fix selection glow in GroupList

This commit is contained in:
Chris Danford
2003-07-26 09:53:15 +00:00
parent 89546b0459
commit 916e08b55c
2 changed files with 65 additions and 42 deletions
+63 -39
View File
@@ -26,11 +26,10 @@ GroupList::GroupList()
GroupList::~GroupList()
{
for( unsigned i = 0; i < m_Frames.size(); ++i )
for( unsigned i = 0; i < m_sprButtons.size(); ++i )
{
delete m_Frames[i];
delete m_sprButtons[i];
delete m_screenLabels[i];
delete m_textLabels[i];
}
}
@@ -49,28 +48,31 @@ void GroupList::Load( const CStringArray& asGroupNames )
for( unsigned i=0; i < m_asLabels.size(); i++ )
{
ActorFrame *frame = new ActorFrame;
frame->SetXY( START_X + i*SPACING_X, START_Y + i*SPACING_Y );
m_Frames.push_back(frame);
m_Frame.AddChild( frame );
Sprite *button = new Sprite;
BitmapText *label = new BitmapText;
Sprite *spr = new Sprite;
m_sprButtons.push_back(spr);
spr->Load( THEME->GetPathToG("GroupList bar") );
frame->AddChild( spr );
m_sprButtons.push_back( button );
m_textLabels.push_back( label );
BitmapText *text = new BitmapText;
m_screenLabels.push_back(text);
text->LoadFromFont( THEME->GetPathToF("GroupList label") );
text->SetShadowLength( 2 );
text->SetText( SONGMAN->ShortenGroupName( asGroupNames[i] ) );
frame->AddChild( text );
button->Load( THEME->GetPathToG("GroupList bar") );
label->LoadFromFont( THEME->GetPathToF("GroupList label") );
label->SetShadowLength( 2 );
label->SetText( SONGMAN->ShortenGroupName( asGroupNames[i] ) );
m_Frame.AddChild( button );
m_Frame.AddChild( label );
button->SetXY( START_X + i*SPACING_X, START_Y + i*SPACING_Y );
label->SetXY( START_X + i*SPACING_X, START_Y + i*SPACING_Y );
if( i == 0 )
text->TurnRainbowOn();
else {
text->TurnRainbowOff();
text->SetDiffuse( SONGMAN->GetGroupColor(asGroupNames[i]) );
{
label->TurnRainbowOn();
}
else
{
label->TurnRainbowOff();
label->SetDiffuse( SONGMAN->GetGroupColor(asGroupNames[i]) );
}
m_bHidden.push_back( ItemIsOnScreen(i) );
@@ -83,20 +85,21 @@ void GroupList::Load( const CStringArray& asGroupNames )
void GroupList::ResetTextSize( int i )
{
BitmapText *text = m_screenLabels[i];
const float fTextWidth = (float)text->GetWidestLineWidthInSourcePixels();
BitmapText *label = m_textLabels[i];
const float fTextWidth = (float)label->GetWidestLineWidthInSourcePixels();
const float fButtonWidth = m_sprButtons[i]->GetZoomedWidth();
float fZoom = fButtonWidth/fTextWidth;
fZoom = min( fZoom, 0.8f );
text->SetZoomX( fZoom );
text->SetZoomY( 0.8f );
label->SetZoomX( fZoom );
label->SetZoomY( 0.8f );
}
void GroupList::BeforeChange()
{
m_Frames[m_iSelection]->Command( LOSE_FOCUS_COMMAND );
m_sprButtons[m_iSelection]->Command( LOSE_FOCUS_COMMAND );
m_textLabels[m_iSelection]->Command( LOSE_FOCUS_COMMAND );
}
@@ -106,7 +109,9 @@ void GroupList::AfterChange()
m_Frame.Command( SCROLL_TWEEN_COMMAND );
m_Frame.SetY( -m_iTop*SPACING_Y );
m_Frames[m_iSelection]->Command( GAIN_FOCUS_COMMAND );
m_sprButtons[m_iSelection]->Command( GAIN_FOCUS_COMMAND );
m_textLabels[m_iSelection]->Command( GAIN_FOCUS_COMMAND );
for( int i=0; i < (int) m_asLabels.size(); i++ )
{
const bool IsHidden = !ItemIsOnScreen(i);
@@ -115,12 +120,12 @@ void GroupList::AfterChange()
if( IsHidden && !WasHidden )
{
m_sprButtons[i]->Command( HIDE_ITEM_COMMAND );
m_screenLabels[i]->Command( HIDE_ITEM_COMMAND );
m_textLabels[i]->Command( HIDE_ITEM_COMMAND );
}
else if( !IsHidden && WasHidden )
{
m_sprButtons[i]->Command( SHOW_ITEM_COMMAND );
m_screenLabels[i]->Command( SHOW_ITEM_COMMAND );
m_textLabels[i]->Command( SHOW_ITEM_COMMAND );
ResetTextSize( i );
}
@@ -186,18 +191,27 @@ void GroupList::TweenOnScreen()
for( int i=0; i < (int) m_asLabels.size(); i++ )
{
const int offset = max(0, i-m_iTop);
m_Frames[i]->SetX( 400 );
m_Frames[i]->BeginTweening( 0.1f*offset, TWEEN_BOUNCE_END );
m_Frames[i]->BeginTweening( 0.2f, TWEEN_BOUNCE_END );
m_Frames[i]->SetX( 0 );
m_sprButtons[i]->SetX( 400 );
m_textLabels[i]->SetX( 400 );
m_sprButtons[i]->BeginTweening( 0.1f*offset, TWEEN_BOUNCE_END );
m_textLabels[i]->BeginTweening( 0.1f*offset, TWEEN_BOUNCE_END );
m_sprButtons[i]->BeginTweening( 0.2f, TWEEN_BOUNCE_END );
m_textLabels[i]->BeginTweening( 0.2f, TWEEN_BOUNCE_END );
m_sprButtons[i]->SetX( 0 );
m_textLabels[i]->SetX( 0 );
/* If this item isn't visible, hide it and skip tweens. */
if( !ItemIsOnScreen(i) )
{
m_sprButtons[i]->Command( HIDE_ITEM_COMMAND );
m_screenLabels[i]->Command( HIDE_ITEM_COMMAND );
m_textLabels[i]->Command( HIDE_ITEM_COMMAND );
m_sprButtons[i]->FinishTweening();
m_screenLabels[i]->FinishTweening();
m_textLabels[i]->FinishTweening();
}
}
}
@@ -208,11 +222,21 @@ void GroupList::TweenOffScreen()
{
const int offset = max(0, i-m_iTop);
if( i == m_iSelection )
m_Frames[i]->BeginTweening( 1.0f, TWEEN_BOUNCE_BEGIN );
{
m_sprButtons[i]->BeginTweening( 1.0f, TWEEN_BOUNCE_BEGIN );
m_textLabels[i]->BeginTweening( 1.0f, TWEEN_BOUNCE_BEGIN );
}
else
m_Frames[i]->BeginTweening( 0.1f*offset, TWEEN_BOUNCE_BEGIN );
m_Frames[i]->BeginTweening( 0.2f, TWEEN_BOUNCE_BEGIN );
m_Frames[i]->SetX( 400 );
{
m_sprButtons[i]->BeginTweening( 0.1f*offset, TWEEN_BOUNCE_BEGIN );
m_textLabels[i]->BeginTweening( 0.1f*offset, TWEEN_BOUNCE_BEGIN );
}
m_sprButtons[i]->BeginTweening( 0.2f, TWEEN_BOUNCE_BEGIN );
m_textLabels[i]->BeginTweening( 0.2f, TWEEN_BOUNCE_BEGIN );
m_sprButtons[i]->SetX( 400 );
m_textLabels[i]->SetX( 400 );
}
}
+2 -3
View File
@@ -7,10 +7,9 @@
class GroupList: public ActorFrame {
ActorFrame m_Frame;
vector<Actor *> m_Frames;
vector<Sprite *> m_sprButtons;
vector<BitmapText *> m_screenLabels;
vector<CString> m_asLabels;
vector<BitmapText *> m_textLabels;
vector<CString> m_asLabels;
vector<bool> m_bHidden;