-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Templates #32
Comments
…against external modification. An element should have complete control over its physical structure (at least its direct children) based on its logical content as specified in XML or programmatically through public methods. External code should use other means to modify an element's logical content.
…ns that I think I'll use for templates. Not sure how everything will fit together yet, so these may be trash later.
…to specify attach points from superclasses that should not be specifiable via source XML.
…ure, not actual MUIS elements. A separate "content creator" creates the actual elements and initializes them now. It seems that this change has triggered a bug in the style sheet code that is causing the animated demo to make a green button on a green background. The animated style expression maybe isn't getting enough priority. I don't think I actually created the bug with these changes--just exposed it.
…hey seem like good fixes though, so I'm committing them anyway.
…e sheet effects and some other style-related bugs
…sTemplate, but I want that old code around for a while as a reference. Stubbed some functionality out in template2, but definitely a lot of design to go.
…turn value to MuisElement.initChildren() that is the mutable child list controlling the element's children. Normally this is called by the content creator without even storing the return value, but I think it may be useful from MuisTemplate2.
…e the template XML file, storing the attach points and widget structure, and then replace the attach points appropriately from the main XML. Working on adding more utility to the class to be able to grab elements in attach points on demand and control them from subclasses.
Just thought of a problem with the way I'm doing this. It would be possible to have a nested template widgets in such a way that roles could potentially conflict. For example, a combo box widget whose items have a role "item" may be contained in a templated widget with this template XML: <template>
<combo>
<element role="item" template:attach-point="item2" />
</combo>
</template> So the main XML to specify the second template widget could specify content of role "item2" which would then be passed to the combo box to be interpreted as role "item". This is a valid use case and needs to be permitted easily and cleanly. One way is for each template type to have its own role attribute. Each instance could have its own attribute also, but this is not necessary as templates cannot be recursive. Right now, I think the attribute manager enforces name uniqueness, so the name of each attribute would have to be different. Should we change this to allow multiple attributes of the same name? Can we hide the inner role attribute from the outside somehow? |
… functionality everywhere. Also added SubList.
I refactored the role attribute into the TemplateStructure class, so now there is a role attribute per template type. As noted in the comment on the issue, the attribute manager does not currently support multiple attributes with the same name. I will need to correct this before any of this works. Implemented the AttachPointInstance inner class which enables basic get/set/collection functionality for attach points. Only one particularly difficult piece of logic missing on the setter for the element occupying a singular attach point. I left a compile error to mark it. Not confident in how I tied up the initChildren functionality. I need to try to follow that logic through before I start debugging.
…the template part is working perfectly, but now there's a problem where style sheet property specifying the button's texture is being inherited by the button's content pane (a block). So it looks like a button within a button. No obvious way to fix this easily.
Even though it looks like the button template is working, I'm leaving this open for now. It seems pretty likely that some other bug will show up after I get the style sheet problem fixed. |
It looks like this is working. At least well enough to implement a button. I'll no doubt reopen this or else open a related bug when I need to make a combo box or something. |
I started on this years ago, but I don't remember any of my ideas. The code is still there, but MUIS has changed around it so much that it may need to be rewritten.
The idea is that a logical widget may be a collection of many simpler widgets working together. For example, a combo box is a combination of a content pane (perhaps a text field), a button (with the down arrow) and a menu. It should be possible to specify a combo box in the XML with its options directly like
without worrying about all the components needed to implement it and without needing to create those components programmatically.
The template functionality allows a widget class to parse a separate XML file containing the widget as a set of component widgets. In addition to the widgets, this file contains markers called "attach points" that label the individual components for easy retrieval from source code (e.g. the "menu" attach point would be the menu widget of a combo box). The widget needs easy access to its children as specified in the main XML (where the templated widget is invoked) such that they are not necessarily added to the widget as children directly, but are given to the widget as content to do what it likes with them. This may necessitate multiple calls to initChildren().
The children (from main XML) of a templated widget might not even need to extend MuisElement. For example, you might specifiy a data model that a widget is to use as an XML element (an attribute would not allow much configuration of the model in XML).
Templated widgets may contain templated widgets in their template XML description. Any MUIS application, no matter how complex, should have a root MUIS file of only a few kilobytes. All that needs to be specified in the root file is one or possibly a very few top-level widgets and a bit of configuration data in the attributes. Those widgets then populate themselves with other widgets from their template XMLs and so on to make the full depth of the application's structure.
This is crucial functionality for complex widgets and needs to be thought out carefully and implemented well the first time, even though it will probably be refactored and improved as more complex widgets are developed.
The text was updated successfully, but these errors were encountered: