Slightly optimise when table selected changes, by only redrawing the table. (And not the other widgets and top bit of the background)

This commit is contained in:
UnknownShadow200 2016-04-01 13:21:59 +11:00
parent 31e9f24693
commit a47118e652

View File

@ -75,7 +75,7 @@ namespace Launcher {
return;
LauncherTableWidget table = (LauncherTableWidget)widgets[tableIndex];
table.SetSelected( widgets[hashIndex].Text );
Resize();
RedrawTable();
}
public override void Init() {
@ -121,6 +121,11 @@ namespace Launcher {
void DrawBackground() {
using( FastBitmap dst = new FastBitmap( game.Framebuffer, true ) ) {
game.ClearArea( 0, 0, game.Width, tableY, dst );
DrawTableBackground( dst );
}
}
void DrawTableBackground( FastBitmap dst ) {
int tableHeight = Math.Max( game.Height - tableY - 50, 1 );
Rectangle rec = new Rectangle( tableX, tableY, game.Width - tableX, tableHeight );
@ -131,7 +136,6 @@ namespace Launcher {
game.ClearArea( rec.X, rec.Y, rec.Width, rec.Height, dst );
}
}
}
void MakeTableWidget() {
int tableHeight = Math.Max( game.Height - tableY - 50, 1 );
@ -145,7 +149,7 @@ namespace Launcher {
widget.SetDrawData( drawer, tableFont, inputFont, inputFont,
Anchor.LeftOrTop, Anchor.LeftOrTop, tableX, tableY );
widget.NeedRedraw = Resize;
widget.NeedRedraw = RedrawTable;
widget.SelectedChanged = SelectedChanged;
widget.SortDefault();
widgets[widgetIndex] = widget;
@ -160,8 +164,7 @@ namespace Launcher {
return;
LauncherTableWidget table = (LauncherTableWidget)widgets[tableIndex];
table.FilterEntries( lastInput.Text );
table.ClampIndex();
Resize();
RedrawTable();
}
void SelectedChanged( string hash ) {
@ -180,8 +183,7 @@ namespace Launcher {
protected override void MouseWheelChanged( object sender, MouseWheelEventArgs e ) {
LauncherTableWidget table = (LauncherTableWidget)widgets[tableIndex];
table.CurrentIndex -= e.Delta;
table.ClampIndex();
Resize();
RedrawTable();
}
string HashFilter( string input ) {
@ -208,5 +210,20 @@ namespace Launcher {
table.DraggingScrollbar = false;
}
}
void RedrawTable() {
using( FastBitmap dst = new FastBitmap( game.Framebuffer, true ) )
DrawTableBackground( dst );
LauncherTableWidget table = (LauncherTableWidget)widgets[tableIndex];
table.ClampIndex();
int tableHeight = Math.Max( game.Height - tableY - 50, 1 );
table.Height = tableHeight;
using( drawer ) {
drawer.SetBitmap( game.Framebuffer );
table.Redraw( drawer );
}
Dirty = true;
}
}
}