scroll_bar.cpp 18 KB

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