From e6cb3de637cd15eed5a25a9061a9959a3e77b6b6 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Mon, 16 Jan 2012 06:26:57 -0200 Subject: [PATCH] add options style for UIComboBox, fix push values of otml nodes --- TODO | 1 + modules/core_widgets/tooltip/tooltip.lua | 4 ++-- modules/core_widgets/uicombobox.lua | 10 +++++++++- src/framework/luascript/luavaluecasts.cpp | 17 ++++++++++------- src/framework/ui/uiwidget.cpp | 3 +++ 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/TODO b/TODO index 471104d7..2a637ec0 100644 --- a/TODO +++ b/TODO @@ -64,6 +64,7 @@ change win32 mouse cursor icon [bart] make set of background/icon/image width alone work [bart] check for recursive anchors and print a error instead of crashing [bart] make api to enable/disable capture of events to avoid massive event processing +[bart] review style apply system == Client modules [bart] make possible to reload modules diff --git a/modules/core_widgets/tooltip/tooltip.lua b/modules/core_widgets/tooltip/tooltip.lua index b890e925..1c672e12 100644 --- a/modules/core_widgets/tooltip/tooltip.lua +++ b/modules/core_widgets/tooltip/tooltip.lua @@ -55,8 +55,8 @@ local function onWidgetStyleApply(widget, styleName, styleNode) end end -connect(UIWidget, { onStyleApply = onWidgetStyleApply, - onHoverChange = onWidgetHoverChange}) +--connect(UIWidget, { onStyleApply = onWidgetStyleApply, +-- onHoverChange = onWidgetHoverChange}) -- UIWidget extensions function UIWidget:setTooltip(text) diff --git a/modules/core_widgets/uicombobox.lua b/modules/core_widgets/uicombobox.lua index ef08dbfa..b6de5e63 100644 --- a/modules/core_widgets/uicombobox.lua +++ b/modules/core_widgets/uicombobox.lua @@ -13,7 +13,7 @@ function UIComboBox:setCurrentOption(text) if v.text == text and self.m_currentIndex ~= i then self.m_currentIndex = i self:setText(text) - self:onOptionChange(text, data) + self:onOptionChange(text, v.data) return end end @@ -38,6 +38,14 @@ function UIComboBox:onMousePress(mousePos, mouseButton) return true end +function UIComboBox:onStyleApply(styleName, styleNode) + if styleNode.options then + for k,option in pairs(styleNode.options) do + self:addOption(option) + end + end +end + function UIComboBox:onOptionChange(optionText, optionData) -- nothing todo end diff --git a/src/framework/luascript/luavaluecasts.cpp b/src/framework/luascript/luavaluecasts.cpp index 352a4b6b..0c5a268e 100644 --- a/src/framework/luascript/luavaluecasts.cpp +++ b/src/framework/luascript/luavaluecasts.cpp @@ -219,15 +219,18 @@ void push_otml_subnode_luavalue(const OTMLNodePtr& node) } else if(node->hasChildren()) { g_lua.newTable(); bool pushedChild = false; + int currentIndex = 1; for(const OTMLNodePtr& cnode : node->children()) { - if(cnode->isUnique()) { - push_luavalue(cnode); - if(!g_lua.isNil()) { - g_lua.setField(cnode->tag()); - pushedChild = true; + push_otml_subnode_luavalue(cnode); + if(!g_lua.isNil()) { + if(cnode->isUnique()) { + g_lua.pushString(cnode->tag()); + g_lua.rawSet(); } else - g_lua.pop(); - } + g_lua.rawSeti(currentIndex++); + pushedChild = true; + } else + g_lua.pop(); } if(!pushedChild) { g_lua.pop(); diff --git a/src/framework/ui/uiwidget.cpp b/src/framework/ui/uiwidget.cpp index 1be66b7f..cc58038b 100644 --- a/src/framework/ui/uiwidget.cpp +++ b/src/framework/ui/uiwidget.cpp @@ -364,6 +364,9 @@ void UIWidget::unlockChild(const UIWidgetPtr& child) void UIWidget::applyStyle(const OTMLNodePtr& styleNode) { + if(styleNode->size() == 0) + return; + m_loadingStyle = true; try { onStyleApply(styleNode->tag(), styleNode);