1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
![]() |
index : minetest.git | |
modified minetest for gpcfs purposes | gpcf |
aboutsummaryrefslogtreecommitdiff |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
/*
Copyright (C) 2002-2013 Nikolaus Gebhardt
This file is part of the "Irrlicht Engine".
For conditions of distribution and use, see copyright notice in irrlicht.h
Modified 2019.05.01 by stujones11, Stuart Jones <stujones111@gmail.com>
This is a heavily modified copy of the Irrlicht CGUIScrollBar class
which includes automatic scaling of the thumb slider and hiding of
the arrow buttons where there is insufficient space.
*/
#include "guiScrollBar.h"
#include <IGUIButton.h>
#include <IGUISkin.h>
GUIScrollBar::GUIScrollBar(IGUIEnvironment *environment, IGUIElement *parent, s32 id,
core::rect<s32> rectangle, bool horizontal, bool auto_scale) :
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)
{
refreshControls();
setNotClipped(false);
setTabStop(true);
setTabOrder(-1);
setPos(0);
}
bool GUIScrollBar::OnEvent(const SEvent &event)
{
if (isEnabled()) {
switch (event.EventType) {
case EET_KEY_INPUT_EVENT:
if (event.KeyInput.PressedDown) {
const s32 old_pos = scroll_pos;
bool absorb = true;
switch (event.KeyInput.Key) {
case KEY_LEFT:
case KEY_UP:
setPos(scroll_pos - small_step);
break;
case KEY_RIGHT:
case KEY_DOWN:
setPos(scroll_pos + small_step);
break;
case KEY_HOME:
setPos(min_pos);
break;
case KEY_PRIOR:
setPos(scroll_pos - large_step);
break;
case KEY_END:
setPos(max_pos);
break;
case KEY_NEXT:
setPos(scroll_pos + large_step);
break;
default:
absorb = false;
}
if (scroll_pos != old_pos) {
SEvent e;
e.EventType = EET_GUI_EVENT;
e.GUIEvent.Caller = this;
e.GUIEvent.Element = nullptr;
e.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED;
Parent->OnEvent(e);
}
if (absorb)