scroll_bar.cpp 19 KB

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