mirror of
https://github.com/minetest/minetest.git
synced 2024-12-23 14:42:24 +01:00
Add setting to disable smooth scrolling
This commit is contained in:
parent
e6f77b95f3
commit
0fb67ccb34
@ -694,6 +694,9 @@ language (Language) enum ,be,bg,ca,cs,da,de,el,en,eo,es,et,eu,fi,fr,gd,gl,hu,i
|
|||||||
# edge pixels when images are scaled by non-integer sizes.
|
# edge pixels when images are scaled by non-integer sizes.
|
||||||
gui_scaling (GUI scaling) float 1.0 0.5 20
|
gui_scaling (GUI scaling) float 1.0 0.5 20
|
||||||
|
|
||||||
|
# Enables smooth scrolling.
|
||||||
|
smooth_scrolling (Smooth scrolling) bool true
|
||||||
|
|
||||||
# Enables animation of inventory items.
|
# Enables animation of inventory items.
|
||||||
inventory_items_animations (Inventory items animations) bool false
|
inventory_items_animations (Inventory items animations) bool false
|
||||||
|
|
||||||
|
@ -299,6 +299,7 @@ void set_default_settings()
|
|||||||
settings->setDefault("gui_scaling", "1.0");
|
settings->setDefault("gui_scaling", "1.0");
|
||||||
settings->setDefault("gui_scaling_filter", "false");
|
settings->setDefault("gui_scaling_filter", "false");
|
||||||
settings->setDefault("gui_scaling_filter_txr2img", "true");
|
settings->setDefault("gui_scaling_filter_txr2img", "true");
|
||||||
|
settings->setDefault("smooth_scrolling", "true");
|
||||||
settings->setDefault("desynchronize_mapblock_texture_animation", "false");
|
settings->setDefault("desynchronize_mapblock_texture_animation", "false");
|
||||||
settings->setDefault("hud_hotbar_max_width", "1.0");
|
settings->setDefault("hud_hotbar_max_width", "1.0");
|
||||||
settings->setDefault("enable_local_map_saving", "false");
|
settings->setDefault("enable_local_map_saving", "false");
|
||||||
|
@ -13,6 +13,7 @@ the arrow buttons where there is insufficient space.
|
|||||||
#include "guiScrollBar.h"
|
#include "guiScrollBar.h"
|
||||||
#include "guiButton.h"
|
#include "guiButton.h"
|
||||||
#include "porting.h"
|
#include "porting.h"
|
||||||
|
#include "settings.h"
|
||||||
#include <IGUISkin.h>
|
#include <IGUISkin.h>
|
||||||
|
|
||||||
GUIScrollBar::GUIScrollBar(IGUIEnvironment *environment, IGUIElement *parent, s32 id,
|
GUIScrollBar::GUIScrollBar(IGUIEnvironment *environment, IGUIElement *parent, s32 id,
|
||||||
@ -101,19 +102,9 @@ bool GUIScrollBar::OnEvent(const SEvent &event)
|
|||||||
tray_clicked = !dragged_by_slider;
|
tray_clicked = !dragged_by_slider;
|
||||||
if (tray_clicked) {
|
if (tray_clicked) {
|
||||||
const s32 new_pos = getPosFromMousePos(p);
|
const s32 new_pos = getPosFromMousePos(p);
|
||||||
const s32 old_pos = scroll_pos;
|
setPosAndSend(new_pos);
|
||||||
setPos(new_pos);
|
|
||||||
// drag in the middle
|
// drag in the middle
|
||||||
drag_offset = thumb_size / 2;
|
drag_offset = thumb_size / 2;
|
||||||
// report the scroll event
|
|
||||||
if (scroll_pos != old_pos && Parent) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Environment->setFocus(this);
|
Environment->setFocus(this);
|
||||||
return true;
|
return true;
|
||||||
@ -147,18 +138,8 @@ bool GUIScrollBar::OnEvent(const SEvent &event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const s32 new_pos = getPosFromMousePos(p);
|
const s32 new_pos = getPosFromMousePos(p);
|
||||||
const s32 old_pos = scroll_pos;
|
setPosAndSend(new_pos);
|
||||||
|
|
||||||
setPos(new_pos);
|
|
||||||
|
|
||||||
if (scroll_pos != old_pos && Parent) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
return is_inside;
|
return is_inside;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -300,8 +281,27 @@ void GUIScrollBar::setPos(const s32 &pos)
|
|||||||
target_pos = std::nullopt;
|
target_pos = std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUIScrollBar::setPosAndSend(const s32 &pos)
|
||||||
|
{
|
||||||
|
const s32 old_pos = scroll_pos;
|
||||||
|
setPos(pos);
|
||||||
|
if (scroll_pos != old_pos && Parent) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GUIScrollBar::setPosInterpolated(const s32 &pos)
|
void GUIScrollBar::setPosInterpolated(const s32 &pos)
|
||||||
{
|
{
|
||||||
|
if (!g_settings->getBool("smooth_scrolling")) {
|
||||||
|
setPosAndSend(pos);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
s32 clamped = core::s32_clamp(pos, min_pos, max_pos);
|
s32 clamped = core::s32_clamp(pos, min_pos, max_pos);
|
||||||
if (scroll_pos != clamped) {
|
if (scroll_pos != clamped) {
|
||||||
target_pos = clamped;
|
target_pos = clamped;
|
||||||
|
@ -53,6 +53,8 @@ public:
|
|||||||
//! Sets a position immediately, aborting any ongoing interpolation.
|
//! Sets a position immediately, aborting any ongoing interpolation.
|
||||||
// setPos does not send EGET_SCROLL_BAR_CHANGED events for you.
|
// setPos does not send EGET_SCROLL_BAR_CHANGED events for you.
|
||||||
void setPos(const s32 &pos);
|
void setPos(const s32 &pos);
|
||||||
|
//! The same as setPos, but it takes care of sending EGET_SCROLL_BAR_CHANGED events.
|
||||||
|
void setPosAndSend(const s32 &pos);
|
||||||
//! Sets a target position for interpolation.
|
//! Sets a target position for interpolation.
|
||||||
// If you want to do an interpolated addition, use
|
// If you want to do an interpolated addition, use
|
||||||
// setPosInterpolated(getTargetPos() + x).
|
// setPosInterpolated(getTargetPos() + x).
|
||||||
|
Loading…
Reference in New Issue
Block a user