From 394276c45f4e1b256d6450a3ae7341368ace5fca Mon Sep 17 00:00:00 2001 From: krzycho Date: Thu, 11 Jun 2015 04:36:11 +0200 Subject: ColorRamp new features: - hold alt and left-click to duplicate color - hold shift while grabbing color node to snap selected one to the nearest one if close enough --- scene/gui/color_ramp_edit.cpp | 52 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'scene/gui') diff --git a/scene/gui/color_ramp_edit.cpp b/scene/gui/color_ramp_edit.cpp index 382c0dc103..c39893ac97 100644 --- a/scene/gui/color_ramp_edit.cpp +++ b/scene/gui/color_ramp_edit.cpp @@ -73,6 +73,31 @@ void ColorRampEdit::_input_event(const InputEvent& p_event) { } } + //Hold alt key to duplicate selected color + if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==1 && p_event.mouse_button.pressed && p_event.key.mod.alt ) { + + int x = p_event.mouse_button.x; + grabbed=_get_point_from_pos(x); + + if( grabbed != -1 ) { + int total_w = get_size().width-get_size().height-3; + ColorRamp::Point newPoint = points[grabbed]; + newPoint.offset=CLAMP(x/float(total_w),0,1); + + points.push_back(newPoint); + points.sort(); + for(int i=0;i