Commit 37dce51e authored by bitplane's avatar bitplane

Fixed scrollbars in GUI editor



git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3541 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 271754f4
Changes in 1.8 (??.??.2011) Changes in 1.8 (??.??.2011)
- Fixed panel scrollbars in GUI editor, reported by Armen
- Add some getters to IGUIImage: getImage, getColor - 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. - 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.
......
...@@ -85,19 +85,16 @@ void CGUIAttributeEditor::refreshAttribs() ...@@ -85,19 +85,16 @@ void CGUIAttributeEditor::refreshAttribs()
str += "_attribute"; str += "_attribute";
CGUIAttribute* n = (CGUIAttribute*)Environment->addGUIElement(str.c_str(), this); 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) if (n)
{ {
// add custom attribute editor
AttribList.push_back(n); AttribList.push_back(n);
n->setParentID(getID()); n->setParentID(getID());
n->grab(); 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]->setSubElement(true);
AttribList[i]->setRelativePosition(r); AttribList[i]->setRelativePosition(r);
......
...@@ -94,47 +94,48 @@ IGUIElement* CGUIEditFactory::addGUIElement(const c8* typeName, IGUIElement* par ...@@ -94,47 +94,48 @@ IGUIElement* CGUIEditFactory::addGUIElement(const c8* typeName, IGUIElement* par
core::stringc elementType(typeName); core::stringc elementType(typeName);
IGUIElement* ret=0; IGUIElement* ret=0;
if (parent == 0) if (!parent)
{
parent = Environment->getRootGUIElement(); parent = Environment->getRootGUIElement();
}
// editor workspace // editor workspace
if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIEDIT])) if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIEDIT]))
ret = new CGUIEditWorkspace(Environment, -1, parent); ret = new CGUIEditWorkspace(Environment, -1, 0);
// editor window // editor window
else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIEDITWINDOW])) else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIEDITWINDOW]))
ret = new CGUIEditWindow(Environment, core::rect<s32>(0,0,100,100), parent); ret = new CGUIEditWindow(Environment, core::rect<s32>(0,0,100,100), 0);
// Klasker's GUI Panel // Klasker's GUI Panel
else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIPANEL])) else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIPANEL]))
ret = new CGUIPanel(Environment, parent); ret = new CGUIPanel(Environment, 0);
// texture cache browser // texture cache browser
else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_TEXTUREBROWSER])) else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_TEXTUREBROWSER]))
ret = new CGUITextureCacheBrowser(Environment, -1, parent); ret = new CGUITextureCacheBrowser(Environment, -1, 0);
// block of attribute editors // block of attribute editors
else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_ATTRIBUTEEDITOR])) else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_ATTRIBUTEEDITOR]))
ret = new CGUIAttributeEditor(Environment, -1, parent); ret = new CGUIAttributeEditor(Environment, -1, 0);
//! single attribute editors //! single attribute editors
else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_STRINGATTRIBUTE])) 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])) 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])) 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])) 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])) 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])) else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_TEXTUREATTRIBUTE]))
ret = new CGUITextureAttribute(Environment, parent, -1); ret = new CGUITextureAttribute(Environment, 0, -1);
// stubs and custom editors // stubs and custom editors
else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_CONTEXTMENUEDITOR]) || else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_CONTEXTMENUEDITOR]) ||
elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_MENUEDITOR]) || elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_MENUEDITOR]) ||
elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_FILEDIALOGEDITOR]) || elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_FILEDIALOGEDITOR]) ||
elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_COLORDIALOGEDITOR]) || elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_COLORDIALOGEDITOR]) ||
elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_MODALSCREENEDITOR]) ) 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 // the environment now has the reference, so we can drop the element
if (ret) if (ret)
......
...@@ -35,16 +35,16 @@ CGUIPanel::CGUIPanel( IGUIEnvironment* environment, IGUIElement* parent, s32 id, ...@@ -35,16 +35,16 @@ CGUIPanel::CGUIPanel( IGUIEnvironment* environment, IGUIElement* parent, s32 id,
core::rect<s32> rct = core::rect<s32>(width - SCROLL_BAR_SIZE,0, width, height); core::rect<s32> rct = core::rect<s32>(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->setSubElement(true);
VScrollBar->setTabStop(false); VScrollBar->setTabStop(false);
VScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); VScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
VScrollBar->grab(); VScrollBar->grab();
IGUIElement::addChild(VScrollBar); IGUIElement::addChild(VScrollBar);
rct = core::rect<s32>(0,height - SCROLL_BAR_SIZE, width - SCROLL_BAR_SIZE,height ); rct = core::rect<s32>(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->setSubElement(true);
HScrollBar->setTabStop(false); HScrollBar->setTabStop(false);
HScrollBar->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT); HScrollBar->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT);
...@@ -59,7 +59,7 @@ CGUIPanel::CGUIPanel( IGUIEnvironment* environment, IGUIElement* parent, s32 id, ...@@ -59,7 +59,7 @@ CGUIPanel::CGUIPanel( IGUIEnvironment* environment, IGUIElement* parent, s32 id,
ClipPane->grab(); ClipPane->grab();
IGUIElement::addChild(ClipPane); IGUIElement::addChild(ClipPane);
InnerPane = environment->addTab( rct, ClipPane, -1); InnerPane = environment->addTab(rct, ClipPane, -1);
InnerPane->setSubElement(true); InnerPane->setSubElement(true);
InnerPane->grab(); InnerPane->grab();
...@@ -157,7 +157,7 @@ E_SCROLL_BAR_MODE CGUIPanel::getHScrollBarMode() const ...@@ -157,7 +157,7 @@ E_SCROLL_BAR_MODE CGUIPanel::getHScrollBarMode() const
return HScrollBarMode; return HScrollBarMode;
} }
void CGUIPanel::setHScrollBarMode( E_SCROLL_BAR_MODE mode ) void CGUIPanel::setHScrollBarMode(E_SCROLL_BAR_MODE mode)
{ {
HScrollBarMode = mode; HScrollBarMode = mode;
NeedsUpdate = true; NeedsUpdate = true;
...@@ -166,7 +166,7 @@ void CGUIPanel::setHScrollBarMode( E_SCROLL_BAR_MODE mode ) ...@@ -166,7 +166,7 @@ void CGUIPanel::setHScrollBarMode( E_SCROLL_BAR_MODE mode )
bool CGUIPanel::OnEvent(const SEvent &event) bool CGUIPanel::OnEvent(const SEvent &event)
{ {
// Redirect mouse wheel to scrollbar // 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()) if (VScrollBar->isVisible())
{ {
...@@ -183,8 +183,8 @@ bool CGUIPanel::OnEvent(const SEvent &event) ...@@ -183,8 +183,8 @@ bool CGUIPanel::OnEvent(const SEvent &event)
} }
else else
{ {
if ( event.EventType == EET_GUI_EVENT && event.GUIEvent.EventType == EGET_SCROLL_BAR_CHANGED && if (event.EventType == EET_GUI_EVENT && event.GUIEvent.EventType == EGET_SCROLL_BAR_CHANGED &&
( event.GUIEvent.Caller == HScrollBar || event.GUIEvent.Caller == VScrollBar) ) (event.GUIEvent.Caller == HScrollBar || event.GUIEvent.Caller == VScrollBar) )
{ {
moveInnerPane(); moveInnerPane();
...@@ -224,12 +224,12 @@ void CGUIPanel::resizeInnerPane() ...@@ -224,12 +224,12 @@ void CGUIPanel::resizeInnerPane()
InnerPane->setRelativePosition(outerRect); InnerPane->setRelativePosition(outerRect);
// get desired size (total size of all children) // get desired size (total size of all children)
core::rect<s32> totalRect(0,0,0,0); core::rect<s32> totalRect(0, 0, 0, 0);
core::list<IGUIElement*>::ConstIterator it; core::list<IGUIElement*>::ConstIterator it;
for ( it = InnerPane->getChildren().begin(); for (it = InnerPane->getChildren().begin();
it != InnerPane->getChildren().end(); ++it ) it != InnerPane->getChildren().end(); ++it)
{ {
core::rect<s32> rct = (*it)->getRelativePosition(); core::rect<s32> rct = (*it)->getRelativePosition();
totalRect.addInternalPoint(rct.UpperLeftCorner); totalRect.addInternalPoint(rct.UpperLeftCorner);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment