@ -29,6 +29,7 @@
/*************************************************************************/
# include "editor_properties.h"
# include "editor/editor_resource_preview.h"
# include "editor_node.h"
# include "editor_properties_array_dict.h"
@ -925,6 +926,9 @@ void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) {
preset - > set_global_position ( easing_draw - > get_global_transform ( ) . xform ( mb - > get_position ( ) ) ) ;
preset - > popup ( ) ;
}
if ( mb . is_valid ( ) & & mb - > is_doubleclick ( ) & & mb - > get_button_index ( ) = = BUTTON_LEFT ) {
_setup_spin ( ) ;
}
Ref < InputEventMouseMotion > mm = p_ev ;
@ -963,7 +967,6 @@ void EditorPropertyEasing::_draw_easing() {
Size2 s = easing_draw - > get_size ( ) ;
Rect2 r ( Point2 ( ) , s ) ;
r = r . grow ( 3 ) ;
//get_stylebox("normal", "LineEdit")->draw(ci, r);
int points = 48 ;
@ -1006,6 +1009,31 @@ void EditorPropertyEasing::_set_preset(int p_preset) {
easing_draw - > update ( ) ;
}
void EditorPropertyEasing : : _setup_spin ( ) {
setting = true ;
spin - > setup_and_show ( ) ;
spin - > get_line_edit ( ) - > set_text ( rtos ( get_edited_object ( ) - > get ( get_edited_property ( ) ) ) ) ;
setting = false ;
spin - > show ( ) ;
}
void EditorPropertyEasing : : _spin_value_changed ( double p_value ) {
if ( setting )
return ;
// 0 is a singularity, but both positive and negative values
// are otherwise allowed. Enforce 0+ as workaround.
if ( Math : : is_zero_approx ( p_value ) ) {
p_value = 0.00001 ;
}
emit_changed ( get_edited_property ( ) , p_value ) ;
_spin_focus_exited ( ) ;
}
void EditorPropertyEasing : : _spin_focus_exited ( ) {
spin - > hide ( ) ;
}
void EditorPropertyEasing : : setup ( bool p_full , bool p_flip ) {
flip = p_flip ;
@ -1028,9 +1056,6 @@ void EditorPropertyEasing::_notification(int p_what) {
}
easing_draw - > set_custom_minimum_size ( Size2 ( 0 , get_font ( " font " , " Label " ) - > get_height ( ) * 2 ) ) ;
} break ;
case NOTIFICATION_RESIZED : {
} break ;
}
}
@ -1039,6 +1064,9 @@ void EditorPropertyEasing::_bind_methods() {
ClassDB : : bind_method ( " _draw_easing " , & EditorPropertyEasing : : _draw_easing ) ;
ClassDB : : bind_method ( " _drag_easing " , & EditorPropertyEasing : : _drag_easing ) ;
ClassDB : : bind_method ( " _set_preset " , & EditorPropertyEasing : : _set_preset ) ;
ClassDB : : bind_method ( " _spin_value_changed " , & EditorPropertyEasing : : _spin_value_changed ) ;
ClassDB : : bind_method ( " _spin_focus_exited " , & EditorPropertyEasing : : _spin_focus_exited ) ;
}
EditorPropertyEasing : : EditorPropertyEasing ( ) {
@ -1053,6 +1081,19 @@ EditorPropertyEasing::EditorPropertyEasing() {
add_child ( preset ) ;
preset - > connect ( " id_pressed " , this , " _set_preset " ) ;
spin = memnew ( EditorSpinSlider ) ;
spin - > set_flat ( true ) ;
spin - > set_min ( - 100 ) ;
spin - > set_max ( 100 ) ;
spin - > set_step ( 0 ) ;
spin - > set_hide_slider ( true ) ;
spin - > set_allow_lesser ( true ) ;
spin - > set_allow_greater ( true ) ;
spin - > connect ( " value_changed " , this , " _spin_value_changed " ) ;
spin - > get_line_edit ( ) - > connect ( " focus_exited " , this , " _spin_focus_exited " ) ;
spin - > hide ( ) ;
add_child ( spin ) ;
flip = false ;
full = false ;
}