prefer AutoActor over Sprite
This commit is contained in:
+25
-25
@@ -8,27 +8,27 @@
|
|||||||
ScrollBar::ScrollBar()
|
ScrollBar::ScrollBar()
|
||||||
{
|
{
|
||||||
m_sprBackground.Load( THEME->GetPathG("ScrollBar","parts 1x3") );
|
m_sprBackground.Load( THEME->GetPathG("ScrollBar","parts 1x3") );
|
||||||
m_sprBackground.StopAnimating();
|
m_sprBackground->StopAnimating();
|
||||||
m_sprBackground.SetState( 1 );
|
m_sprBackground->SetState( 1 );
|
||||||
this->AddChild( &m_sprBackground );
|
this->AddChild( m_sprBackground );
|
||||||
|
|
||||||
m_sprScrollThumbPart1.Load( THEME->GetPathG("ScrollBar","thumb") );
|
m_sprScrollThumbPart1.Load( THEME->GetPathG("ScrollBar","thumb") );
|
||||||
m_sprScrollThumbPart1.StopAnimating();
|
m_sprScrollThumbPart1->StopAnimating();
|
||||||
this->AddChild( &m_sprScrollThumbPart1 );
|
this->AddChild( m_sprScrollThumbPart1 );
|
||||||
|
|
||||||
m_sprScrollThumbPart2.Load( THEME->GetPathG("ScrollBar","thumb") );
|
m_sprScrollThumbPart2.Load( THEME->GetPathG("ScrollBar","thumb") );
|
||||||
m_sprScrollThumbPart2.StopAnimating();
|
m_sprScrollThumbPart2->StopAnimating();
|
||||||
this->AddChild( &m_sprScrollThumbPart2 );
|
this->AddChild( m_sprScrollThumbPart2 );
|
||||||
|
|
||||||
m_sprTopButton.Load( THEME->GetPathG("ScrollBar","parts 1x3") );
|
m_sprTopButton.Load( THEME->GetPathG("ScrollBar","parts 1x3") );
|
||||||
m_sprTopButton.StopAnimating();
|
m_sprTopButton->StopAnimating();
|
||||||
m_sprTopButton.SetState( 0 );
|
m_sprTopButton->SetState( 0 );
|
||||||
this->AddChild( &m_sprTopButton );
|
this->AddChild( m_sprTopButton );
|
||||||
|
|
||||||
m_sprBottomButton.Load( THEME->GetPathG("ScrollBar","parts 1x3") );
|
m_sprBottomButton.Load( THEME->GetPathG("ScrollBar","parts 1x3") );
|
||||||
m_sprBottomButton.StopAnimating();
|
m_sprBottomButton->StopAnimating();
|
||||||
m_sprBottomButton.SetState( 2 );
|
m_sprBottomButton->SetState( 2 );
|
||||||
this->AddChild( &m_sprBottomButton );
|
this->AddChild( m_sprBottomButton );
|
||||||
|
|
||||||
SetBarHeight( 100 );
|
SetBarHeight( 100 );
|
||||||
}
|
}
|
||||||
@@ -36,17 +36,17 @@ ScrollBar::ScrollBar()
|
|||||||
void ScrollBar::SetBarHeight( int iHeight )
|
void ScrollBar::SetBarHeight( int iHeight )
|
||||||
{
|
{
|
||||||
m_iBarHeight = iHeight;
|
m_iBarHeight = iHeight;
|
||||||
m_sprBackground.SetZoomY( m_iBarHeight/m_sprBackground.GetUnzoomedHeight() );
|
m_sprBackground->SetZoomY( m_iBarHeight/m_sprBackground->GetUnzoomedHeight() );
|
||||||
m_sprTopButton.SetY( -m_iBarHeight/2.0f );
|
m_sprTopButton->SetY( -m_iBarHeight/2.0f );
|
||||||
m_sprBottomButton.SetY( +m_iBarHeight/2.0f );
|
m_sprBottomButton->SetY( +m_iBarHeight/2.0f );
|
||||||
m_sprScrollThumbPart1.SetY( 0 );
|
m_sprScrollThumbPart1->SetY( 0 );
|
||||||
m_sprScrollThumbPart2.SetY( 0 );
|
m_sprScrollThumbPart2->SetY( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollBar::SetPercentage( float fStartPercent, float fEndPercent )
|
void ScrollBar::SetPercentage( float fStartPercent, float fEndPercent )
|
||||||
{
|
{
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
const int iBarContentHeight = m_iBarHeight - int( m_sprTopButton.GetUnzoomedHeight()/2 + m_sprBottomButton.GetUnzoomedHeight()/2 );
|
const int iBarContentHeight = m_iBarHeight - int( m_sprTopButton->GetUnzoomedHeight()/2 + m_sprBottomButton->GetUnzoomedHeight()/2 );
|
||||||
ASSERT( iBarContentHeight != 0 );
|
ASSERT( iBarContentHeight != 0 );
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
|
|
||||||
@@ -74,18 +74,18 @@ void ScrollBar::SetPercentage( float fStartPercent, float fEndPercent )
|
|||||||
|
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
|
|
||||||
m_sprScrollThumbPart1.StretchTo( RectF(
|
m_sprScrollThumbPart1->StretchTo( RectF(
|
||||||
-m_sprScrollThumbPart1.GetUnzoomedWidth()/2,
|
-m_sprScrollThumbPart1->GetUnzoomedWidth()/2,
|
||||||
fPart1TopY,
|
fPart1TopY,
|
||||||
+m_sprScrollThumbPart1.GetUnzoomedWidth()/2,
|
+m_sprScrollThumbPart1->GetUnzoomedWidth()/2,
|
||||||
fPart1BottomY
|
fPart1BottomY
|
||||||
) );
|
) );
|
||||||
|
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
m_sprScrollThumbPart2.StretchTo( RectF(
|
m_sprScrollThumbPart2->StretchTo( RectF(
|
||||||
-m_sprScrollThumbPart2.GetUnzoomedWidth()/2,
|
-m_sprScrollThumbPart2->GetUnzoomedWidth()/2,
|
||||||
fPart2TopY,
|
fPart2TopY,
|
||||||
+m_sprScrollThumbPart2.GetUnzoomedWidth()/2,
|
+m_sprScrollThumbPart2->GetUnzoomedWidth()/2,
|
||||||
fPart2BottomY
|
fPart2BottomY
|
||||||
) );
|
) );
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
/* ScrollBar - A simple scrollbar. */
|
/* ScrollBar - A simple scrollbar. */
|
||||||
|
|
||||||
#ifndef SCROLLBAR_H
|
#ifndef SCROLL_BAR_H
|
||||||
#define SCROLLBAR_H
|
#define SCROLL_BAR_H
|
||||||
|
|
||||||
#include "ActorFrame.h"
|
#include "ActorFrame.h"
|
||||||
#include "Sprite.h"
|
#include "AutoActor.h"
|
||||||
|
|
||||||
|
|
||||||
class ScrollBar : public ActorFrame
|
class ScrollBar : public ActorFrame
|
||||||
@@ -19,11 +19,11 @@ protected:
|
|||||||
|
|
||||||
int m_iBarHeight;
|
int m_iBarHeight;
|
||||||
|
|
||||||
Sprite m_sprTopButton;
|
AutoActor m_sprTopButton;
|
||||||
Sprite m_sprBottomButton;
|
AutoActor m_sprBottomButton;
|
||||||
Sprite m_sprBackground;
|
AutoActor m_sprBackground;
|
||||||
Sprite m_sprScrollThumbPart1;
|
AutoActor m_sprScrollThumbPart1;
|
||||||
Sprite m_sprScrollThumbPart2;
|
AutoActor m_sprScrollThumbPart2;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user