prefer AutoActor over Sprite

This commit is contained in:
Glenn Maynard
2005-10-05 22:36:49 +00:00
parent a3c0817d81
commit 757b5c0acb
2 changed files with 33 additions and 33 deletions
+25 -25
View File
@@ -8,27 +8,27 @@
ScrollBar::ScrollBar()
{
m_sprBackground.Load( THEME->GetPathG("ScrollBar","parts 1x3") );
m_sprBackground.StopAnimating();
m_sprBackground.SetState( 1 );
this->AddChild( &m_sprBackground );
m_sprBackground->StopAnimating();
m_sprBackground->SetState( 1 );
this->AddChild( m_sprBackground );
m_sprScrollThumbPart1.Load( THEME->GetPathG("ScrollBar","thumb") );
m_sprScrollThumbPart1.StopAnimating();
this->AddChild( &m_sprScrollThumbPart1 );
m_sprScrollThumbPart1->StopAnimating();
this->AddChild( m_sprScrollThumbPart1 );
m_sprScrollThumbPart2.Load( THEME->GetPathG("ScrollBar","thumb") );
m_sprScrollThumbPart2.StopAnimating();
this->AddChild( &m_sprScrollThumbPart2 );
m_sprScrollThumbPart2->StopAnimating();
this->AddChild( m_sprScrollThumbPart2 );
m_sprTopButton.Load( THEME->GetPathG("ScrollBar","parts 1x3") );
m_sprTopButton.StopAnimating();
m_sprTopButton.SetState( 0 );
this->AddChild( &m_sprTopButton );
m_sprTopButton->StopAnimating();
m_sprTopButton->SetState( 0 );
this->AddChild( m_sprTopButton );
m_sprBottomButton.Load( THEME->GetPathG("ScrollBar","parts 1x3") );
m_sprBottomButton.StopAnimating();
m_sprBottomButton.SetState( 2 );
this->AddChild( &m_sprBottomButton );
m_sprBottomButton->StopAnimating();
m_sprBottomButton->SetState( 2 );
this->AddChild( m_sprBottomButton );
SetBarHeight( 100 );
}
@@ -36,17 +36,17 @@ ScrollBar::ScrollBar()
void ScrollBar::SetBarHeight( int iHeight )
{
m_iBarHeight = iHeight;
m_sprBackground.SetZoomY( m_iBarHeight/m_sprBackground.GetUnzoomedHeight() );
m_sprTopButton.SetY( -m_iBarHeight/2.0f );
m_sprBottomButton.SetY( +m_iBarHeight/2.0f );
m_sprScrollThumbPart1.SetY( 0 );
m_sprScrollThumbPart2.SetY( 0 );
m_sprBackground->SetZoomY( m_iBarHeight/m_sprBackground->GetUnzoomedHeight() );
m_sprTopButton->SetY( -m_iBarHeight/2.0f );
m_sprBottomButton->SetY( +m_iBarHeight/2.0f );
m_sprScrollThumbPart1->SetY( 0 );
m_sprScrollThumbPart2->SetY( 0 );
}
void ScrollBar::SetPercentage( float fStartPercent, float fEndPercent )
{
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 );
CHECKPOINT;
@@ -74,18 +74,18 @@ void ScrollBar::SetPercentage( float fStartPercent, float fEndPercent )
CHECKPOINT;
m_sprScrollThumbPart1.StretchTo( RectF(
-m_sprScrollThumbPart1.GetUnzoomedWidth()/2,
m_sprScrollThumbPart1->StretchTo( RectF(
-m_sprScrollThumbPart1->GetUnzoomedWidth()/2,
fPart1TopY,
+m_sprScrollThumbPart1.GetUnzoomedWidth()/2,
+m_sprScrollThumbPart1->GetUnzoomedWidth()/2,
fPart1BottomY
) );
CHECKPOINT;
m_sprScrollThumbPart2.StretchTo( RectF(
-m_sprScrollThumbPart2.GetUnzoomedWidth()/2,
m_sprScrollThumbPart2->StretchTo( RectF(
-m_sprScrollThumbPart2->GetUnzoomedWidth()/2,
fPart2TopY,
+m_sprScrollThumbPart2.GetUnzoomedWidth()/2,
+m_sprScrollThumbPart2->GetUnzoomedWidth()/2,
fPart2BottomY
) );
CHECKPOINT;
+8 -8
View File
@@ -1,10 +1,10 @@
/* ScrollBar - A simple scrollbar. */
#ifndef SCROLLBAR_H
#define SCROLLBAR_H
#ifndef SCROLL_BAR_H
#define SCROLL_BAR_H
#include "ActorFrame.h"
#include "Sprite.h"
#include "AutoActor.h"
class ScrollBar : public ActorFrame
@@ -19,11 +19,11 @@ protected:
int m_iBarHeight;
Sprite m_sprTopButton;
Sprite m_sprBottomButton;
Sprite m_sprBackground;
Sprite m_sprScrollThumbPart1;
Sprite m_sprScrollThumbPart2;
AutoActor m_sprTopButton;
AutoActor m_sprBottomButton;
AutoActor m_sprBackground;
AutoActor m_sprScrollThumbPart1;
AutoActor m_sprScrollThumbPart2;
};
#endif