GUI: add PUI combo-box mapping
This commit is contained in:
parent
aa57b7992f
commit
581f8d163f
2 changed files with 56 additions and 3 deletions
|
@ -41,6 +41,13 @@ gui.widgets.PopupMenu = {
|
|||
me.menu().append(gui.widgets.MenuItem.new());
|
||||
},
|
||||
|
||||
# helper to set the current item by passing in
|
||||
# a value of an item
|
||||
setCurrentByValue: func(value) {
|
||||
|
||||
|
||||
},
|
||||
|
||||
# protected:
|
||||
_setView: func(view)
|
||||
{
|
||||
|
|
|
@ -383,10 +383,7 @@ var XMLSlider =
|
|||
{
|
||||
init: func(objectProps)
|
||||
{
|
||||
logprint(LOG_INFO, "Init of XMLSlider");
|
||||
# TODO: support vertical sliders
|
||||
|
||||
|
||||
},
|
||||
|
||||
show: func(viewParent)
|
||||
|
@ -481,10 +478,27 @@ var XMLHRule =
|
|||
{
|
||||
show: func(viewParent)
|
||||
{
|
||||
var label = me.configValue("label");
|
||||
|
||||
me._view = cwidgets.HorizontalRule.new(viewParent, canvas.style, {});
|
||||
if (label) {
|
||||
me._view.setText(label);
|
||||
}
|
||||
|
||||
me._layout = me._view;
|
||||
me._applyLayoutConfig();
|
||||
return me._view;
|
||||
},
|
||||
|
||||
update: func()
|
||||
{
|
||||
# allow label to be updated live
|
||||
var l = me.value();
|
||||
if (l) {
|
||||
me._view.setText(l);
|
||||
}
|
||||
|
||||
me._view.setSize(me._size);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -499,6 +513,32 @@ var XMLVRule =
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
var XMLPopupMenu =
|
||||
{
|
||||
init: func(objectProps)
|
||||
{
|
||||
},
|
||||
|
||||
show: func(viewParent)
|
||||
{
|
||||
# do we support a label or is that a seperate widget?
|
||||
|
||||
me._view = cwidgets.PopupMenu.new(viewParent, canvas.style, {});
|
||||
me._layout = me._view;
|
||||
me._applyLayoutConfig();
|
||||
me.update();
|
||||
return me._view;
|
||||
},
|
||||
|
||||
update: func()
|
||||
{
|
||||
if (me._view and !me._view.hasActiveFocus()) {
|
||||
me._view.setCurrentByValue(me.value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
# this is the callback function invoked by C++ to build Nasal peers
|
||||
# for the C++ objects defined by XML (PUICompatObject). It's primarly
|
||||
# a factory method: once the peer object is created, all other behaviour
|
||||
|
@ -545,6 +585,12 @@ var _createCompatObject = func(type)
|
|||
widget = XMLVRule;
|
||||
}
|
||||
|
||||
# these are called combos in XML, but are really
|
||||
# popup menus, no free value entry is possible
|
||||
if (type == "combo") {
|
||||
widget = XMLPopupMenu;
|
||||
}
|
||||
|
||||
return gui.xml.Object.new({
|
||||
parents: [widget, XMLObjectBase]
|
||||
}, type);
|
||||
|
|
Loading…
Reference in a new issue