scroll_bar.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. /**************************************************************************/
  2. /* scroll_bar.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  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 "scroll_bar.h"
  31. #include "core/os/keyboard.h"
  32. #include "core/os/os.h"
  33. #include "core/string/print_string.h"
  34. #include "scene/main/window.h"
  35. bool ScrollBar::focus_by_default = false;
  36. void ScrollBar::set_can_focus_by_default(bool p_can_focus) {
  37. focus_by_default = p_can_focus;
  38. }
  39. void ScrollBar::gui_input(const Ref<InputEvent> &p_event) {
  40. ERR_FAIL_COND(p_event.is_null());
  41. Ref<InputEventMouseMotion> m = p_event;
  42. if (!m.is_valid() || drag.active) {
  43. emit_signal(SNAME("scrolling"));
  44. }
  45. Ref<InputEventMouseButton> b = p_event;
  46. if (b.is_valid()) {
  47. accept_event();
  48. if (b->get_button_index() == MouseButton::WHEEL_DOWN && b->is_pressed()) {
  49. set_value(get_value() + get_page() / 4.0);
  50. accept_event();
  51. }
  52. if (b->get_button_index() == MouseButton::WHEEL_UP && b->is_pressed()) {
  53. set_value(get_value() - get_page() / 4.0);
  54. accept_event();
  55. }
  56. if (b->get_button_index() != MouseButton::LEFT) {
  57. return;
  58. }
  59. if (b->is_pressed()) {
  60. double ofs = orientation == VERTICAL ? b->get_position().y : b->get_position().x;
  61. Ref<Texture2D> decr = theme_cache.decrement_icon;
  62. Ref<Texture2D> incr = theme_cache.increment_icon;
  63. double decr_size = orientation == VERTICAL ? decr->get_height() : decr->get_width();
  64. double incr_size = orientation == VERTICAL ? incr->get_height() : incr->get_width();
  65. double grabber_ofs = get_grabber_offset();
  66. double grabber_size = get_grabber_size();
  67. double total = orientation == VERTICAL ? get_size().height : get_size().width;
  68. if (ofs < decr_size) {
  69. decr_active = true;
  70. set_value(get_value() - (custom_step >= 0 ? custom_step : get_step()));
  71. queue_redraw();
  72. return;
  73. }
  74. if (ofs > total - incr_size) {
  75. incr_active = true;
  76. set_value(get_value() + (custom_step >= 0 ? custom_step : get_step()));
  77. queue_redraw();
  78. return;
  79. }
  80. ofs -= decr_size;
  81. if (ofs < grabber_ofs) {
  82. if (scrolling) {
  83. target_scroll = CLAMP(target_scroll - get_page(), get_min(), get_max() - get_page());
  84. } else {
  85. target_scroll = CLAMP(get_value() - get_page(), get_min(), get_max() - get_page());
  86. }
  87. if (smooth_scroll_enabled) {
  88. scrolling = true;
  89. set_physics_process_internal(true);
  90. } else {
  91. set_value(target_scroll);
  92. }
  93. return;
  94. }
  95. ofs -= grabber_ofs;
  96. if (ofs < grabber_size) {
  97. drag.active = true;
  98. drag.pos_at_click = grabber_ofs + ofs;
  99. drag.value_at_click = get_as_ratio();
  100. queue_redraw();
  101. } else {
  102. if (scrolling) {
  103. target_scroll = CLAMP(target_scroll + get_page(), get_min(), get_max() - get_page());
  104. } else {
  105. target_scroll = CLAMP(get_value() + get_page(), get_min(), get_max() - get_page());
  106. }
  107. if (smooth_scroll_enabled) {
  108. scrolling = true;
  109. set_physics_process_internal(true);
  110. } else {
  111. set_value(target_scroll);
  112. }
  113. }
  114. } else {
  115. incr_active = false;
  116. decr_active = false;
  117. drag.active = false;
  118. queue_redraw();
  119. }
  120. }
  121. if (m.is_valid()) {
  122. accept_event();
  123. if (drag.active) {
  124. double ofs = orientation == VERTICAL ? m->get_position().y : m->get_position().x;
  125. Ref<Texture2D> decr = theme_cache.decrement_icon;
  126. double decr_size = orientation == VERTICAL ? decr->get_height() : decr->get_width();
  127. ofs -= decr_size;
  128. double diff = (ofs - drag.pos_at_click) / get_area_size();
  129. set_as_ratio(drag.value_at_click + diff);
  130. } else {
  131. double ofs = orientation == VERTICAL ? m->get_position().y : m->get_position().x;
  132. Ref<Texture2D> decr = theme_cache.decrement_icon;
  133. Ref<Texture2D> incr = theme_cache.increment_icon;
  134. double decr_size = orientation == VERTICAL ? decr->get_height() : decr->get_width();
  135. double incr_size = orientation == VERTICAL ? incr->get_height() : incr->get_width();
  136. double total = orientation == VERTICAL ? get_size().height : get_size().width;
  137. HighlightStatus new_hilite;
  138. if (ofs < decr_size) {
  139. new_hilite = HIGHLIGHT_DECR;
  140. } else if (ofs > total - incr_size) {
  141. new_hilite = HIGHLIGHT_INCR;
  142. } else {
  143. new_hilite = HIGHLIGHT_RANGE;
  144. }
  145. if (new_hilite != highlight) {
  146. highlight = new_hilite;
  147. queue_redraw();
  148. }
  149. }
  150. }
  151. if (p_event->is_pressed()) {
  152. if (p_event->is_action("ui_left", true)) {
  153. if (orientation != HORIZONTAL) {
  154. return;
  155. }
  156. set_value(get_value() - (custom_step >= 0 ? custom_step : get_step()));
  157. } else if (p_event->is_action("ui_right", true)) {
  158. if (orientation != HORIZONTAL) {
  159. return;
  160. }
  161. set_value(get_value() + (custom_step >= 0 ? custom_step : get_step()));
  162. } else if (p_event->is_action("ui_up", true)) {
  163. if (orientation != VERTICAL) {
  164. return;
  165. }
  166. set_value(get_value() - (custom_step >= 0 ? custom_step : get_step()));
  167. } else if (p_event->is_action("ui_down", true)) {
  168. if (orientation != VERTICAL) {
  169. return;
  170. }
  171. set_value(get_value() + (custom_step >= 0 ? custom_step : get_step()));
  172. } else if (p_event->is_action("ui_home", true)) {
  173. set_value(get_min());
  174. } else if (p_event->is_action("ui_end", true)) {
  175. set_value(get_max());
  176. }
  177. }
  178. }
  179. void ScrollBar::_update_theme_item_cache() {
  180. Range::_update_theme_item_cache();
  181. theme_cache.scroll_style = get_theme_stylebox(SNAME("scroll"));
  182. theme_cache.scroll_focus_style = get_theme_stylebox(SNAME("scroll_focus"));
  183. theme_cache.scroll_offset_style = get_theme_stylebox(SNAME("hscroll"));
  184. theme_cache.grabber_style = get_theme_stylebox(SNAME("grabber"));
  185. theme_cache.grabber_hl_style = get_theme_stylebox(SNAME("grabber_highlight"));
  186. theme_cache.grabber_pressed_style = get_theme_stylebox(SNAME("grabber_pressed"));
  187. theme_cache.increment_icon = get_theme_icon(SNAME("increment"));
  188. theme_cache.increment_hl_icon = get_theme_icon(SNAME("increment_highlight"));
  189. theme_cache.increment_pressed_icon = get_theme_icon(SNAME("increment_pressed"));
  190. theme_cache.decrement_icon = get_theme_icon(SNAME("decrement"));
  191. theme_cache.decrement_hl_icon = get_theme_icon(SNAME("decrement_highlight"));
  192. theme_cache.decrement_pressed_icon = get_theme_icon(SNAME("decrement_pressed"));
  193. }
  194. void ScrollBar::_notification(int p_what) {
  195. switch (p_what) {
  196. case NOTIFICATION_DRAW: {
  197. RID ci = get_canvas_item();
  198. Ref<Texture2D> decr, incr;
  199. if (decr_active) {
  200. decr = theme_cache.decrement_pressed_icon;
  201. } else if (highlight == HIGHLIGHT_DECR) {
  202. decr = theme_cache.decrement_hl_icon;
  203. } else {
  204. decr = theme_cache.decrement_icon;
  205. }
  206. if (incr_active) {
  207. incr = theme_cache.increment_pressed_icon;
  208. } else if (highlight == HIGHLIGHT_INCR) {
  209. incr = theme_cache.increment_hl_icon;
  210. } else {
  211. incr = theme_cache.increment_icon;
  212. }
  213. Ref<StyleBox> bg = has_focus() ? theme_cache.scroll_focus_style : theme_cache.scroll_style;
  214. Ref<StyleBox> grabber;
  215. if (drag.active) {
  216. grabber = theme_cache.grabber_pressed_style;
  217. } else if (highlight == HIGHLIGHT_RANGE) {
  218. grabber = theme_cache.grabber_hl_style;
  219. } else {
  220. grabber = theme_cache.grabber_style;
  221. }
  222. Point2 ofs;
  223. decr->draw(ci, Point2());
  224. if (orientation == HORIZONTAL) {
  225. ofs.x += decr->get_width();
  226. } else {
  227. ofs.y += decr->get_height();
  228. }
  229. Size2 area = get_size();
  230. if (orientation == HORIZONTAL) {
  231. area.width -= incr->get_width() + decr->get_width();
  232. } else {
  233. area.height -= incr->get_height() + decr->get_height();
  234. }
  235. bg->draw(ci, Rect2(ofs, area));
  236. if (orientation == HORIZONTAL) {
  237. ofs.width += area.width;
  238. } else {
  239. ofs.height += area.height;
  240. }
  241. incr->draw(ci, ofs);
  242. Rect2 grabber_rect;
  243. if (orientation == HORIZONTAL) {
  244. grabber_rect.size.width = get_grabber_size();
  245. grabber_rect.size.height = get_size().height;
  246. grabber_rect.position.y = 0;
  247. grabber_rect.position.x = get_grabber_offset() + decr->get_width() + bg->get_margin(SIDE_LEFT);
  248. } else {
  249. grabber_rect.size.width = get_size().width;
  250. grabber_rect.size.height = get_grabber_size();
  251. grabber_rect.position.y = get_grabber_offset() + decr->get_height() + bg->get_margin(SIDE_TOP);
  252. grabber_rect.position.x = 0;
  253. }
  254. grabber->draw(ci, grabber_rect);
  255. } break;
  256. case NOTIFICATION_ENTER_TREE: {
  257. if (has_node(drag_node_path)) {
  258. Node *n = get_node(drag_node_path);
  259. drag_node = Object::cast_to<Control>(n);
  260. }
  261. if (drag_node) {
  262. drag_node->connect("gui_input", callable_mp(this, &ScrollBar::_drag_node_input));
  263. drag_node->connect("tree_exiting", callable_mp(this, &ScrollBar::_drag_node_exit), CONNECT_ONE_SHOT);
  264. }
  265. } break;
  266. case NOTIFICATION_EXIT_TREE: {
  267. if (drag_node) {
  268. drag_node->disconnect("gui_input", callable_mp(this, &ScrollBar::_drag_node_input));
  269. drag_node->disconnect("tree_exiting", callable_mp(this, &ScrollBar::_drag_node_exit));
  270. }
  271. drag_node = nullptr;
  272. } break;
  273. case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
  274. if (scrolling) {
  275. if (get_value() != target_scroll) {
  276. double target = target_scroll - get_value();
  277. double dist = abs(target);
  278. double vel = ((target / dist) * 500) * get_physics_process_delta_time();
  279. if (Math::abs(vel) >= dist) {
  280. set_value(target_scroll);
  281. scrolling = false;
  282. set_physics_process_internal(false);
  283. } else {
  284. set_value(get_value() + vel);
  285. }
  286. } else {
  287. scrolling = false;
  288. set_physics_process_internal(false);
  289. }
  290. } else if (drag_node_touching) {
  291. if (drag_node_touching_deaccel) {
  292. Vector2 pos = Vector2(orientation == HORIZONTAL ? get_value() : 0, orientation == VERTICAL ? get_value() : 0);
  293. pos += drag_node_speed * get_physics_process_delta_time();
  294. bool turnoff = false;
  295. if (orientation == HORIZONTAL) {
  296. if (pos.x < 0) {
  297. pos.x = 0;
  298. turnoff = true;
  299. }
  300. if (pos.x > (get_max() - get_page())) {
  301. pos.x = get_max() - get_page();
  302. turnoff = true;
  303. }
  304. set_value(pos.x);
  305. float sgn_x = drag_node_speed.x < 0 ? -1 : 1;
  306. float val_x = Math::abs(drag_node_speed.x);
  307. val_x -= 1000 * get_physics_process_delta_time();
  308. if (val_x < 0) {
  309. turnoff = true;
  310. }
  311. drag_node_speed.x = sgn_x * val_x;
  312. } else {
  313. if (pos.y < 0) {
  314. pos.y = 0;
  315. turnoff = true;
  316. }
  317. if (pos.y > (get_max() - get_page())) {
  318. pos.y = get_max() - get_page();
  319. turnoff = true;
  320. }
  321. set_value(pos.y);
  322. float sgn_y = drag_node_speed.y < 0 ? -1 : 1;
  323. float val_y = Math::abs(drag_node_speed.y);
  324. val_y -= 1000 * get_physics_process_delta_time();
  325. if (val_y < 0) {
  326. turnoff = true;
  327. }
  328. drag_node_speed.y = sgn_y * val_y;
  329. }
  330. if (turnoff) {
  331. set_physics_process_internal(false);
  332. drag_node_touching = false;
  333. drag_node_touching_deaccel = false;
  334. }
  335. } else {
  336. if (time_since_motion == 0 || time_since_motion > 0.1) {
  337. Vector2 diff = drag_node_accum - last_drag_node_accum;
  338. last_drag_node_accum = drag_node_accum;
  339. drag_node_speed = diff / get_physics_process_delta_time();
  340. }
  341. time_since_motion += get_physics_process_delta_time();
  342. }
  343. }
  344. } break;
  345. case NOTIFICATION_MOUSE_EXIT: {
  346. highlight = HIGHLIGHT_NONE;
  347. queue_redraw();
  348. } break;
  349. }
  350. }
  351. double ScrollBar::get_grabber_min_size() const {
  352. Ref<StyleBox> grabber = theme_cache.grabber_style;
  353. Size2 gminsize = grabber->get_minimum_size();
  354. return (orientation == VERTICAL) ? gminsize.height : gminsize.width;
  355. }
  356. double ScrollBar::get_grabber_size() const {
  357. float range = get_max() - get_min();
  358. if (range <= 0) {
  359. return 0;
  360. }
  361. float page = (get_page() > 0) ? get_page() : 0;
  362. double area_size = get_area_size();
  363. double grabber_size = page / range * area_size;
  364. return grabber_size + get_grabber_min_size();
  365. }
  366. double ScrollBar::get_area_size() const {
  367. switch (orientation) {
  368. case VERTICAL: {
  369. double area = get_size().height;
  370. area -= theme_cache.scroll_style->get_minimum_size().height;
  371. area -= theme_cache.increment_icon->get_height();
  372. area -= theme_cache.decrement_icon->get_height();
  373. area -= get_grabber_min_size();
  374. return area;
  375. } break;
  376. case HORIZONTAL: {
  377. double area = get_size().width;
  378. area -= theme_cache.scroll_style->get_minimum_size().width;
  379. area -= theme_cache.increment_icon->get_width();
  380. area -= theme_cache.decrement_icon->get_width();
  381. area -= get_grabber_min_size();
  382. return area;
  383. } break;
  384. default: {
  385. return 0.0;
  386. }
  387. }
  388. }
  389. double ScrollBar::get_area_offset() const {
  390. double ofs = 0.0;
  391. if (orientation == VERTICAL) {
  392. ofs += theme_cache.scroll_offset_style->get_margin(SIDE_TOP);
  393. ofs += theme_cache.decrement_icon->get_height();
  394. }
  395. if (orientation == HORIZONTAL) {
  396. ofs += theme_cache.scroll_offset_style->get_margin(SIDE_LEFT);
  397. ofs += theme_cache.decrement_icon->get_width();
  398. }
  399. return ofs;
  400. }
  401. double ScrollBar::get_grabber_offset() const {
  402. return (get_area_size()) * get_as_ratio();
  403. }
  404. Size2 ScrollBar::get_minimum_size() const {
  405. Ref<Texture2D> incr = theme_cache.increment_icon;
  406. Ref<Texture2D> decr = theme_cache.decrement_icon;
  407. Ref<StyleBox> bg = theme_cache.scroll_style;
  408. Size2 minsize;
  409. if (orientation == VERTICAL) {
  410. minsize.width = MAX(incr->get_size().width, bg->get_minimum_size().width);
  411. minsize.height += incr->get_size().height;
  412. minsize.height += decr->get_size().height;
  413. minsize.height += bg->get_minimum_size().height;
  414. minsize.height += get_grabber_min_size();
  415. }
  416. if (orientation == HORIZONTAL) {
  417. minsize.height = MAX(incr->get_size().height, bg->get_minimum_size().height);
  418. minsize.width += incr->get_size().width;
  419. minsize.width += decr->get_size().width;
  420. minsize.width += bg->get_minimum_size().width;
  421. minsize.width += get_grabber_min_size();
  422. }
  423. return minsize;
  424. }
  425. void ScrollBar::set_custom_step(float p_custom_step) {
  426. custom_step = p_custom_step;
  427. }
  428. float ScrollBar::get_custom_step() const {
  429. return custom_step;
  430. }
  431. void ScrollBar::_drag_node_exit() {
  432. if (drag_node) {
  433. drag_node->disconnect("gui_input", callable_mp(this, &ScrollBar::_drag_node_input));
  434. }
  435. drag_node = nullptr;
  436. }
  437. void ScrollBar::_drag_node_input(const Ref<InputEvent> &p_input) {
  438. if (!drag_node_enabled) {
  439. return;
  440. }
  441. Ref<InputEventMouseButton> mb = p_input;
  442. if (mb.is_valid()) {
  443. if (mb->get_button_index() != MouseButton::LEFT) {
  444. return;
  445. }
  446. if (mb->is_pressed()) {
  447. drag_node_speed = Vector2();
  448. drag_node_accum = Vector2();
  449. last_drag_node_accum = Vector2();
  450. drag_node_from = Vector2(orientation == HORIZONTAL ? get_value() : 0, orientation == VERTICAL ? get_value() : 0);
  451. drag_node_touching = DisplayServer::get_singleton()->is_touchscreen_available();
  452. drag_node_touching_deaccel = false;
  453. time_since_motion = 0;
  454. if (drag_node_touching) {
  455. set_physics_process_internal(true);
  456. time_since_motion = 0;
  457. }
  458. } else {
  459. if (drag_node_touching) {
  460. if (drag_node_speed == Vector2()) {
  461. drag_node_touching_deaccel = false;
  462. drag_node_touching = false;
  463. set_physics_process_internal(false);
  464. } else {
  465. drag_node_touching_deaccel = true;
  466. }
  467. }
  468. }
  469. }
  470. Ref<InputEventMouseMotion> mm = p_input;
  471. if (mm.is_valid()) {
  472. if (drag_node_touching && !drag_node_touching_deaccel) {
  473. Vector2 motion = mm->get_relative();
  474. drag_node_accum -= motion;
  475. Vector2 diff = drag_node_from + drag_node_accum;
  476. if (orientation == HORIZONTAL) {
  477. set_value(diff.x);
  478. }
  479. if (orientation == VERTICAL) {
  480. set_value(diff.y);
  481. }
  482. time_since_motion = 0;
  483. }
  484. }
  485. }
  486. void ScrollBar::set_drag_node(const NodePath &p_path) {
  487. if (is_inside_tree()) {
  488. if (drag_node) {
  489. drag_node->disconnect("gui_input", callable_mp(this, &ScrollBar::_drag_node_input));
  490. drag_node->disconnect("tree_exiting", callable_mp(this, &ScrollBar::_drag_node_exit));
  491. }
  492. }
  493. drag_node = nullptr;
  494. drag_node_path = p_path;
  495. if (is_inside_tree()) {
  496. if (has_node(p_path)) {
  497. Node *n = get_node(p_path);
  498. drag_node = Object::cast_to<Control>(n);
  499. }
  500. if (drag_node) {
  501. drag_node->connect("gui_input", callable_mp(this, &ScrollBar::_drag_node_input));
  502. drag_node->connect("tree_exiting", callable_mp(this, &ScrollBar::_drag_node_exit), CONNECT_ONE_SHOT);
  503. }
  504. }
  505. }
  506. NodePath ScrollBar::get_drag_node() const {
  507. return drag_node_path;
  508. }
  509. void ScrollBar::set_drag_node_enabled(bool p_enable) {
  510. drag_node_enabled = p_enable;
  511. }
  512. void ScrollBar::set_smooth_scroll_enabled(bool p_enable) {
  513. smooth_scroll_enabled = p_enable;
  514. }
  515. bool ScrollBar::is_smooth_scroll_enabled() const {
  516. return smooth_scroll_enabled;
  517. }
  518. void ScrollBar::_bind_methods() {
  519. ClassDB::bind_method(D_METHOD("set_custom_step", "step"), &ScrollBar::set_custom_step);
  520. ClassDB::bind_method(D_METHOD("get_custom_step"), &ScrollBar::get_custom_step);
  521. ADD_SIGNAL(MethodInfo("scrolling"));
  522. ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "custom_step", PROPERTY_HINT_RANGE, "-1,4096,suffix:px"), "set_custom_step", "get_custom_step");
  523. }
  524. ScrollBar::ScrollBar(Orientation p_orientation) {
  525. orientation = p_orientation;
  526. if (focus_by_default) {
  527. set_focus_mode(FOCUS_ALL);
  528. }
  529. set_step(0);
  530. }
  531. ScrollBar::~ScrollBar() {
  532. }