diff --git a/src/gui/guiEditBoxWithScrollbar.cpp b/src/gui/guiEditBoxWithScrollbar.cpp index 91d417253..ed5db785b 100644 --- a/src/gui/guiEditBoxWithScrollbar.cpp +++ b/src/gui/guiEditBoxWithScrollbar.cpp @@ -25,9 +25,10 @@ numerical //! constructor GUIEditBoxWithScrollBar::GUIEditBoxWithScrollBar(const wchar_t* text, bool border, IGUIEnvironment* environment, IGUIElement* parent, s32 id, - const core::rect& rectangle, bool writable, bool has_vscrollbar) + const core::rect& rectangle, ISimpleTextureSource *tsrc, + bool writable, bool has_vscrollbar) : GUIEditBox(environment, parent, id, rectangle, border, writable), - m_background(true), m_bg_color_used(false) + m_background(true), m_bg_color_used(false), m_tsrc(tsrc) { #ifdef _DEBUG setDebugName("GUIEditBoxWithScrollBar"); @@ -635,7 +636,7 @@ void GUIEditBoxWithScrollBar::createVScrollBar() irr::core::rect scrollbarrect = m_frame_rect; scrollbarrect.UpperLeftCorner.X += m_frame_rect.getWidth() - m_scrollbar_width; m_vscrollbar = new GUIScrollBar(Environment, getParent(), -1, - scrollbarrect, false, true); + scrollbarrect, false, true, m_tsrc); m_vscrollbar->setVisible(false); m_vscrollbar->setSmallStep(3 * fontHeight); diff --git a/src/gui/guiEditBoxWithScrollbar.h b/src/gui/guiEditBoxWithScrollbar.h index cea482fc2..22c9dce6d 100644 --- a/src/gui/guiEditBoxWithScrollbar.h +++ b/src/gui/guiEditBoxWithScrollbar.h @@ -7,6 +7,8 @@ #include "guiEditBox.h" +class ISimpleTextureSource; + class GUIEditBoxWithScrollBar : public GUIEditBox { public: @@ -14,7 +16,7 @@ public: //! constructor GUIEditBoxWithScrollBar(const wchar_t* text, bool border, IGUIEnvironment* environment, IGUIElement* parent, s32 id, const core::rect& rectangle, - bool writable = true, bool has_vscrollbar = true); + ISimpleTextureSource *tsrc, bool writable = true, bool has_vscrollbar = true); //! destructor virtual ~GUIEditBoxWithScrollBar() {} @@ -56,6 +58,8 @@ protected: bool m_bg_color_used; video::SColor m_bg_color; + + ISimpleTextureSource *m_tsrc; }; diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index afc6d09db..578456139 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -666,7 +666,7 @@ void GUIFormSpecMenu::parseScrollBar(parserData* data, const std::string &elemen spec.ftype = f_ScrollBar; spec.send = true; GUIScrollBar *e = new GUIScrollBar(Environment, data->current_parent, - spec.fid, rect, is_horizontal, true); + spec.fid, rect, is_horizontal, true, m_tsrc); auto style = getDefaultStyleForElement("scrollbar", name); e->setNotClipped(style.getBool(StyleSpec::NOCLIP, false)); @@ -1493,7 +1493,7 @@ void GUIFormSpecMenu::createTextField(parserData *data, FieldSpec &spec, gui::IGUIEditBox *e = nullptr; if (is_multiline) { e = new GUIEditBoxWithScrollBar(spec.fdefault.c_str(), true, Environment, - data->current_parent, spec.fid, rect, is_editable, true); + data->current_parent, spec.fid, rect, m_tsrc, is_editable, true); } else if (is_editable) { e = Environment->addEditBox(spec.fdefault.c_str(), rect, true, data->current_parent, spec.fid); diff --git a/src/gui/guiHyperText.cpp b/src/gui/guiHyperText.cpp index c2461b29b..d50a6cc7f 100644 --- a/src/gui/guiHyperText.cpp +++ b/src/gui/guiHyperText.cpp @@ -1010,7 +1010,7 @@ GUIHyperText::GUIHyperText(const wchar_t *text, IGUIEnvironment *environment, RelativeRect.getWidth() - m_scrollbar_width, 0, RelativeRect.getWidth(), RelativeRect.getHeight()); - m_vscrollbar = new GUIScrollBar(Environment, this, -1, rect, false, true); + m_vscrollbar = new GUIScrollBar(Environment, this, -1, rect, false, true, tsrc); m_vscrollbar->setVisible(false); } diff --git a/src/gui/guiScrollBar.cpp b/src/gui/guiScrollBar.cpp index c6a03f3e4..8ec387d18 100644 --- a/src/gui/guiScrollBar.cpp +++ b/src/gui/guiScrollBar.cpp @@ -11,17 +11,19 @@ the arrow buttons where there is insufficient space. */ #include "guiScrollBar.h" -#include +#include "guiButton.h" #include GUIScrollBar::GUIScrollBar(IGUIEnvironment *environment, IGUIElement *parent, s32 id, - core::rect rectangle, bool horizontal, bool auto_scale) : + core::rect rectangle, bool horizontal, bool auto_scale, + ISimpleTextureSource *tsrc) : IGUIElement(EGUIET_ELEMENT, environment, parent, id, rectangle), up_button(nullptr), down_button(nullptr), is_dragging(false), is_horizontal(horizontal), is_auto_scaling(auto_scale), dragged_by_slider(false), tray_clicked(false), scroll_pos(0), draw_center(0), thumb_size(0), min_pos(0), max_pos(100), small_step(10), - large_step(50), drag_offset(0), page_size(100), border_size(0) + large_step(50), drag_offset(0), page_size(100), border_size(0), + m_tsrc(tsrc) { refreshControls(); setNotClipped(false); @@ -343,8 +345,9 @@ void GUIScrollBar::refreshControls() s32 h = RelativeRect.getHeight(); border_size = RelativeRect.getWidth() < h * 4 ? 0 : h; if (!up_button) { - up_button = Environment->addButton( - core::rect(0, 0, h, h), this); + core::rect up_button_rect(0, 0, h, h); + up_button = GUIButton::addButton(Environment, up_button_rect, m_tsrc, + this, -1, L""); up_button->setSubElement(true); up_button->setTabStop(false); } @@ -361,10 +364,12 @@ void GUIScrollBar::refreshControls() up_button->setAlignment(EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); if (!down_button) { - down_button = Environment->addButton( - core::rect(RelativeRect.getWidth() - h, 0, - RelativeRect.getWidth(), h), - this); + core::rect down_button_rect( + RelativeRect.getWidth() - h, 0, + RelativeRect.getWidth(), h + ); + down_button = GUIButton::addButton(Environment, down_button_rect, m_tsrc, + this, -1, L""); down_button->setSubElement(true); down_button->setTabStop(false); } @@ -386,8 +391,9 @@ void GUIScrollBar::refreshControls() s32 w = RelativeRect.getWidth(); border_size = RelativeRect.getHeight() < w * 4 ? 0 : w; if (!up_button) { - up_button = Environment->addButton( - core::rect(0, 0, w, w), this); + core::rect up_button_rect(0, 0, w, w); + up_button = GUIButton::addButton(Environment, up_button_rect, m_tsrc, + this, -1, L""); up_button->setSubElement(true); up_button->setTabStop(false); } @@ -404,10 +410,12 @@ void GUIScrollBar::refreshControls() up_button->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); if (!down_button) { - down_button = Environment->addButton( - core::rect(0, RelativeRect.getHeight() - w, - w, RelativeRect.getHeight()), - this); + core::rect down_button_rect( + 0, RelativeRect.getHeight() - w, + w, RelativeRect.getHeight() + ); + down_button = GUIButton::addButton(Environment, down_button_rect, m_tsrc, + this, -1, L""); down_button->setSubElement(true); down_button->setTabStop(false); } diff --git a/src/gui/guiScrollBar.h b/src/gui/guiScrollBar.h index d18f8e875..3ff3bba35 100644 --- a/src/gui/guiScrollBar.h +++ b/src/gui/guiScrollBar.h @@ -14,6 +14,8 @@ the arrow buttons where there is insufficient space. #include "irrlichttypes_extrabloated.h" +class ISimpleTextureSource; + using namespace irr; using namespace gui; @@ -21,7 +23,8 @@ class GUIScrollBar : public IGUIElement { public: GUIScrollBar(IGUIEnvironment *environment, IGUIElement *parent, s32 id, - core::rect rectangle, bool horizontal, bool auto_scale); + core::rect rectangle, bool horizontal, bool auto_scale, + ISimpleTextureSource *tsrc); enum ArrowVisibility { @@ -74,4 +77,6 @@ private: core::rect slider_rect; video::SColor current_icon_color; + + ISimpleTextureSource *m_tsrc; }; diff --git a/src/gui/guiTable.cpp b/src/gui/guiTable.cpp index 3e5f1bfc2..b5042802a 100644 --- a/src/gui/guiTable.cpp +++ b/src/gui/guiTable.cpp @@ -66,7 +66,7 @@ GUITable::GUITable(gui::IGUIEnvironment *env, 0, RelativeRect.getWidth(), RelativeRect.getHeight()), - false, true); + false, true, tsrc); m_scrollbar->setSubElement(true); m_scrollbar->setTabStop(false); m_scrollbar->setAlignment(gui::EGUIA_LOWERRIGHT, gui::EGUIA_LOWERRIGHT, diff --git a/src/gui/guiVolumeChange.cpp b/src/gui/guiVolumeChange.cpp index 9f35c852b..066206649 100644 --- a/src/gui/guiVolumeChange.cpp +++ b/src/gui/guiVolumeChange.cpp @@ -86,7 +86,7 @@ void GUIVolumeChange::regenerateGui(v2u32 screensize) core::rect rect(0, 0, 300 * s, 20 * s); rect = rect + v2s32(size.X / 2 - 150 * s, size.Y / 2); auto e = make_irr(Environment, this, - ID_soundSlider, rect, true, false); + ID_soundSlider, rect, true, false, m_tsrc); e->setMax(100); e->setPos(volume); }