From 37dce51ed5f7c0403fc5aa004b6ededff578dfe6 Mon Sep 17 00:00:00 2001 From: bitplane Date: Fri, 7 Jan 2011 00:47:30 +0000 Subject: [PATCH] Fixed scrollbars in GUI editor git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3541 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 2 ++ tools/GUIEditor/CGUIAttributeEditor.cpp | 11 +++---- tools/GUIEditor/CGUIEditFactory.cpp | 41 +++++++++++++------------ tools/GUIEditor/CGUIPanel.cpp | 22 ++++++------- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/changes.txt b/changes.txt index 6e301bbe..e1920371 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,7 @@ Changes in 1.8 (??.??.2011) + - Fixed panel scrollbars in GUI editor, reported by Armen + - Add some getters to IGUIImage: getImage, getColor - API change: Added write only lock mode for textures. The lock method has changed the signature and uses an enum parameter now instead of a bool. The default is still to lock for read/write (previously 'false'). The old 'true' value should be replaced by ETLM_READ_ONLY. diff --git a/tools/GUIEditor/CGUIAttributeEditor.cpp b/tools/GUIEditor/CGUIAttributeEditor.cpp index f34b8b47..f6b8d8ce 100644 --- a/tools/GUIEditor/CGUIAttributeEditor.cpp +++ b/tools/GUIEditor/CGUIAttributeEditor.cpp @@ -85,19 +85,16 @@ void CGUIAttributeEditor::refreshAttribs() str += "_attribute"; CGUIAttribute* n = (CGUIAttribute*)Environment->addGUIElement(str.c_str(), this); + // if this doesn't exist, use a string editor + if (!n) + n = (CGUIAttribute*)Environment->addGUIElement("string_attribute", this); + if (n) { - // add custom attribute editor AttribList.push_back(n); n->setParentID(getID()); n->grab(); } - else - { - // create a generic string editor - AttribList.push_back(new CGUIStringAttribute(Environment, this, getID())); - // dont grab it because we created it with new - } AttribList[i]->setSubElement(true); AttribList[i]->setRelativePosition(r); diff --git a/tools/GUIEditor/CGUIEditFactory.cpp b/tools/GUIEditor/CGUIEditFactory.cpp index b92eaaa3..c39218db 100644 --- a/tools/GUIEditor/CGUIEditFactory.cpp +++ b/tools/GUIEditor/CGUIEditFactory.cpp @@ -94,47 +94,48 @@ IGUIElement* CGUIEditFactory::addGUIElement(const c8* typeName, IGUIElement* par core::stringc elementType(typeName); IGUIElement* ret=0; - if (parent == 0) - { + if (!parent) parent = Environment->getRootGUIElement(); - } // editor workspace if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIEDIT])) - ret = new CGUIEditWorkspace(Environment, -1, parent); + ret = new CGUIEditWorkspace(Environment, -1, 0); // editor window else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIEDITWINDOW])) - ret = new CGUIEditWindow(Environment, core::rect(0,0,100,100), parent); + ret = new CGUIEditWindow(Environment, core::rect(0,0,100,100), 0); // Klasker's GUI Panel else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIPANEL])) - ret = new CGUIPanel(Environment, parent); + ret = new CGUIPanel(Environment, 0); // texture cache browser else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_TEXTUREBROWSER])) - ret = new CGUITextureCacheBrowser(Environment, -1, parent); + ret = new CGUITextureCacheBrowser(Environment, -1, 0); // block of attribute editors else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_ATTRIBUTEEDITOR])) - ret = new CGUIAttributeEditor(Environment, -1, parent); + ret = new CGUIAttributeEditor(Environment, -1, 0); //! single attribute editors else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_STRINGATTRIBUTE])) - ret = new CGUIStringAttribute(Environment, parent, -1); + ret = new CGUIStringAttribute(Environment, 0, -1); else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_BOOLATTRIBUTE])) - ret = new CGUIBoolAttribute(Environment, parent, -1); + ret = new CGUIBoolAttribute(Environment, 0, -1); else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_ENUMATTRIBUTE])) - ret = new CGUIEnumAttribute(Environment, parent, -1); + ret = new CGUIEnumAttribute(Environment, 0, -1); else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_COLORATTRIBUTE])) - ret = new CGUIColorAttribute(Environment, parent, -1); + ret = new CGUIColorAttribute(Environment, 0, -1); else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_COLORFATTRIBUTE])) - ret = new CGUIColorAttribute(Environment, parent, -1); + ret = new CGUIColorAttribute(Environment, 0, -1); else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_TEXTUREATTRIBUTE])) - ret = new CGUITextureAttribute(Environment, parent, -1); + ret = new CGUITextureAttribute(Environment, 0, -1); // stubs and custom editors - else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_CONTEXTMENUEDITOR]) || - elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_MENUEDITOR]) || - elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_FILEDIALOGEDITOR]) || - elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_COLORDIALOGEDITOR]) || + else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_CONTEXTMENUEDITOR]) || + elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_MENUEDITOR]) || + elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_FILEDIALOGEDITOR]) || + elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_COLORDIALOGEDITOR]) || elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_MODALSCREENEDITOR]) ) - ret = new CGUIDummyEditorStub(Environment, parent, typeName); + ret = new CGUIDummyEditorStub(Environment, 0, typeName); + // add the element to its parent + if (ret) + parent->addChild(ret); // the environment now has the reference, so we can drop the element if (ret) @@ -151,7 +152,7 @@ s32 CGUIEditFactory::getCreatableGUIElementTypeCount() const } -//! returns type name of a createable element type +//! returns type name of a createable element type const c8* CGUIEditFactory::getCreateableGUIElementTypeName(s32 idx) const { if (idx>=0 && idx rct = core::rect(width - SCROLL_BAR_SIZE,0, width, height); - VScrollBar = environment->addScrollBar( false, rct, 0, id ); + VScrollBar = environment->addScrollBar(false, rct, 0, id); VScrollBar->setSubElement(true); VScrollBar->setTabStop(false); VScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); VScrollBar->grab(); IGUIElement::addChild(VScrollBar); - rct = core::rect(0,height - SCROLL_BAR_SIZE, width - SCROLL_BAR_SIZE,height ); + rct = core::rect(0, height - SCROLL_BAR_SIZE, width - SCROLL_BAR_SIZE,height ); - HScrollBar = environment->addScrollBar( true, rct, 0, id ); + HScrollBar = environment->addScrollBar(true, rct, 0, id); HScrollBar->setSubElement(true); HScrollBar->setTabStop(false); HScrollBar->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT); @@ -59,7 +59,7 @@ CGUIPanel::CGUIPanel( IGUIEnvironment* environment, IGUIElement* parent, s32 id, ClipPane->grab(); IGUIElement::addChild(ClipPane); - InnerPane = environment->addTab( rct, ClipPane, -1); + InnerPane = environment->addTab(rct, ClipPane, -1); InnerPane->setSubElement(true); InnerPane->grab(); @@ -157,7 +157,7 @@ E_SCROLL_BAR_MODE CGUIPanel::getHScrollBarMode() const return HScrollBarMode; } -void CGUIPanel::setHScrollBarMode( E_SCROLL_BAR_MODE mode ) +void CGUIPanel::setHScrollBarMode(E_SCROLL_BAR_MODE mode) { HScrollBarMode = mode; NeedsUpdate = true; @@ -166,7 +166,7 @@ void CGUIPanel::setHScrollBarMode( E_SCROLL_BAR_MODE mode ) bool CGUIPanel::OnEvent(const SEvent &event) { // Redirect mouse wheel to scrollbar - if ( event.EventType == EET_MOUSE_INPUT_EVENT && event.MouseInput.Event == EMIE_MOUSE_WHEEL ) + if (event.EventType == EET_MOUSE_INPUT_EVENT && event.MouseInput.Event == EMIE_MOUSE_WHEEL) { if (VScrollBar->isVisible()) { @@ -183,8 +183,8 @@ bool CGUIPanel::OnEvent(const SEvent &event) } else { - if ( event.EventType == EET_GUI_EVENT && event.GUIEvent.EventType == EGET_SCROLL_BAR_CHANGED && - ( event.GUIEvent.Caller == HScrollBar || event.GUIEvent.Caller == VScrollBar) ) + if (event.EventType == EET_GUI_EVENT && event.GUIEvent.EventType == EGET_SCROLL_BAR_CHANGED && + (event.GUIEvent.Caller == HScrollBar || event.GUIEvent.Caller == VScrollBar) ) { moveInnerPane(); @@ -224,12 +224,12 @@ void CGUIPanel::resizeInnerPane() InnerPane->setRelativePosition(outerRect); // get desired size (total size of all children) - core::rect totalRect(0,0,0,0); + core::rect totalRect(0, 0, 0, 0); core::list::ConstIterator it; - for ( it = InnerPane->getChildren().begin(); - it != InnerPane->getChildren().end(); ++it ) + for (it = InnerPane->getChildren().begin(); + it != InnerPane->getChildren().end(); ++it) { core::rect rct = (*it)->getRelativePosition(); totalRect.addInternalPoint(rct.UpperLeftCorner);