editor_spin_slider.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. /*************************************************************************/
  2. /* editor_spin_slider.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "editor_spin_slider.h"
  31. #include "core/math/expression.h"
  32. #include "core/os/input.h"
  33. #include "core/os/keyboard.h"
  34. #include "editor_node.h"
  35. #include "editor_scale.h"
  36. String EditorSpinSlider::get_tooltip(const Point2 &p_pos) const {
  37. if (grabber->is_visible()) {
  38. #ifdef OSX_ENABLED
  39. const int key = KEY_META;
  40. #else
  41. const int key = KEY_CONTROL;
  42. #endif
  43. return rtos(get_value()) + "\n\n" + vformat(TTR("Hold %s to round to integers. Hold Shift for more precise changes."), find_keycode_name(key));
  44. }
  45. return rtos(get_value());
  46. }
  47. String EditorSpinSlider::get_text_value() const {
  48. return String::num(get_value(), Math::range_step_decimals(get_step()));
  49. }
  50. void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) {
  51. if (read_only) {
  52. return;
  53. }
  54. Ref<InputEventMouseButton> mb = p_event;
  55. if (mb.is_valid()) {
  56. if (mb->get_button_index() == BUTTON_LEFT) {
  57. if (mb->is_pressed()) {
  58. if (updown_offset != -1 && mb->get_position().x > updown_offset) {
  59. //there is an updown, so use it.
  60. if (mb->get_position().y < get_size().height / 2) {
  61. set_value(get_value() + get_step());
  62. } else {
  63. set_value(get_value() - get_step());
  64. }
  65. return;
  66. } else {
  67. grabbing_spinner_attempt = true;
  68. grabbing_spinner_dist_cache = 0;
  69. pre_grab_value = get_value();
  70. grabbing_spinner = false;
  71. grabbing_spinner_mouse_pos = Input::get_singleton()->get_mouse_position();
  72. }
  73. } else {
  74. if (grabbing_spinner_attempt) {
  75. if (grabbing_spinner) {
  76. Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
  77. Input::get_singleton()->warp_mouse_position(grabbing_spinner_mouse_pos);
  78. update();
  79. } else {
  80. _focus_entered();
  81. }
  82. grabbing_spinner = false;
  83. grabbing_spinner_attempt = false;
  84. }
  85. }
  86. } else if (mb->get_button_index() == BUTTON_WHEEL_UP || mb->get_button_index() == BUTTON_WHEEL_DOWN) {
  87. if (grabber->is_visible()) {
  88. call_deferred("update");
  89. }
  90. }
  91. }
  92. Ref<InputEventMouseMotion> mm = p_event;
  93. if (mm.is_valid()) {
  94. if (grabbing_spinner_attempt) {
  95. double diff_x = mm->get_relative().x;
  96. if (mm->get_shift() && grabbing_spinner) {
  97. diff_x *= 0.1;
  98. }
  99. grabbing_spinner_dist_cache += diff_x;
  100. if (!grabbing_spinner && ABS(grabbing_spinner_dist_cache) > 4 * EDSCALE) {
  101. Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
  102. grabbing_spinner = true;
  103. }
  104. if (grabbing_spinner) {
  105. // Don't make the user scroll all the way back to 'in range' if they went off the end.
  106. if (pre_grab_value < get_min() && !is_lesser_allowed()) {
  107. pre_grab_value = get_min();
  108. }
  109. if (pre_grab_value > get_max() && !is_greater_allowed()) {
  110. pre_grab_value = get_max();
  111. }
  112. if (mm->get_command()) {
  113. // If control was just pressed, don't make the value do a huge jump in magnitude.
  114. if (grabbing_spinner_dist_cache != 0) {
  115. pre_grab_value += grabbing_spinner_dist_cache * get_step();
  116. grabbing_spinner_dist_cache = 0;
  117. }
  118. set_value(Math::round(pre_grab_value + get_step() * grabbing_spinner_dist_cache * 10));
  119. } else {
  120. set_value(pre_grab_value + get_step() * grabbing_spinner_dist_cache);
  121. }
  122. }
  123. } else if (updown_offset != -1) {
  124. bool new_hover = (mm->get_position().x > updown_offset);
  125. if (new_hover != hover_updown) {
  126. hover_updown = new_hover;
  127. update();
  128. }
  129. }
  130. }
  131. Ref<InputEventKey> k = p_event;
  132. if (k.is_valid() && k->is_pressed() && k->is_action("ui_accept")) {
  133. _focus_entered();
  134. }
  135. }
  136. void EditorSpinSlider::_grabber_gui_input(const Ref<InputEvent> &p_event) {
  137. Ref<InputEventMouseButton> mb = p_event;
  138. if (grabbing_grabber) {
  139. if (mb.is_valid()) {
  140. if (mb->get_button_index() == BUTTON_WHEEL_UP) {
  141. set_value(get_value() + get_step());
  142. mousewheel_over_grabber = true;
  143. } else if (mb->get_button_index() == BUTTON_WHEEL_DOWN) {
  144. set_value(get_value() - get_step());
  145. mousewheel_over_grabber = true;
  146. }
  147. }
  148. }
  149. if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT) {
  150. if (mb->is_pressed()) {
  151. grabbing_grabber = true;
  152. if (!mousewheel_over_grabber) {
  153. grabbing_ratio = get_as_ratio();
  154. grabbing_from = grabber->get_transform().xform(mb->get_position()).x;
  155. }
  156. } else {
  157. grabbing_grabber = false;
  158. mousewheel_over_grabber = false;
  159. }
  160. }
  161. Ref<InputEventMouseMotion> mm = p_event;
  162. if (mm.is_valid() && grabbing_grabber) {
  163. if (mousewheel_over_grabber) {
  164. return;
  165. }
  166. float scale_x = get_global_transform_with_canvas().get_scale().x;
  167. ERR_FAIL_COND(Math::is_zero_approx(scale_x));
  168. float grabbing_ofs = (grabber->get_transform().xform(mm->get_position()).x - grabbing_from) / float(grabber_range) / scale_x;
  169. set_as_ratio(grabbing_ratio + grabbing_ofs);
  170. update();
  171. }
  172. }
  173. void EditorSpinSlider::_value_input_gui_input(const Ref<InputEvent> &p_event) {
  174. Ref<InputEventKey> k = p_event;
  175. if (k.is_valid() && k->is_pressed()) {
  176. double step = get_step();
  177. double real_step = step;
  178. if (step < 1) {
  179. double divisor = 1.0 / get_step();
  180. if (trunc(divisor) == divisor) {
  181. step = 1.0;
  182. }
  183. }
  184. #ifdef APPLE_STYLE_KEYS
  185. if (k->get_command()) {
  186. #else
  187. if (k->get_control()) {
  188. #endif
  189. step *= 100.0;
  190. } else if (k->get_shift()) {
  191. step *= 10.0;
  192. #ifdef APPLE_STYLE_KEYS
  193. } else if (k->get_metakey()) {
  194. #else
  195. } else if (k->get_alt()) {
  196. #endif
  197. step *= 0.1;
  198. }
  199. uint32_t code = k->get_scancode();
  200. switch (code) {
  201. case KEY_UP: {
  202. _evaluate_input_text();
  203. double last_value = get_value();
  204. set_value(last_value + step);
  205. double new_value = get_value();
  206. if (new_value < CLAMP(last_value + step, get_min(), get_max())) {
  207. set_value(last_value + real_step);
  208. }
  209. value_input->set_text(get_text_value());
  210. } break;
  211. case KEY_DOWN: {
  212. _evaluate_input_text();
  213. double last_value = get_value();
  214. set_value(last_value - step);
  215. double new_value = get_value();
  216. if (new_value > CLAMP(last_value - step, get_min(), get_max())) {
  217. set_value(last_value - real_step);
  218. }
  219. value_input->set_text(get_text_value());
  220. } break;
  221. }
  222. }
  223. }
  224. void EditorSpinSlider::_draw_spin_slider() {
  225. updown_offset = -1;
  226. Ref<StyleBox> sb = get_stylebox("normal", "LineEdit");
  227. if (!flat) {
  228. draw_style_box(sb, Rect2(Vector2(), get_size()));
  229. }
  230. Ref<Font> font = get_font("font", "LineEdit");
  231. int sep_base = 4 * EDSCALE;
  232. int sep = sep_base + sb->get_offset().x; //make it have the same margin on both sides, looks better
  233. int string_width = font->get_string_size(label).width;
  234. int number_width = get_size().width - sb->get_minimum_size().width - string_width - sep;
  235. Ref<Texture> updown = get_icon("updown", "SpinBox");
  236. if (get_step() == 1) {
  237. number_width -= updown->get_width();
  238. }
  239. String numstr = get_text_value();
  240. int vofs = (get_size().height - font->get_height()) / 2 + font->get_ascent();
  241. Color fc = get_color("font_color", "LineEdit");
  242. Color lc;
  243. if (use_custom_label_color) {
  244. lc = custom_label_color;
  245. } else {
  246. lc = fc;
  247. }
  248. if (flat && label != String()) {
  249. Color label_bg_color = get_color("dark_color_3", "Editor");
  250. draw_rect(Rect2(Vector2(), Vector2(sb->get_offset().x * 2 + string_width, get_size().height)), label_bg_color);
  251. }
  252. if (has_focus()) {
  253. Ref<StyleBox> focus = get_stylebox("focus", "LineEdit");
  254. draw_style_box(focus, Rect2(Vector2(), get_size()));
  255. }
  256. draw_string(font, Vector2(Math::round(sb->get_offset().x), vofs), label, lc * Color(1, 1, 1, 0.5));
  257. draw_string(font, Vector2(Math::round(sb->get_offset().x + string_width + sep), vofs), numstr, fc, number_width);
  258. if (get_step() == 1) {
  259. Ref<Texture> updown2 = get_icon("updown", "SpinBox");
  260. int updown_vofs = (get_size().height - updown2->get_height()) / 2;
  261. updown_offset = get_size().width - sb->get_margin(MARGIN_RIGHT) - updown2->get_width();
  262. Color c(1, 1, 1);
  263. if (hover_updown) {
  264. c *= Color(1.2, 1.2, 1.2);
  265. }
  266. draw_texture(updown2, Vector2(updown_offset, updown_vofs), c);
  267. if (grabber->is_visible()) {
  268. grabber->hide();
  269. }
  270. } else if (!hide_slider) {
  271. int grabber_w = 4 * EDSCALE;
  272. int width = get_size().width - sb->get_minimum_size().width - grabber_w;
  273. int ofs = sb->get_offset().x;
  274. int svofs = (get_size().height + vofs) / 2 - 1;
  275. Color c = fc;
  276. c.a = 0.2;
  277. draw_rect(Rect2(ofs, svofs + 1, width, 2 * EDSCALE), c);
  278. int gofs = get_as_ratio() * width;
  279. c.a = 0.9;
  280. Rect2 grabber_rect = Rect2(ofs + gofs, svofs + 1, grabber_w, 2 * EDSCALE);
  281. draw_rect(grabber_rect, c);
  282. bool display_grabber = (mouse_over_spin || mouse_over_grabber) && !grabbing_spinner && !value_input->is_visible();
  283. if (grabber->is_visible() != display_grabber) {
  284. if (display_grabber) {
  285. grabber->show();
  286. } else {
  287. grabber->hide();
  288. }
  289. }
  290. if (display_grabber) {
  291. Ref<Texture> grabber_tex;
  292. if (mouse_over_grabber) {
  293. grabber_tex = get_icon("grabber_highlight", "HSlider");
  294. } else {
  295. grabber_tex = get_icon("grabber", "HSlider");
  296. }
  297. if (grabber->get_texture() != grabber_tex) {
  298. grabber->set_texture(grabber_tex);
  299. }
  300. Vector2 scale = get_global_transform_with_canvas().get_scale();
  301. grabber->set_scale(scale);
  302. grabber->set_size(Size2(0, 0));
  303. grabber->set_position(get_global_position() + (grabber_rect.position + grabber_rect.size * 0.5 - grabber->get_size() * 0.5) * scale);
  304. if (mousewheel_over_grabber) {
  305. Input::get_singleton()->warp_mouse_position(grabber->get_position() + grabber_rect.size);
  306. }
  307. grabber_range = width;
  308. }
  309. }
  310. }
  311. void EditorSpinSlider::_notification(int p_what) {
  312. switch (p_what) {
  313. case NOTIFICATION_ENTER_TREE:
  314. case NOTIFICATION_THEME_CHANGED: {
  315. // Add a left margin to the stylebox to make the number align with the Label
  316. // when it's edited. The LineEdit "focus" stylebox uses the "normal" stylebox's
  317. // default margins.
  318. Ref<StyleBox> stylebox = get_stylebox("normal", "LineEdit")->duplicate();
  319. // EditorSpinSliders with a label have more space on the left, so add an
  320. // higher margin to match the location where the text begins.
  321. // The margin values below were determined by empirical testing.
  322. stylebox->set_default_margin(MARGIN_LEFT, (get_label() != String() ? 23 : 16) * EDSCALE);
  323. value_input->add_style_override("normal", stylebox);
  324. } break;
  325. case NOTIFICATION_DRAW:
  326. _draw_spin_slider();
  327. break;
  328. case MainLoop::NOTIFICATION_WM_FOCUS_IN:
  329. case MainLoop::NOTIFICATION_WM_FOCUS_OUT:
  330. case NOTIFICATION_EXIT_TREE:
  331. if (grabbing_spinner) {
  332. grabber->hide();
  333. Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
  334. grabbing_spinner = false;
  335. grabbing_spinner_attempt = false;
  336. }
  337. break;
  338. case NOTIFICATION_MOUSE_ENTER:
  339. mouse_over_spin = true;
  340. update();
  341. break;
  342. case NOTIFICATION_MOUSE_EXIT:
  343. mouse_over_spin = false;
  344. update();
  345. break;
  346. case NOTIFICATION_FOCUS_ENTER:
  347. /* Sorry, I don't like this, it makes navigating the different fields with arrows more difficult.
  348. * Just press enter to edit.
  349. * if (Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT) && !value_input_just_closed) {
  350. _focus_entered();
  351. }*/
  352. if ((Input::get_singleton()->is_action_pressed("ui_focus_next") || Input::get_singleton()->is_action_pressed("ui_focus_prev")) && !value_input_just_closed) {
  353. _focus_entered();
  354. }
  355. value_input_just_closed = false;
  356. break;
  357. }
  358. }
  359. Size2 EditorSpinSlider::get_minimum_size() const {
  360. Ref<StyleBox> sb = get_stylebox("normal", "LineEdit");
  361. Ref<Font> font = get_font("font", "LineEdit");
  362. Size2 ms = sb->get_minimum_size();
  363. ms.height += font->get_height();
  364. return ms;
  365. }
  366. void EditorSpinSlider::set_hide_slider(bool p_hide) {
  367. hide_slider = p_hide;
  368. update();
  369. }
  370. bool EditorSpinSlider::is_hiding_slider() const {
  371. return hide_slider;
  372. }
  373. void EditorSpinSlider::set_label(const String &p_label) {
  374. label = p_label;
  375. update();
  376. }
  377. String EditorSpinSlider::get_label() const {
  378. return label;
  379. }
  380. void EditorSpinSlider::_evaluate_input_text() {
  381. // Replace comma with dot to support it as decimal separator (GH-6028).
  382. // This prevents using functions like `pow()`, but using functions
  383. // in EditorSpinSlider is a barely known (and barely used) feature.
  384. // Instead, we'd rather support German/French keyboard layouts out of the box.
  385. const String text = value_input->get_text().replace(",", ".");
  386. Ref<Expression> expr;
  387. expr.instance();
  388. Error err = expr->parse(text);
  389. if (err != OK) {
  390. return;
  391. }
  392. Variant v = expr->execute(Array(), nullptr, false);
  393. if (v.get_type() == Variant::NIL) {
  394. return;
  395. }
  396. set_value(v);
  397. }
  398. //text_entered signal
  399. void EditorSpinSlider::_value_input_entered(const String &p_text) {
  400. value_input_just_closed = true;
  401. value_input->hide();
  402. }
  403. //modal_closed signal
  404. void EditorSpinSlider::_value_input_closed() {
  405. _evaluate_input_text();
  406. value_input_just_closed = true;
  407. }
  408. //focus_exited signal
  409. void EditorSpinSlider::_value_focus_exited() {
  410. // discontinue because the focus_exit was caused by right-click context menu
  411. if (value_input->get_menu()->is_visible()) {
  412. return;
  413. }
  414. _evaluate_input_text();
  415. // focus is not on the same element after the vlalue_input was exited
  416. // -> focus is on next element
  417. // -> TAB was pressed
  418. // -> modal_close was not called
  419. // -> need to close/hide manually
  420. if (!value_input_just_closed) { //value_input_just_closed should do the same
  421. value_input->hide();
  422. //tab was pressed
  423. } else {
  424. //enter, click, esc
  425. }
  426. }
  427. void EditorSpinSlider::_grabber_mouse_entered() {
  428. mouse_over_grabber = true;
  429. update();
  430. }
  431. void EditorSpinSlider::_grabber_mouse_exited() {
  432. mouse_over_grabber = false;
  433. update();
  434. }
  435. void EditorSpinSlider::set_read_only(bool p_enable) {
  436. read_only = p_enable;
  437. update();
  438. }
  439. bool EditorSpinSlider::is_read_only() const {
  440. return read_only;
  441. }
  442. void EditorSpinSlider::set_flat(bool p_enable) {
  443. flat = p_enable;
  444. update();
  445. }
  446. bool EditorSpinSlider::is_flat() const {
  447. return flat;
  448. }
  449. void EditorSpinSlider::set_custom_label_color(bool p_use_custom_label_color, Color p_custom_label_color) {
  450. use_custom_label_color = p_use_custom_label_color;
  451. custom_label_color = p_custom_label_color;
  452. }
  453. void EditorSpinSlider::_focus_entered() {
  454. Rect2 gr = get_global_rect();
  455. value_input->set_text(get_text_value());
  456. value_input->set_position(gr.position);
  457. value_input->set_size(gr.size);
  458. value_input->show_modal();
  459. value_input->select_all();
  460. value_input->call_deferred("grab_focus"); // deferred to avoid losing focus
  461. value_input->set_focus_next(find_next_valid_focus()->get_path());
  462. value_input->set_focus_previous(find_prev_valid_focus()->get_path());
  463. }
  464. void EditorSpinSlider::_bind_methods() {
  465. ClassDB::bind_method(D_METHOD("set_label", "label"), &EditorSpinSlider::set_label);
  466. ClassDB::bind_method(D_METHOD("get_label"), &EditorSpinSlider::get_label);
  467. ClassDB::bind_method(D_METHOD("set_read_only", "read_only"), &EditorSpinSlider::set_read_only);
  468. ClassDB::bind_method(D_METHOD("is_read_only"), &EditorSpinSlider::is_read_only);
  469. ClassDB::bind_method(D_METHOD("set_flat", "flat"), &EditorSpinSlider::set_flat);
  470. ClassDB::bind_method(D_METHOD("is_flat"), &EditorSpinSlider::is_flat);
  471. ClassDB::bind_method(D_METHOD("_gui_input"), &EditorSpinSlider::_gui_input);
  472. ClassDB::bind_method(D_METHOD("_value_input_gui_input", "event"), &EditorSpinSlider::_value_input_gui_input);
  473. ClassDB::bind_method(D_METHOD("_grabber_mouse_entered"), &EditorSpinSlider::_grabber_mouse_entered);
  474. ClassDB::bind_method(D_METHOD("_grabber_mouse_exited"), &EditorSpinSlider::_grabber_mouse_exited);
  475. ClassDB::bind_method(D_METHOD("_grabber_gui_input"), &EditorSpinSlider::_grabber_gui_input);
  476. ClassDB::bind_method(D_METHOD("_value_input_closed"), &EditorSpinSlider::_value_input_closed);
  477. ClassDB::bind_method(D_METHOD("_value_input_entered"), &EditorSpinSlider::_value_input_entered);
  478. ClassDB::bind_method(D_METHOD("_value_focus_exited"), &EditorSpinSlider::_value_focus_exited);
  479. ADD_PROPERTY(PropertyInfo(Variant::STRING, "label"), "set_label", "get_label");
  480. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "read_only"), "set_read_only", "is_read_only");
  481. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flat"), "set_flat", "is_flat");
  482. }
  483. EditorSpinSlider::EditorSpinSlider() {
  484. flat = false;
  485. grabbing_spinner_attempt = false;
  486. grabbing_spinner = false;
  487. grabbing_spinner_dist_cache = 0;
  488. pre_grab_value = 0;
  489. set_focus_mode(FOCUS_ALL);
  490. updown_offset = -1;
  491. hover_updown = false;
  492. grabber = memnew(TextureRect);
  493. add_child(grabber);
  494. grabber->hide();
  495. grabber->set_as_toplevel(true);
  496. grabber->set_mouse_filter(MOUSE_FILTER_STOP);
  497. grabber->connect("mouse_entered", this, "_grabber_mouse_entered");
  498. grabber->connect("mouse_exited", this, "_grabber_mouse_exited");
  499. grabber->connect("gui_input", this, "_grabber_gui_input");
  500. mouse_over_spin = false;
  501. mouse_over_grabber = false;
  502. mousewheel_over_grabber = false;
  503. grabbing_grabber = false;
  504. grabber_range = 1;
  505. value_input = memnew(LineEdit);
  506. add_child(value_input);
  507. value_input->set_as_toplevel(true);
  508. value_input->hide();
  509. value_input->connect("modal_closed", this, "_value_input_closed");
  510. value_input->connect("text_entered", this, "_value_input_entered");
  511. value_input->connect("focus_exited", this, "_value_focus_exited");
  512. value_input->connect("gui_input", this, "_value_input_gui_input");
  513. value_input_just_closed = false;
  514. hide_slider = false;
  515. read_only = false;
  516. use_custom_label_color = false;
  517. }