WidgetSlider.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. /*
  2. * This source file is part of libRocket, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://www.librocket.com
  5. *
  6. * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. *
  26. */
  27. #include "WidgetSlider.h"
  28. #include "../../Include/Rocket/Core.h"
  29. #include "../../Include/Rocket/Controls/ElementFormControl.h"
  30. #include "../Core/Clock.h"
  31. namespace Rocket {
  32. namespace Controls {
  33. static const float DEFAULT_REPEAT_DELAY = 0.5f;
  34. static const float DEFAULT_REPEAT_PERIOD = 0.1f;
  35. WidgetSlider::WidgetSlider(ElementFormControl* _parent)
  36. {
  37. parent = _parent;
  38. orientation = HORIZONTAL;
  39. track = NULL;
  40. bar = NULL;
  41. arrows[0] = NULL;
  42. arrows[1] = NULL;
  43. bar_position = 0;
  44. bar_drag_anchor = 0;
  45. arrow_timers[0] = -1;
  46. arrow_timers[1] = -1;
  47. last_update_time = 0;
  48. }
  49. WidgetSlider::~WidgetSlider()
  50. {
  51. if (bar != NULL)
  52. {
  53. parent->RemoveChild(bar);
  54. }
  55. if (track != NULL)
  56. {
  57. parent->RemoveChild(track);
  58. }
  59. using Core::EventId;
  60. parent->RemoveEventListener(EventId::Blur, this);
  61. parent->RemoveEventListener(EventId::Focus, this);
  62. parent->RemoveEventListener(EventId::Keydown, this, true);
  63. parent->RemoveEventListener(EventId::Mousedown, this);
  64. parent->RemoveEventListener(EventId::Mouseup, this);
  65. parent->RemoveEventListener(EventId::Mouseout, this);
  66. parent->RemoveEventListener(EventId::Drag, this);
  67. parent->RemoveEventListener(EventId::Dragstart, this);
  68. parent->RemoveEventListener(EventId::Dragend, this);
  69. for (int i = 0; i < 2; i++)
  70. {
  71. if (arrows[i] != NULL)
  72. {
  73. parent->RemoveChild(arrows[i]);
  74. }
  75. }
  76. }
  77. // Initialises the slider to a given orientation.
  78. bool WidgetSlider::Initialise()
  79. {
  80. Core::Property drag_property = Core::Property(Core::Style::Drag::Drag);
  81. parent->SetProperty(Core::PropertyId::Drag, drag_property);
  82. // Create all of our child elements as standard elements, and abort if we can't create them.
  83. track = Core::Factory::InstanceElement(parent, "*", "slidertrack", Rocket::Core::XMLAttributes());
  84. bar = Core::Factory::InstanceElement(parent, "*", "sliderbar", Rocket::Core::XMLAttributes());
  85. arrows[0] = Core::Factory::InstanceElement(parent, "*", "sliderarrowdec", Rocket::Core::XMLAttributes());
  86. arrows[1] = Core::Factory::InstanceElement(parent, "*", "sliderarrowinc", Rocket::Core::XMLAttributes());
  87. arrows[0]->SetProperty(Core::PropertyId::Drag, drag_property);
  88. arrows[1]->SetProperty(Core::PropertyId::Drag, drag_property);
  89. if (track == NULL ||
  90. bar == NULL ||
  91. arrows[0] == NULL ||
  92. arrows[1] == NULL)
  93. {
  94. if (track != NULL)
  95. track->RemoveReference();
  96. if (bar != NULL)
  97. bar->RemoveReference();
  98. if (arrows[0] != NULL)
  99. arrows[0]->RemoveReference();
  100. if (arrows[1] != NULL)
  101. arrows[1]->RemoveReference();
  102. return false;
  103. }
  104. // Add them as non-DOM elements.
  105. parent->AppendChild(track, false);
  106. parent->AppendChild(bar, false);
  107. parent->AppendChild(arrows[0], false);
  108. parent->AppendChild(arrows[1], false);
  109. // Remove the initial references on the elements.
  110. track->RemoveReference();
  111. bar->RemoveReference();
  112. arrows[0]->RemoveReference();
  113. arrows[1]->RemoveReference();
  114. // Attach the listeners
  115. // All listeners are attached to parent, ensuring that we don't get duplicate events when it bubbles from child to parent
  116. using Core::EventId;
  117. parent->AddEventListener(EventId::Blur, this);
  118. parent->AddEventListener(EventId::Focus, this);
  119. parent->AddEventListener(EventId::Keydown, this, true);
  120. parent->AddEventListener(EventId::Mousedown, this);
  121. parent->AddEventListener(EventId::Mouseup, this);
  122. parent->AddEventListener(EventId::Mouseout, this);
  123. parent->AddEventListener(EventId::Drag, this);
  124. parent->AddEventListener(EventId::Dragstart, this);
  125. parent->AddEventListener(EventId::Dragend, this);
  126. return true;
  127. }
  128. // Updates the key repeats for the increment / decrement arrows.
  129. void WidgetSlider::Update()
  130. {
  131. for (int i = 0; i < 2; i++)
  132. {
  133. bool updated_time = false;
  134. float delta_time = 0;
  135. if (arrow_timers[i] > 0)
  136. {
  137. if (!updated_time)
  138. {
  139. double current_time = Core::Clock::GetElapsedTime();
  140. delta_time = float(current_time - last_update_time);
  141. last_update_time = current_time;
  142. }
  143. arrow_timers[i] -= delta_time;
  144. while (arrow_timers[i] <= 0)
  145. {
  146. arrow_timers[i] += DEFAULT_REPEAT_PERIOD;
  147. SetBarPosition(i == 0 ? OnLineDecrement() : OnLineIncrement());
  148. }
  149. }
  150. }
  151. }
  152. // Sets the position of the bar.
  153. void WidgetSlider::SetBarPosition(float _bar_position)
  154. {
  155. bar_position = Rocket::Core::Math::Clamp(_bar_position, 0.0f, 1.0f);
  156. PositionBar();
  157. Rocket::Core::Dictionary parameters;
  158. parameters["value"] = bar_position;
  159. parent->DispatchEvent(Core::EventId::Change, parameters);
  160. }
  161. // Returns the current position of the bar.
  162. float WidgetSlider::GetBarPosition()
  163. {
  164. return bar_position;
  165. }
  166. // Sets the orientation of the slider.
  167. void WidgetSlider::SetOrientation(Orientation _orientation)
  168. {
  169. orientation = _orientation;
  170. }
  171. // Returns the slider's orientation.
  172. WidgetSlider::Orientation WidgetSlider::GetOrientation() const
  173. {
  174. return orientation;
  175. }
  176. // Sets the dimensions to the size of the slider.
  177. void WidgetSlider::GetDimensions(Rocket::Core::Vector2f& dimensions) const
  178. {
  179. switch (orientation)
  180. {
  181. case VERTICAL: dimensions.x = 16; dimensions.y = 256; break;
  182. case HORIZONTAL: dimensions.x = 256; dimensions.y = 16; break;
  183. }
  184. }
  185. // Lays out and resizes the internal elements.
  186. void WidgetSlider::FormatElements(const Rocket::Core::Vector2f& containing_block, float slider_length, float bar_length)
  187. {
  188. int length_axis = orientation == VERTICAL ? 1 : 0;
  189. // Build the box for the containing slider element. As the containing block is not guaranteed to have a defined
  190. // height, we must use the width for both axes.
  191. Core::Box parent_box;
  192. Core::ElementUtilities::BuildBox(parent_box, Rocket::Core::Vector2f(containing_block.x, containing_block.x), parent);
  193. // Set the length of the slider.
  194. Rocket::Core::Vector2f content = parent_box.GetSize();
  195. content[length_axis] = slider_length;
  196. parent_box.SetContent(content);
  197. // Generate the initial dimensions for the track. It'll need to be cut down to fit the arrows.
  198. Core::Box track_box;
  199. Core::ElementUtilities::BuildBox(track_box, parent_box.GetSize(), track);
  200. content = track_box.GetSize();
  201. content[length_axis] = slider_length -= orientation == VERTICAL ? (track_box.GetCumulativeEdge(Core::Box::CONTENT, Core::Box::TOP) + track_box.GetCumulativeEdge(Core::Box::CONTENT, Core::Box::BOTTOM)) :
  202. (track_box.GetCumulativeEdge(Core::Box::CONTENT, Core::Box::LEFT) + track_box.GetCumulativeEdge(Core::Box::CONTENT, Core::Box::RIGHT));
  203. // If no height has been explicitly specified for the track, it'll be initialised to -1 as per normal block
  204. // elements. We'll fix that up here.
  205. if (orientation == HORIZONTAL &&
  206. content.y < 0)
  207. content.y = parent_box.GetSize().y;
  208. // Now we size the arrows.
  209. for (int i = 0; i < 2; i++)
  210. {
  211. Core::Box arrow_box;
  212. Core::ElementUtilities::BuildBox(arrow_box, parent_box.GetSize(), arrows[i]);
  213. // Clamp the size to (0, 0).
  214. Rocket::Core::Vector2f arrow_size = arrow_box.GetSize();
  215. if (arrow_size.x < 0 ||
  216. arrow_size.y < 0)
  217. arrow_box.SetContent(Rocket::Core::Vector2f(0, 0));
  218. arrows[i]->SetBox(arrow_box);
  219. // Shrink the track length by the arrow size.
  220. content[length_axis] -= arrow_box.GetSize(Core::Box::MARGIN)[length_axis];
  221. }
  222. // Now the track has been sized, we can fix everything into position.
  223. track_box.SetContent(content);
  224. track->SetBox(track_box);
  225. if (orientation == VERTICAL)
  226. {
  227. Rocket::Core::Vector2f offset(arrows[0]->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::LEFT), arrows[0]->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::TOP));
  228. arrows[0]->SetOffset(offset, parent);
  229. offset.x = track->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::LEFT);
  230. offset.y += arrows[0]->GetBox().GetSize(Core::Box::BORDER).y + arrows[0]->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::BOTTOM) + track->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::TOP);
  231. track->SetOffset(offset, parent);
  232. offset.x = arrows[1]->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::LEFT);
  233. offset.y += track->GetBox().GetSize(Core::Box::BORDER).y + track->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::BOTTOM) + arrows[1]->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::TOP);
  234. arrows[1]->SetOffset(offset, parent);
  235. }
  236. else
  237. {
  238. Rocket::Core::Vector2f offset(arrows[0]->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::LEFT), arrows[0]->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::TOP));
  239. arrows[0]->SetOffset(offset, parent);
  240. offset.x += arrows[0]->GetBox().GetSize(Core::Box::BORDER).x + arrows[0]->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::RIGHT) + track->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::LEFT);
  241. offset.y = track->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::TOP);
  242. track->SetOffset(offset, parent);
  243. offset.x += track->GetBox().GetSize(Core::Box::BORDER).x + track->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::RIGHT) + arrows[1]->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::LEFT);
  244. offset.y = arrows[1]->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::TOP);
  245. arrows[1]->SetOffset(offset, parent);
  246. }
  247. FormatBar(bar_length);
  248. if (parent->IsDisabled())
  249. {
  250. // Propagate disabled state to child elements
  251. bar->SetPseudoClass("disabled", true);
  252. track->SetPseudoClass("disabled", true);
  253. arrows[0]->SetPseudoClass("disabled", true);
  254. arrows[1]->SetPseudoClass("disabled", true);
  255. }
  256. }
  257. // Lays out and positions the bar element.
  258. void WidgetSlider::FormatBar(float bar_length)
  259. {
  260. Core::Box bar_box;
  261. Core::ElementUtilities::BuildBox(bar_box, parent->GetBox().GetSize(), bar);
  262. auto& computed = bar->GetComputedValues();
  263. Rocket::Core::Vector2f bar_box_content = bar_box.GetSize();
  264. if (orientation == HORIZONTAL)
  265. {
  266. if (computed.height.value == Core::Style::Height::Auto)
  267. bar_box_content.y = parent->GetBox().GetSize().y;
  268. }
  269. if (bar_length >= 0)
  270. {
  271. Rocket::Core::Vector2f track_size = track->GetBox().GetSize();
  272. if (orientation == VERTICAL)
  273. {
  274. float track_length = track_size.y - (bar_box.GetCumulativeEdge(Core::Box::CONTENT, Core::Box::TOP) + bar_box.GetCumulativeEdge(Core::Box::CONTENT, Core::Box::BOTTOM));
  275. if (computed.height.value == Core::Style::Height::Auto)
  276. {
  277. bar_box_content.y = track_length * bar_length;
  278. // Check for 'min-height' restrictions.
  279. float min_track_length = Core::ResolveValue(computed.min_height, track_length);
  280. bar_box_content.y = Rocket::Core::Math::Max(min_track_length, bar_box_content.y);
  281. // Check for 'max-height' restrictions.
  282. float max_track_length = Core::ResolveValue(computed.max_height, track_length);
  283. if (max_track_length > 0)
  284. bar_box_content.y = Rocket::Core::Math::Min(max_track_length, bar_box_content.y);
  285. }
  286. // Make sure we haven't gone further than we're allowed to (min-height may have made us too big).
  287. bar_box_content.y = Rocket::Core::Math::Min(bar_box_content.y, track_length);
  288. }
  289. else
  290. {
  291. float track_length = track_size.x - (bar_box.GetCumulativeEdge(Core::Box::CONTENT, Core::Box::LEFT) + bar_box.GetCumulativeEdge(Core::Box::CONTENT, Core::Box::RIGHT));
  292. if (computed.width.value == Core::Style::Height::Auto)
  293. {
  294. bar_box_content.x = track_length * bar_length;
  295. // Check for 'min-width' restrictions.
  296. float min_track_length = Core::ResolveValue(computed.min_width, track_length);
  297. bar_box_content.x = Rocket::Core::Math::Max(min_track_length, bar_box_content.x);
  298. // Check for 'max-width' restrictions.
  299. float max_track_length = Core::ResolveValue(computed.max_width, track_length);
  300. if (max_track_length > 0)
  301. bar_box_content.x = Rocket::Core::Math::Min(max_track_length, bar_box_content.x);
  302. }
  303. // Make sure we haven't gone further than we're allowed to (min-width may have made us too big).
  304. bar_box_content.x = Rocket::Core::Math::Min(bar_box_content.x, track_length);
  305. }
  306. }
  307. // Set the new dimensions on the bar to re-decorate it.
  308. bar_box.SetContent(bar_box_content);
  309. bar->SetBox(bar_box);
  310. // Now that it's been resized, re-position it.
  311. PositionBar();
  312. }
  313. // Returns the widget's parent element.
  314. Core::Element* WidgetSlider::GetParent() const
  315. {
  316. return parent;
  317. }
  318. // Handles events coming through from the slider's components.
  319. void WidgetSlider::ProcessEvent(Core::Event& event)
  320. {
  321. if (parent->IsDisabled())
  322. return;
  323. using Rocket::Core::EventId;
  324. switch (event.GetId())
  325. {
  326. case EventId::Mousedown:
  327. {
  328. if (event.GetTargetElement() == parent || event.GetTargetElement() == track)
  329. {
  330. if (orientation == HORIZONTAL)
  331. {
  332. float mouse_position = event.GetParameter< float >("mouse_x", 0);
  333. float click_position = (mouse_position - track->GetAbsoluteOffset().x) / track->GetBox().GetSize().x;
  334. SetBarPosition(click_position <= bar_position ? OnPageDecrement(click_position) : OnPageIncrement(click_position));
  335. }
  336. else
  337. {
  338. float mouse_position = event.GetParameter< float >("mouse_y", 0);
  339. float click_position = (mouse_position - track->GetAbsoluteOffset().y) / track->GetBox().GetSize().y;
  340. SetBarPosition(click_position <= bar_position ? OnPageDecrement(click_position) : OnPageIncrement(click_position));
  341. }
  342. }
  343. else if (event.GetTargetElement() == arrows[0])
  344. {
  345. arrow_timers[0] = DEFAULT_REPEAT_DELAY;
  346. last_update_time = Core::Clock::GetElapsedTime();
  347. SetBarPosition(OnLineDecrement());
  348. }
  349. else if (event.GetTargetElement() == arrows[1])
  350. {
  351. arrow_timers[1] = DEFAULT_REPEAT_DELAY;
  352. last_update_time = Core::Clock::GetElapsedTime();
  353. SetBarPosition(OnLineIncrement());
  354. }
  355. }
  356. break;
  357. case EventId::Mouseup:
  358. case EventId::Mouseout:
  359. {
  360. if (event.GetTargetElement() == arrows[0])
  361. arrow_timers[0] = -1;
  362. else if (event.GetTargetElement() == arrows[1])
  363. arrow_timers[1] = -1;
  364. }
  365. break;
  366. case EventId::Dragstart:
  367. {
  368. if (event.GetTargetElement() == parent)
  369. {
  370. bar->SetPseudoClass("active", true);
  371. if (orientation == HORIZONTAL)
  372. bar_drag_anchor = event.GetParameter< int >("mouse_x", 0) - Rocket::Core::Math::RealToInteger(bar->GetAbsoluteOffset().x);
  373. else
  374. bar_drag_anchor = event.GetParameter< int >("mouse_y", 0) - Rocket::Core::Math::RealToInteger(bar->GetAbsoluteOffset().y);
  375. }
  376. }
  377. break;
  378. case EventId::Drag:
  379. {
  380. if (event.GetTargetElement() == parent)
  381. {
  382. if (orientation == HORIZONTAL)
  383. {
  384. float traversable_track_length = track->GetBox().GetSize(Core::Box::CONTENT).x - bar->GetBox().GetSize(Core::Box::CONTENT).x;
  385. if (traversable_track_length > 0)
  386. {
  387. float traversable_track_origin = track->GetAbsoluteOffset().x + bar_drag_anchor;
  388. float new_bar_position = (event.GetParameter< float >("mouse_x", 0) - traversable_track_origin) / traversable_track_length;
  389. new_bar_position = Rocket::Core::Math::Clamp(new_bar_position, 0.0f, 1.0f);
  390. SetBarPosition(OnBarChange(new_bar_position));
  391. }
  392. }
  393. else
  394. {
  395. float traversable_track_length = track->GetBox().GetSize(Core::Box::CONTENT).y - bar->GetBox().GetSize(Core::Box::CONTENT).y;
  396. if (traversable_track_length > 0)
  397. {
  398. float traversable_track_origin = track->GetAbsoluteOffset().y + bar_drag_anchor;
  399. float new_bar_position = (event.GetParameter< float >("mouse_y", 0) - traversable_track_origin) / traversable_track_length;
  400. new_bar_position = Rocket::Core::Math::Clamp(new_bar_position, 0.0f, 1.0f);
  401. SetBarPosition(OnBarChange(new_bar_position));
  402. }
  403. }
  404. }
  405. }
  406. break;
  407. case EventId::Dragend:
  408. {
  409. if (event.GetTargetElement() == parent)
  410. {
  411. bar->SetPseudoClass("active", false);
  412. }
  413. }
  414. break;
  415. case EventId::Keydown:
  416. {
  417. Core::Input::KeyIdentifier key_identifier = (Core::Input::KeyIdentifier) event.GetParameter< int >("key_identifier", 0);
  418. switch (key_identifier)
  419. {
  420. case Core::Input::KI_LEFT:
  421. if (orientation == HORIZONTAL) SetBarPosition(OnLineDecrement());
  422. break;
  423. case Core::Input::KI_UP:
  424. if (orientation == VERTICAL) SetBarPosition(OnLineDecrement());
  425. break;
  426. case Core::Input::KI_RIGHT:
  427. if (orientation == HORIZONTAL) SetBarPosition(OnLineIncrement());
  428. break;
  429. case Core::Input::KI_DOWN:
  430. if (orientation == VERTICAL) SetBarPosition(OnLineIncrement());
  431. break;
  432. default:
  433. break;
  434. }
  435. }
  436. break;
  437. case EventId::Focus:
  438. {
  439. if (event.GetTargetElement() == parent)
  440. bar->SetPseudoClass("focus", true);
  441. }
  442. break;
  443. case EventId::Blur:
  444. {
  445. if (event.GetTargetElement() == parent)
  446. bar->SetPseudoClass("focus", false);
  447. }
  448. break;
  449. default:
  450. break;
  451. }
  452. }
  453. void WidgetSlider::PositionBar()
  454. {
  455. const Rocket::Core::Vector2f& track_dimensions = track->GetBox().GetSize();
  456. const Rocket::Core::Vector2f& bar_dimensions = bar->GetBox().GetSize(Core::Box::BORDER);
  457. if (orientation == VERTICAL)
  458. {
  459. float traversable_track_length = track_dimensions.y - bar_dimensions.y;
  460. bar->SetOffset(Rocket::Core::Vector2f(bar->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::LEFT), track->GetRelativeOffset().y + traversable_track_length * bar_position), parent);
  461. }
  462. else
  463. {
  464. float traversable_track_length = track_dimensions.x - bar_dimensions.x;
  465. bar->SetOffset(Rocket::Core::Vector2f(track->GetRelativeOffset().x + traversable_track_length * bar_position, bar->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::TOP)), parent);
  466. }
  467. }
  468. }
  469. }