diff --git a/changes.txt b/changes.txt index 69c7af5f..7d483296 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,7 @@ -------------------------- Changes in 1.9 (not yet released) +- CGUIComboBox uses now EGDS_SCROLLBAR_SIZE instead of EGDS_WINDOW_BUTTON_WIDTH for the width of the listbox button to allow changing that without changing window topbar height. + Thanks @LunaRebirth for reporting. (Forum: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=1&t=52297&p=303682#p303682) - CGUIListbox, CGUITreeView and CGUITable now resize scrollbars when EGDS_SCROLLBAR_SIZE in the skin changes without having to re-create the elements. This also fixes the problem that drawing looked wrong when this value got changed after the elements were created. Thanks @LunaRebirth for reporting. (Forum: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=1&t=52297&p=303682#p303682) diff --git a/include/IGUISkin.h b/include/IGUISkin.h index bd2de6b5..e685a1ed 100644 --- a/include/IGUISkin.h +++ b/include/IGUISkin.h @@ -149,11 +149,11 @@ namespace gui //! Enumeration for default sizes. enum EGUI_DEFAULT_SIZE { - //! default with / height of scrollbar + //! default with / height of scrollbar. Also width of drop-down button in comboboxes. EGDS_SCROLLBAR_SIZE = 0, //! height of menu EGDS_MENU_HEIGHT, - //! width of a window button + //! width and height of a window titlebar button (like minimize/maximize/close buttons). The titlebar height is also calculated from that. EGDS_WINDOW_BUTTON_WIDTH, //! width of a checkbox check EGDS_CHECK_BOX_WIDTH, diff --git a/source/Irrlicht/CGUIComboBox.cpp b/source/Irrlicht/CGUIComboBox.cpp index e26a9fec..1efd345b 100644 --- a/source/Irrlicht/CGUIComboBox.cpp +++ b/source/Irrlicht/CGUIComboBox.cpp @@ -33,18 +33,7 @@ CGUIComboBox::CGUIComboBox(IGUIEnvironment* environment, IGUIElement* parent, IGUISkin* skin = Environment->getSkin(); - s32 width = 15; - if (skin) - width = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); - - core::rect r; - r.UpperLeftCorner.X = rectangle.getWidth() - width - 2; - r.LowerRightCorner.X = rectangle.getWidth() - 2; - - r.UpperLeftCorner.Y = 2; - r.LowerRightCorner.Y = rectangle.getHeight() - 2; - - ListButton = Environment->addButton(r, this, -1, L""); + ListButton = Environment->addButton(core::recti(0,0,1,1), this, -1, L""); if (skin && skin->getSpriteBank()) { ListButton->setSpriteBank(skin->getSpriteBank()); @@ -55,12 +44,7 @@ CGUIComboBox::CGUIComboBox(IGUIEnvironment* environment, IGUIElement* parent, ListButton->setSubElement(true); ListButton->setTabStop(false); - r.UpperLeftCorner.X = 2; - r.UpperLeftCorner.Y = 2; - r.LowerRightCorner.X = RelativeRect.getWidth() - (ListButton->getAbsolutePosition().getWidth() + 2); - r.LowerRightCorner.Y = RelativeRect.getHeight() - 2; - - SelectedText = Environment->addStaticText(L"", r, false, false, this, -1, false); + SelectedText = Environment->addStaticText(L"", core::recti(0,0,1,1), false, false, this, -1, false); SelectedText->setSubElement(true); SelectedText->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); SelectedText->setTextAlignment(EGUIA_UPPERLEFT, EGUIA_CENTER); @@ -68,6 +52,8 @@ CGUIComboBox::CGUIComboBox(IGUIEnvironment* environment, IGUIElement* parent, SelectedText->setOverrideColor(skin->getColor(EGDC_BUTTON_TEXT)); SelectedText->enableOverrideColor(true); + updateListButtonWidth(skin ? skin->getSize(EGDS_SCROLLBAR_SIZE) : 15); + // this element can be tabbed to setTabStop(true); setTabOrder(-1); @@ -377,6 +363,24 @@ void CGUIComboBox::sendSelectionChangedEvent() } } +void CGUIComboBox::updateListButtonWidth(s32 width) +{ + if (ListButton->getRelativePosition().getWidth() != width) + { + core::rect r; + r.UpperLeftCorner.X = RelativeRect.getWidth() - width - 2; + r.LowerRightCorner.X = RelativeRect.getWidth() - 2; + r.UpperLeftCorner.Y = 2; + r.LowerRightCorner.Y = RelativeRect.getHeight() - 2; + ListButton->setRelativePosition(r); + + r.UpperLeftCorner.X = 2; + r.UpperLeftCorner.Y = 2; + r.LowerRightCorner.X = RelativeRect.getWidth() - (width + 2); + r.LowerRightCorner.Y = RelativeRect.getHeight() - 2; + SelectedText->setRelativePosition(r); + } +} //! draws the element and its children void CGUIComboBox::draw() @@ -386,6 +390,8 @@ void CGUIComboBox::draw() IGUISkin* skin = Environment->getSkin(); + updateListButtonWidth(skin->getSize(EGDS_SCROLLBAR_SIZE)); + // font changed while the listbox is open? if ( ActiveFont != skin->getFont() && ListBox ) { diff --git a/source/Irrlicht/CGUIComboBox.h b/source/Irrlicht/CGUIComboBox.h index 1edcfb7b..5aa5de6d 100644 --- a/source/Irrlicht/CGUIComboBox.h +++ b/source/Irrlicht/CGUIComboBox.h @@ -84,6 +84,7 @@ namespace gui void openCloseMenu(); void sendSelectionChangedEvent(); + void updateListButtonWidth(s32 width); IGUIButton* ListButton; IGUIStaticText* SelectedText;