You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-24 15:26:15 +00:00
Fix Slider's drag mouse position when grabber is centered
(cherry picked from commit e6a42e3fc5)
This commit is contained in:
committed by
Rémi Verschelde
parent
fb63404aad
commit
f90d6dffed
@@ -65,8 +65,8 @@ void Slider::gui_input(const Ref<InputEvent> &p_event) {
|
|||||||
|
|
||||||
grab.pos = orientation == VERTICAL ? mb->get_position().y : mb->get_position().x;
|
grab.pos = orientation == VERTICAL ? mb->get_position().y : mb->get_position().x;
|
||||||
|
|
||||||
double grab_width = (double)grabber->get_width();
|
double grab_width = theme_cache.center_grabber ? 0.0 : (double)grabber->get_width();
|
||||||
double grab_height = (double)grabber->get_height();
|
double grab_height = theme_cache.center_grabber ? 0.0 : (double)grabber->get_height();
|
||||||
double max = orientation == VERTICAL ? get_size().height - grab_height : get_size().width - grab_width;
|
double max = orientation == VERTICAL ? get_size().height - grab_height : get_size().width - grab_width;
|
||||||
set_block_signals(true);
|
set_block_signals(true);
|
||||||
if (orientation == VERTICAL) {
|
if (orientation == VERTICAL) {
|
||||||
@@ -106,12 +106,14 @@ void Slider::gui_input(const Ref<InputEvent> &p_event) {
|
|||||||
if (mm.is_valid()) {
|
if (mm.is_valid()) {
|
||||||
if (grab.active) {
|
if (grab.active) {
|
||||||
Size2i size = get_size();
|
Size2i size = get_size();
|
||||||
Ref<Texture2D> grabber = theme_cache.grabber_icon;
|
Ref<Texture2D> grabber = theme_cache.grabber_hl_icon;
|
||||||
|
double grab_width = theme_cache.center_grabber ? 0.0 : (double)grabber->get_width();
|
||||||
|
double grab_height = theme_cache.center_grabber ? 0.0 : (double)grabber->get_height();
|
||||||
double motion = (orientation == VERTICAL ? mm->get_position().y : mm->get_position().x) - grab.pos;
|
double motion = (orientation == VERTICAL ? mm->get_position().y : mm->get_position().x) - grab.pos;
|
||||||
if (orientation == VERTICAL) {
|
if (orientation == VERTICAL) {
|
||||||
motion = -motion;
|
motion = -motion;
|
||||||
}
|
}
|
||||||
double areasize = orientation == VERTICAL ? size.height - grabber->get_height() : size.width - grabber->get_width();
|
double areasize = orientation == VERTICAL ? size.height - grab_height : size.width - grab_width;
|
||||||
if (areasize <= 0) {
|
if (areasize <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user