Spinning Topp Logo BlackTopp Studios
inc
horizontalscrollbar.cpp
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _uihorizontalscrollbar_cpp
41 #define _uihorizontalscrollbar_cpp
42 
43 #include "UI/horizontalscrollbar.h"
44 #include "UI/button.h"
45 #include "UI/screen.h"
46 #include "UI/pagedcontainer.h"
47 #include "UI/uimanager.h"
48 
49 #include "UI/horizontallayoutstrategy.h"
50 
51 #include "stringtool.h"
52 #include "MathTools/mathtools.h"
53 #include "Input/metacode.h"
54 
55 #include <algorithm>
56 
57 namespace Mezzanine
58 {
59  namespace UI
60  {
61  ///////////////////////////////////////////////////////////////////////////////
62  // HorizontalScrollbar Methods
63  ///////////////////////////////////////
64 
65  const String HorizontalScrollbar::TypeName = "HorizontalScrollbar";
66 
68  Scrollbar(Parent)
69  { }
70 
72  Scrollbar(RendName,Parent)
73  { this->ConstructHorizontalScrollbar(Style); }
74 
75  HorizontalScrollbar::HorizontalScrollbar(const String& RendName, const UnifiedRect& RendRect, const UI::ScrollbarStyle& Style, Screen* Parent) :
76  Scrollbar(RendName,RendRect,Parent)
77  { this->ConstructHorizontalScrollbar(Style); }
78 
80  Scrollbar(Parent)
81  { this->ProtoDeSerialize(XMLNode); }
82 
84  {
85  if( this->Container != NULL ) {
86  this->Container->UnbindProvider(this);
87  }
88 
89  this->RemoveChild( this->Scroller );
90  this->ParentScreen->DestroyWidget( this->Scroller );
91  this->RemoveChild( this->ScrollBack );
92  this->ParentScreen->DestroyWidget( this->ScrollBack );
93  this->RemoveChild( this->UpLeftButton );
94  this->ParentScreen->DestroyWidget( this->UpLeftButton );
95  this->RemoveChild( this->DownRightButton );
97  }
98 
100  {
101  // Create the rects we'll use
102  UnifiedVec2 ChildPosition(0,0,0,0);
103  UnifiedVec2 ChildSize(1,1,0,0);
104  UnifiedRect ChildRect(ChildPosition,ChildSize);
105  if( UI::SB_NoButtons == ScrollStyle )
106  {
107  // Create our objects
108  this->ScrollBack = ParentScreen->CreateButton(this->Name+".ScrollBack",ChildRect);
111  this->AddChild(this->ScrollBack,0);
112 
113  this->Scroller = ParentScreen->CreateButton(this->Name+".Scroller",ChildRect);
114  this->Scroller->SetManualTransformUpdates(true);
115  this->AddChild(this->Scroller,1);
116  }else{
117  //Get the position for all items involved and configure their offsets
118  if(UI::SB_Separate == ScrollStyle)
119  {
120  // Create our objects
121  this->UpLeftButton = ParentScreen->CreateButton(this->Name+".LeftButton",ChildRect);
125  this->AddChild(this->UpLeftButton,0);
126 
127  this->ScrollBack = ParentScreen->CreateButton(this->Name+".ScrollBack",ChildRect);
130  this->AddChild(this->ScrollBack,1);
131 
132  this->DownRightButton = ParentScreen->CreateButton(this->Name+".RightButton",ChildRect);
136  this->AddChild(this->DownRightButton,2);
137 
138  this->Scroller = ParentScreen->CreateButton(this->Name+".Scroller",ChildRect);
139  this->Scroller->SetManualTransformUpdates(true);
140  this->AddChild(this->Scroller,3);
141  }
142  else if(UI::SB_TogetherDownRight == ScrollStyle)
143  {
144  // Create our objects
145  this->ScrollBack = ParentScreen->CreateButton(this->Name+".ScrollBack",ChildRect);
148  this->AddChild(this->ScrollBack,0);
149 
150  this->UpLeftButton = ParentScreen->CreateButton(this->Name+".LeftButton",UnifiedRect(UnifiedVec2(-1,-1,0,0),ChildSize));
154  this->AddChild(this->UpLeftButton,1);
155 
156  this->DownRightButton = ParentScreen->CreateButton(this->Name+".RightButton",ChildRect);
160  this->AddChild(this->DownRightButton,2);
161 
162  this->Scroller = ParentScreen->CreateButton(this->Name+".Scroller",ChildRect);
163  this->Scroller->SetManualTransformUpdates(true);
164  this->AddChild(this->Scroller,3);
165  }
166  else if(UI::SB_TogetherUpLeft == ScrollStyle)
167  {
168  // Create our objects
169  this->UpLeftButton = ParentScreen->CreateButton(this->Name+".LeftButton",ChildRect);
173  this->AddChild(this->UpLeftButton,0);
174 
175  this->DownRightButton = ParentScreen->CreateButton(this->Name+".RightButton",UnifiedRect(UnifiedVec2(1,1,0,0),ChildSize));
179  this->AddChild(this->DownRightButton,1);
180 
181  this->ScrollBack = ParentScreen->CreateButton(this->Name+".ScrollBack",ChildRect);
184  this->AddChild(this->ScrollBack,2);
185 
186  this->Scroller = ParentScreen->CreateButton(this->Name+".Scroller",ChildRect);
187  this->Scroller->SetManualTransformUpdates(true);
188  this->AddChild(this->Scroller,3);
189  }
190  }
191 
192  Rect TempDims;
193  if( this->ActDims != TempDims ) {
194  TempDims = this->ActDims;
195  this->UpdateDimensions(TempDims,TempDims);
196  }
197 
198  this->SubscribeToChildEvents();
199  }
200 
202  {
203  return this->ScrollBack->GetActualPosition().X + this->ScrollBack->GetActualSize().X;
204  }
205 
207  {
208  return this->ScrollBack->GetActualPosition().X;
209  }
210 
211  ///////////////////////////////////////////////////////////////////////////////
212  // Utility Methods
213 
215  {
217  }
218 
220  {
221  if(Value > 1 || Value < 0)
222  return;
223 
224  const Rect ScrollBackRect = this->ScrollBack->GetRect();
225  const Rect OldScrollerRect = this->Scroller->GetRect();
226  Rect NewScrollerRect;
227 
228  NewScrollerRect.Size.X = OldScrollerRect.Size.X;
229  NewScrollerRect.Size.Y = OldScrollerRect.Size.Y;
230  NewScrollerRect.Position.X = ScrollBackRect.Position.X + ( ( this->GetScrollRange() - NewScrollerRect.Size.X ) * Value );
231  NewScrollerRect.Position.Y = ScrollBackRect.Position.Y;
232 
233  this->Scroller->UpdateDimensions(OldScrollerRect,NewScrollerRect);
234  }
235 
237  {
238  Real RelPos = this->Scroller->GetActualPosition().X - this->GetLowerScrollLimit();
239  Real RelLimit = this->GetScrollRange() - this->Scroller->GetActualSize().X;
240  return ( RelLimit > 0 ? RelPos / RelLimit : 0 );
241  }
242 
244  {
245  if(Size > 1 || Size < 0)
246  return;
247 
248  this->ScrollerSize = Size;
249  const Rect ScrollBackRect = this->ScrollBack->GetRect();
250  const Rect OldScrollerRect = this->Scroller->GetRect();
251  Rect NewScrollerRect;
252 
253  Real ScrollValue = this->GetScrollerValue();
254  NewScrollerRect.Size.X = ScrollBackRect.Size.X * Size;
255  NewScrollerRect.Size.Y = ScrollBackRect.Size.Y;
256  NewScrollerRect.Position.X = ScrollBackRect.Position.X + ( ( this->GetScrollRange() - NewScrollerRect.Size.X ) * ScrollValue );
257  NewScrollerRect.Position.Y = ScrollBackRect.Position.Y;
258 
259  this->Scroller->UpdateDimensions(OldScrollerRect,NewScrollerRect);
260  }
261 
263  {
264  //const Real ScrollBackX = this->ScrollBack->GetActualSize().X;
265  //return ( ScrollBackX > 0 ? this->Scroller->GetActualSize().X / ScrollBackX : 0 );
266  return ScrollerSize;
267  }
268 
269  void HorizontalScrollbar::UpdateDimensions(const Rect& OldSelfRect, const Rect& NewSelfRect)
270  {
271  // Update the personal data first
272  this->ActDims = NewSelfRect;
273 
274  // Get the data regarding the scroller we'll need after everything else is updated
275  const Real ScrollValue = this->GetScrollerValue();
276  const Real ScrollSize = this->GetScrollerSize();
277  const Rect OldScrollerRect = this->Scroller->GetRect();
278 
279  // Update the children
280  this->LayoutStrat->Layout(OldSelfRect,NewSelfRect,this->ChildWidgets);
281 
282  // Next prepare the new rect for the scroller
283  const Rect ScrollBackRect = this->ScrollBack->GetRect();
284  Rect NewScrollerRect;
285  NewScrollerRect.Size.X = ScrollBackRect.Size.X * ScrollSize;
286  NewScrollerRect.Size.Y = ScrollBackRect.Size.Y;
287  NewScrollerRect.Position.X = ScrollBackRect.Position.X + ( ( this->GetScrollRange() - NewScrollerRect.Size.Y ) * ScrollValue );
288  NewScrollerRect.Position.Y = ScrollBackRect.Position.Y;
289 
290  // Finally update the scroller
291  this->Scroller->UpdateDimensions(OldScrollerRect,NewScrollerRect);
292 
293  // We done got icky
294  this->_MarkAllLayersDirty();
295  }
296 
297  ///////////////////////////////////////////////////////////////////////////////
298  // Visibility and Priority Methods
299 
301  {
302  if( this->AutoHideScroll && CanSee ) {
303  if( this->GetMaxXPages() > 1.0 ) {
304  this->Widget::SetVisible(CanSee);
305  }
306  }else{
307  this->Widget::SetVisible(CanSee);
308  }
309  }
310 
312  {
313  if( this->AutoHideScroll ) {
314  if( this->GetMaxXPages() > 1.0 ) {
315  this->Widget::Show();
316  }
317  }else{
318  this->Widget::Show();
319  }
320  }
321 
323  {
324  this->Widget::Hide();
325  }
326 
327  ///////////////////////////////////////////////////////////////////////////////
328  // PageProvider Methods
329 
331  {
332  if( this->Container != NULL ) {
333  const Real ContainerXSize = this->Container->GetActualSize().X;
334  if( ContainerXSize > 0 ) {
335  Real Ret = MathTools::Ceil( this->Container->GetWorkAreaSize().X / ContainerXSize );
336  return ( Ret > 1 ? Ret : 1 );
337  }
338  }
339  return 1;
340  }
341 
343  { return 1; }
344 
346  { return ( (this->GetMaxXPages() - 1) * this->GetScrollerValue() ) + 1; }
347 
349  { return 1; }
350 
351  ///////////////////////////////////////////////////////////////////////////////
352  // Serialization
353 
355  {
357  }
358 
360  {
362 
363  // Assign the ScrollBack
364  this->ScrollBack = static_cast<Button*>( this->GetChild(this->Name+".ScrollBack") );
365  if( this->ScrollBack == NULL ) {
366  MEZZ_EXCEPTION(ExceptionBase::INVALID_STATE_EXCEPTION,"ScrollBack button not found after HorizontalScrollbar deserialization.");
367  }
368 
369  // Assign the Scroller
370  this->Scroller = static_cast<Button*>( this->GetChild(this->Name+".Scroller") );
371  if( this->Scroller == NULL ) {
372  MEZZ_EXCEPTION(ExceptionBase::INVALID_STATE_EXCEPTION,"Scroller button not found after HorizontalScrollbar deserialization.");
373  }
374 
375  if( this->GetNumChildren() > 2 )
376  {
377  // Assign the LeftButton
378  this->UpLeftButton = static_cast<Button*>( this->GetChild(this->Name+".LeftButton") );
379  if( this->UpLeftButton == NULL ) {
380  MEZZ_EXCEPTION(ExceptionBase::INVALID_STATE_EXCEPTION,"LeftButton button not found after HorizontalScrollbar deserialization.");
381  }
382 
383  // Assign the RightButton
384  this->DownRightButton = static_cast<Button*>( this->GetChild(this->Name+".RightButton") );
385  if( this->DownRightButton == NULL ) {
386  MEZZ_EXCEPTION(ExceptionBase::INVALID_STATE_EXCEPTION,"RightButton button not found after HorizontalScrollbar deserialization.");
387  }
388  }
389 
390  this->SubscribeToChildEvents();
391  }
392 
395 
396  ///////////////////////////////////////////////////////////////////////////////
397  // Internal Methods
398 
400  {
401  if( this->Container != NULL ) {
402  // Update the scroller size
403  Real XView = this->Container->GetActualSize().X;
404  Real XWork = this->Container->GetWorkAreaSize().X;
405  if( XWork > 0 ) {
406  this->SetScrollerSize( XView / XWork );
407  }else{
408  this->SetScrollerSize( 1.0 );
409  }
410 
411  // AutoHide check
412  /*if( this->AutoHideScroll ) {
413  if( this->GetMaxXPages() <= 1.0 ) {
414  this->Hide();
415  }else{
416  this->Show();
417  }
418  }// */
419  }
420  }
421 
423  {
424  if( this->ChildLock == this->Scroller && MouseDelta.X != 0 )
425  {
426  const Real OldScrollerValue = this->GetScrollerValue();
427  const Rect OldScrollerRect = this->Scroller->GetRect();
428  Rect NewScrollerRect;
429  NewScrollerRect.Size = OldScrollerRect.Size;
430 
431  NewScrollerRect.Position.X = OldScrollerRect.Position.X + MouseDelta.X;
432  NewScrollerRect.Position.Y = OldScrollerRect.Position.Y;
433 
434  NewScrollerRect.Position.X = std::min(NewScrollerRect.Position.X,this->GetUpperScrollLimit() - OldScrollerRect.Size.X);
435  NewScrollerRect.Position.X = std::max(NewScrollerRect.Position.X,this->GetLowerScrollLimit());
436 
437  this->Scroller->UpdateDimensions(OldScrollerRect,NewScrollerRect);
438 
439  const Real NewScrollerValue = this->GetScrollerValue();
440  if( OldScrollerValue != NewScrollerValue ) {
441  this->_OnScrollValueChanged(OldScrollerValue,NewScrollerValue);
442  }
443 
444  return true;
445  }
446  return false;
447  }
448 
450  {
451  if( Direction == Input::DIRECTIONALMOTION_UPLEFT ) {
452  const Real OldScrollerValue = this->GetScrollerValue();
453  const Rect OldScrollerRect = this->Scroller->GetRect();
454  Rect NewScrollerRect;
455  NewScrollerRect.Size = OldScrollerRect.Size;
456 
457  Real ScrollDist = -(this->ScrollBack->GetActualSize().X * this->IncrementDistance);
458  NewScrollerRect.Position.X = OldScrollerRect.Position.X + ScrollDist;
459  NewScrollerRect.Position.Y = OldScrollerRect.Position.Y;
460 
461  NewScrollerRect.Position.X = std::min(NewScrollerRect.Position.X,this->GetUpperScrollLimit() - OldScrollerRect.Size.X);
462  NewScrollerRect.Position.X = std::max(NewScrollerRect.Position.X,this->GetLowerScrollLimit());
463 
464  this->Scroller->UpdateDimensions(OldScrollerRect,NewScrollerRect);
465 
466  const Real NewScrollerValue = this->GetScrollerValue();
467  if( OldScrollerValue != NewScrollerValue ) {
468  this->_OnScrollValueChanged(OldScrollerValue,NewScrollerValue);
469  }
470 
471  return true;
472  }else if( Direction == Input::DIRECTIONALMOTION_DOWNRIGHT ) {
473  const Real OldScrollerValue = this->GetScrollerValue();
474  const Rect OldScrollerRect = this->Scroller->GetRect();
475  Rect NewScrollerRect;
476  NewScrollerRect.Size = OldScrollerRect.Size;
477 
478  Real ScrollDist = this->ScrollBack->GetActualSize().X * this->IncrementDistance;
479  NewScrollerRect.Position.X = OldScrollerRect.Position.X + ScrollDist;
480  NewScrollerRect.Position.Y = OldScrollerRect.Position.Y;
481 
482  NewScrollerRect.Position.X = std::min(NewScrollerRect.Position.X,this->GetUpperScrollLimit() - OldScrollerRect.Size.X);
483  NewScrollerRect.Position.X = std::max(NewScrollerRect.Position.X,this->GetLowerScrollLimit());
484 
485  this->Scroller->UpdateDimensions(OldScrollerRect,NewScrollerRect);
486 
487  const Real NewScrollerValue = this->GetScrollerValue();
488  if( OldScrollerValue != NewScrollerValue ) {
489  this->_OnScrollValueChanged(OldScrollerValue,NewScrollerValue);
490  }
491 
492  return true;
493  }
494  return false;
495  }
496 
498  {
499  if( this->ChildLock == this->ScrollBack )
500  {
501  const Real OldScrollerValue = this->GetScrollerValue();
502  const Rect OldScrollerRect = this->Scroller->GetRect();
503  const Real ScrollDist = this->ScrollBack->GetActualSize().X * this->IncrementDistance;
504  Rect NewScrollerRect(OldScrollerRect);
505 
506  // Early escape in case of error, but in general this shouldn't happen.
507  if( HitPosition.X < 0.0 || HitPosition.Y < 0.0 )
508  return false;
509 
510  if( HitPosition.X < OldScrollerRect.Position.X ) { // Check for left
511  NewScrollerRect.Position.X = ( OldScrollerRect.Position.X - OldScrollerRect.Size.X <= this->GetLowerScrollLimit() ?
512  this->GetLowerScrollLimit() : OldScrollerRect.Position.X - ScrollDist );
513  NewScrollerRect.Position.Y = OldScrollerRect.Position.Y;
514  }else if( HitPosition.X > OldScrollerRect.Position.X + OldScrollerRect.Size.X ) { // Check for right
515  NewScrollerRect.Position.X = ( OldScrollerRect.Position.X + ( OldScrollerRect.Size.X * 2 ) >= this->GetUpperScrollLimit() ?
516  this->GetUpperScrollLimit() - OldScrollerRect.Size.X : OldScrollerRect.Position.X + ScrollDist );
517  NewScrollerRect.Position.Y = OldScrollerRect.Position.Y;
518  }
519 
520  this->Scroller->UpdateDimensions(OldScrollerRect,NewScrollerRect);
521 
522  const Real NewScrollerValue = this->GetScrollerValue();
523  if( OldScrollerValue != NewScrollerValue ) {
524  this->_OnScrollValueChanged(OldScrollerValue,NewScrollerValue);
525  }
526 
527  return true;
528  }
529  return false;
530  }
531 
533  {
534  if( this->ChildLock == this->UpLeftButton ) {
535  const Real OldScrollerValue = this->GetScrollerValue();
536  const Rect OldScrollerRect = this->Scroller->GetRect();
537  Rect NewScrollerRect;
538  NewScrollerRect.Size = OldScrollerRect.Size;
539 
540  Real ScrollDist = -(this->ScrollBack->GetActualSize().X * this->IncrementDistance);
541  NewScrollerRect.Position.X = OldScrollerRect.Position.X + ScrollDist;
542  NewScrollerRect.Position.Y = OldScrollerRect.Position.Y;
543 
544  NewScrollerRect.Position.X = std::min(NewScrollerRect.Position.X,this->GetUpperScrollLimit() - OldScrollerRect.Size.X);
545  NewScrollerRect.Position.X = std::max(NewScrollerRect.Position.X,this->GetLowerScrollLimit());
546 
547  this->Scroller->UpdateDimensions(OldScrollerRect,NewScrollerRect);
548 
549  const Real NewScrollerValue = this->GetScrollerValue();
550  if( OldScrollerValue != NewScrollerValue ) {
551  this->_OnScrollValueChanged(OldScrollerValue,NewScrollerValue);
552  }
553 
554  return true;
555  }else if( this->ChildLock == this->DownRightButton ) {
556  const Real OldScrollerValue = this->GetScrollerValue();
557  const Rect OldScrollerRect = this->Scroller->GetRect();
558  Rect NewScrollerRect;
559  NewScrollerRect.Size = OldScrollerRect.Size;
560 
561  Real ScrollDist = this->ScrollBack->GetActualSize().X * this->IncrementDistance;
562  NewScrollerRect.Position.X = OldScrollerRect.Position.X + ScrollDist;
563  NewScrollerRect.Position.Y = OldScrollerRect.Position.Y;
564 
565  NewScrollerRect.Position.X = std::min(NewScrollerRect.Position.X,this->GetUpperScrollLimit() - OldScrollerRect.Size.X);
566  NewScrollerRect.Position.X = std::max(NewScrollerRect.Position.X,this->GetLowerScrollLimit());
567 
568  this->Scroller->UpdateDimensions(OldScrollerRect,NewScrollerRect);
569 
570  const Real NewScrollerValue = this->GetScrollerValue();
571  if( OldScrollerValue != NewScrollerValue ) {
572  this->_OnScrollValueChanged(OldScrollerValue,NewScrollerValue);
573  }
574 
575  return true;
576  }
577  return false;
578  }
579 
580  ///////////////////////////////////////////////////////////////////////////////
581  // HorizontalScrollbarFactory Methods
582 
585 
587  {
588  HorizontalScrollbar* Ret = new HorizontalScrollbar(RendName,Style,Parent);
590  return Ret;
591  }
592 
594  {
595  HorizontalScrollbar* Ret = new HorizontalScrollbar(RendName,RendRect,Style,Parent);
597  return Ret;
598  }
599 
601  {
602  HorizontalScrollbar* Ret = new HorizontalScrollbar(XMLNode,Parent);
604  return Ret;
605  }
606 
608  {
609  HorizontalScrollbar* Ret = new HorizontalScrollbar(Parent);
611  return Ret;
612  }
613 
615  {
616  UI::ScrollbarStyle Style = UI::SB_NoButtons;
617 
618  NameValuePairMap::const_iterator ParamIt;
619  ParamIt = Params.find("ScrollbarStyle");
620  if( ParamIt != Params.end() )
621  Style = static_cast<UI::ScrollbarStyle>( StringTools::ConvertToUInt32( (*ParamIt).second ) );
622 
623  return this->CreateHorizontalScrollbar(RendName,Style,Parent);
624  }
625 
626  Widget* HorizontalScrollbarFactory::CreateWidget(const String& RendName, const UnifiedRect& RendRect, const NameValuePairMap& Params, Screen* Parent)
627  {
628  UI::ScrollbarStyle Style = UI::SB_NoButtons;
629 
630  NameValuePairMap::const_iterator ParamIt;
631  ParamIt = Params.find("ScrollbarStyle");
632  if( ParamIt != Params.end() )
633  Style = static_cast<UI::ScrollbarStyle>( StringTools::ConvertToUInt32( (*ParamIt).second ) );
634 
635  return this->CreateHorizontalScrollbar(RendName,RendRect,Style,Parent);
636  }
637 
639  { return this->CreateHorizontalScrollbar(XMLNode,Parent); }
640 
642  { delete static_cast<HorizontalScrollbar*>( ToBeDestroyed ); }
643  }//UI
644 }//Mezzanine
645 
646 #endif
virtual void ConstructHorizontalScrollbar(const UI::ScrollbarStyle &ScrollStyle)
Constructor helper function for creating a horizontally aligned scrollbar.
virtual void ProtoSerializeChildQuads(XML::Node &SelfRoot) const
Convert the child quads of this class to an XML::Node ready for serialization.
virtual HorizontalScrollbar * CreateHorizontalScrollbar(const String &RendName, const UI::ScrollbarStyle &Style, Screen *Parent)
Creates a new HorizontalScrollbar.
virtual Rect GetRect() const
Gets this QuadRenderables' Rect.
virtual Boole _MouseWheelScroll(const Integer Direction)
Performs the operations for when the scroller is manipulated by the mouse wheel.
Button * ScrollBack
The background around that can be clicked on and represents the valid bounds for the scroller...
Definition: scrollbar.h:139
virtual void Show()
Forces this renderable to be shown.
Definition: widget.cpp:257
virtual Real GetMaxXPages() const
Gets the maximum number of pages supported on the X axis.
UInt32 ConvertToUInt32(const String &ToConvert)
Converts a string into a UInt32.
Definition: stringtool.cpp:456
Button * Scroller
The manipulatable widget that represents the current position on the scrollbar/slider.
Definition: scrollbar.h:136
virtual void _OnScrollValueChanged(const Real OldValue, const Real NewValue)
Self logic to be executed when this scrollbar changes it's scrollvalue.
Definition: scrollbar.cpp:238
virtual Real GetScrollerValue() const
Get the currnent scroll position represented by a value between 0 and 1.
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
virtual void SubscribeToChildEvents()
Subscribes to all the events of this scrollbars children we care about. Used only on construction...
Definition: scrollbar.cpp:126
virtual void ProtoDeSerializeChildQuads(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the ChildQuads of this object with it...
virtual void _MarkAllLayersDirty()
Tells this QuadRenderable that all of it's layers are dirty.
Vector2 Size
Vector2 representing the width and height of the rect.
Definition: rect.h:71
static String GetSerializableName()
Get the name of the the XML tag the Renderable class will leave behind as its instances are serialize...
Unified dimensions are ignored and will instead us all available space.
virtual void SetScrollerValue(const Real &Value)
Sets the value of this scrollbar and warps the scroller to that respective position.
virtual Real GetScrollRange() const
Gets the range on which the scroller can be placed.
Definition: scrollbar.cpp:148
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Definition: exception.h:3048
virtual void Hide()
Forces this renderable to hide.
int Integer
A datatype used to represent any integer close to.
Definition: datatypes.h:154
virtual void SetHorizontalPositioningRules(const Whole Rules)
Sets the behavior this quad will have when it is positioned automatically on the X axis...
virtual Boole _ButtonScroll(Button *TheButton)
Performs the operations for when one of the buttons is pressed to manipulate the scroller.
Real ScrollerSize
The size of the scroller on the appropriate axis relative to the ScrollBack.
Definition: scrollbar.h:156
virtual Real GetMaxYPages() const
Gets the maximum number of pages supported on the Y axis.
virtual Real GetScrollerSize() const
Gets the size of the scroller relative to the ScrollBack.
This class represents a box shaped area on the screen.
Definition: rect.h:55
virtual Real GetUpperScrollLimit() const
Gets the pixel position of the upper limit the scroller can be placed on.
ScrollbarStyle
Used by the scrollbar class to determine what styling should be used for the scrollbar.
virtual const String & GetTypeName() const
Gets the type of widget this is.
virtual void SetScrollerSize(const Real &Size)
Sets the length(or height) of the scroller based on the relative size of it's background.
PagedContainer * Container
A pointer to the PagedContainer this scrollbar is providing page data for.
Definition: pageprovider.h:60
virtual Widget * GetChild(const UInt16 Zorder) const
Gets a child by it's ZOrder.
virtual void ProtoSerializeChildQuads(XML::Node &SelfRoot) const
Convert the child quads of this class to an XML::Node ready for serialization.
ChildContainer ChildWidgets
This is a container storing all the children that belong to this Quad.
Button * DownRightButton
The Down/Right button that when clicked will move the scroller in that respective direction...
Definition: scrollbar.h:147
virtual void _NotifyContainerUpdated()
Notifies this provider that the container it is providing page data to has been updated.
virtual Real GetLowerScrollLimit() const
Gets the pixel position of the lower limit the scroller can be placed on.
Rect ActDims
The actual (pixel) position and size of this Quad on the screen it belongs to.
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
virtual Boole _ScrollBackScroll(const Vector2 &HitPosition)
Performs the operations for when the scrollback is clicked on to manipulate the scroller.
This class represents a 2D rect which can express the size and position of a renderable on screen...
Definition: unifieddim.h:661
Resizing will use the provided unified dimensions with no further alterations. This is the default fo...
virtual void RemoveChild(Widget *ToBeRemoved)
Removes a child Widget from this quadrenderable.
The calculated value for the perpendicular axis will be used as the final value for this axis...
This is the scrollbar base class.
Definition: scrollbar.h:126
HorizontalScrollbar(Screen *Parent)
Blank constructor.
Real Y
Coordinate on the Y vector.
Definition: vector2.h:69
virtual void DestroyWidget(Widget *ToBeDestroyed)
Destroys a widget.
Definition: screen.cpp:585
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
Real X
Coordinate on the X vector.
Definition: vector2.h:67
virtual const Vector2 & GetWorkAreaSize() const
Gets the size of this containers work area.
virtual void SetManualTransformUpdates(Boole Enable)
Sets whether or not this quad has specific behaviors for it's transform updates and they should not b...
This is used to represent a point on a 2 dimentional area, such as a screen.
Definition: vector2.h:63
This is the base class for all widgets.
Definition: widget.h:126
virtual void SetHorizontalSizingRules(const Whole Rules)
Sets the behavior this quad will have on the X axis when it is resized.
virtual void UnbindProvider(PageProvider *Prov)
Unbinds a provider being used by this container.
virtual Vector2 GetActualSize() const
Gets the pixel size of this widget.
Anchors to the left side of the quad.
static const String TypeName
String containing the type name for this class: "HorizontalScrollbar".
virtual Real GetCurrentYPage() const
Gets the current page position on the Y axis.
virtual String GetWidgetTypeName() const
Gets the name of the Widget that is created by this factory.
virtual void Layout(const Rect &OldSelfRect, const Rect &NewSelfRect, const ChildContainer &ChildQuads)
Updates the dimensions of a collection of QuadRenderables.
This is a scrollbar class aligned on the X axis.
virtual void DestroyWidget(Widget *ToBeDestroyed)
Destroys a Widget created by this factory.
String Name
The unique name of this Renderable.
Definition: renderable.h:81
Thrown when the available information should have worked but failed for unknown reasons.
Definition: exception.h:113
Uses the its own updated size as the offset for the new transform, and applies the Unified Dim of the...
virtual void AddChild(Widget *Child)
Adds a Widget to this as a child of this quad.
virtual void _SetLayoutStrat(LayoutStrategy *ToSet)
Sets a new LayoutStrategy for this quad to use.
virtual void Hide()
Forces this renderable to hide.
Definition: widget.cpp:266
Real IncrementDistance
The distance the scroller is to be moved when the up, left, down, or right buttons are clicked...
Definition: scrollbar.h:153
virtual Button * CreateButton(const String &RendName)
Creates a Button.
Definition: screen.cpp:630
Boole AutoHideScroll
Stores whether or not this scrollbar should hide when there is 1 page or less of list items...
Definition: scrollbar.h:159
Button * UpLeftButton
The Up/Left button that when clicked will move the scroller in that respective direction.
Definition: scrollbar.h:143
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
virtual void SetVerticalSizingRules(const Whole Rules)
Sets the behavior this quad will have on the Y axis when it is resized.
virtual Whole GetNumChildren() const
Gets the number of children in this QuadRenderable.
virtual void SetVisible(Boole CanSee)
Sets the visibility of this renderable.
virtual Vector2 GetActualPosition() const
Gets the pixel position of this widget.
virtual void SetVisible(Boole CanSee)
Sets the visibility of this renderable.
Definition: widget.cpp:229
Anchors to the right side of the quad.
This class represents a point in 2D space using UnifiedDim's.
Definition: unifieddim.h:306
This class is a helper class, specifically for use as a button.
Definition: button.h:66
virtual void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
virtual Boole _MouseScroll(const Vector2 &MouseDelta)
Performs the operations for when the scroller is directly manipulated by the mouse.
virtual void Show()
Forces this renderable to be shown.
Button * ChildLock
This is a pointer to the specific child that is locked and being manipulated.
Definition: scrollbar.h:150
virtual void UpdateDimensions()
Updates the dimensions of this QuadRenderable based on the transform of it's parent.
Vector2 Position
Vector2 representing the top-left position of the rect.
Definition: rect.h:69
virtual Widget * CreateWidget(Screen *Parent)
Creates a Widget of the type represented by this factory.
std::map< String, String > NameValuePairMap
This is a datatype mostly used for describing settings or parameters that can't be declared in advanc...
Definition: datatypes.h:209
virtual void ProtoDeSerializeChildQuads(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the ChildQuads of this object with it...
This class is a helper class for creating UI's. It is responsible for storing and keeping track of al...
Definition: screen.h:142
LayoutStrategy * LayoutStrat
This is a pointer to the strategy being used by this Quad to determine the positions and sizes of chi...
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
This is a specialization of a layout strategy where a group of quads are sized and placed in a linear...
virtual Real GetCurrentXPage() const
Gets the current page position on the X axis.
Screen * ParentScreen
A pointer to the Screen that created this Renderable.
Definition: renderable.h:72
virtual ~HorizontalScrollbar()
Class destructor.