mirror of
https://github.com/minetest/minetest.git
synced 2024-08-19 21:14:15 +02:00
Use our GUIButton in our GUIScrollBar
Note that GUIScrollBar needs an ISimpleTextureSource now due to button styling.
This commit is contained in:
parent
9d62abbe46
commit
91c0439922
@ -25,9 +25,10 @@ numerical
|
||||
//! constructor
|
||||
GUIEditBoxWithScrollBar::GUIEditBoxWithScrollBar(const wchar_t* text, bool border,
|
||||
IGUIEnvironment* environment, IGUIElement* parent, s32 id,
|
||||
const core::rect<s32>& rectangle, bool writable, bool has_vscrollbar)
|
||||
const core::rect<s32>& 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<s32> 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);
|
||||
|
@ -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<s32>& 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;
|
||||
};
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -11,17 +11,19 @@ the arrow buttons where there is insufficient space.
|
||||
*/
|
||||
|
||||
#include "guiScrollBar.h"
|
||||
#include <IGUIButton.h>
|
||||
#include "guiButton.h"
|
||||
#include <IGUISkin.h>
|
||||
|
||||
GUIScrollBar::GUIScrollBar(IGUIEnvironment *environment, IGUIElement *parent, s32 id,
|
||||
core::rect<s32> rectangle, bool horizontal, bool auto_scale) :
|
||||
core::rect<s32> 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<s32>(0, 0, h, h), this);
|
||||
core::rect<s32> 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<s32>(RelativeRect.getWidth() - h, 0,
|
||||
RelativeRect.getWidth(), h),
|
||||
this);
|
||||
core::rect<s32> 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<s32>(0, 0, w, w), this);
|
||||
core::rect<s32> 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<s32>(0, RelativeRect.getHeight() - w,
|
||||
w, RelativeRect.getHeight()),
|
||||
this);
|
||||
core::rect<s32> 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);
|
||||
}
|
||||
|
@ -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<s32> rectangle, bool horizontal, bool auto_scale);
|
||||
core::rect<s32> rectangle, bool horizontal, bool auto_scale,
|
||||
ISimpleTextureSource *tsrc);
|
||||
|
||||
enum ArrowVisibility
|
||||
{
|
||||
@ -74,4 +77,6 @@ private:
|
||||
|
||||
core::rect<s32> slider_rect;
|
||||
video::SColor current_icon_color;
|
||||
|
||||
ISimpleTextureSource *m_tsrc;
|
||||
};
|
||||
|
@ -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,
|
||||
|
@ -86,7 +86,7 @@ void GUIVolumeChange::regenerateGui(v2u32 screensize)
|
||||
core::rect<s32> rect(0, 0, 300 * s, 20 * s);
|
||||
rect = rect + v2s32(size.X / 2 - 150 * s, size.Y / 2);
|
||||
auto e = make_irr<GUIScrollBar>(Environment, this,
|
||||
ID_soundSlider, rect, true, false);
|
||||
ID_soundSlider, rect, true, false, m_tsrc);
|
||||
e->setMax(100);
|
||||
e->setPos(volume);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user