1 /*
2 GWEN
3 Copyright (c) 2010 Facepunch Studios
4 See license in Gwen.h
5 */
6
7 #include "Gwen/Controls/ScrollBar.h"
8 #include "Gwen/Controls/ScrollBarBar.h"
9
10 using namespace Gwen;
11 using namespace Gwen::Controls;
12 using namespace Gwen::ControlsInternal;
13
14 //Actual bar representing height of parent
15
GWEN_CONTROL_CONSTRUCTOR(ScrollBarBar)16 GWEN_CONTROL_CONSTRUCTOR(ScrollBarBar)
17 {
18 RestrictToParent(true);
19 SetTarget(this);
20 }
21
Render(Skin::Base * skin)22 void ScrollBarBar::Render(Skin::Base* skin)
23 {
24 skin->DrawScrollBarBar(this, m_bDepressed, IsHovered(), m_bHorizontal);
25 BaseClass::Render(skin);
26 }
27
OnMouseMoved(int x,int y,int deltaX,int deltaY)28 void ScrollBarBar::OnMouseMoved(int x, int y, int deltaX, int deltaY)
29 {
30 BaseClass::OnMouseMoved(x, y, deltaX, deltaY);
31
32 if (!m_bDepressed)
33 return;
34
35 InvalidateParent();
36 }
37
OnMouseClickLeft(int x,int y,bool bDown)38 void ScrollBarBar::OnMouseClickLeft(int x, int y, bool bDown)
39 {
40 BaseClass::OnMouseClickLeft(x, y, bDown);
41 InvalidateParent();
42 }
43
Layout(Skin::Base *)44 void ScrollBarBar::Layout(Skin::Base* /*skin*/)
45 {
46 if (!GetParent())
47 return;
48
49 //Move to our current position to force clamping - is this a hack?
50 MoveTo(X(), Y());
51 }
52
MoveTo(int x,int y)53 void ScrollBarBar::MoveTo(int x, int y)
54 {
55 BaseClass::MoveTo(x, y);
56 }