Launcher: Blend input box top

This commit is contained in:
UnknownShadow200 2016-09-13 18:56:28 +10:00
parent ffacf8e8e2
commit 88ee8aa432
6 changed files with 49 additions and 29 deletions

View File

@ -50,14 +50,14 @@ namespace Launcher {
} }
} }
public static void Clear( FastBitmap dst, Rectangle dstRect, FastColour col ) { public static void Clear( FastBitmap bmp, Rectangle rect, FastColour col ) {
int x, y, width, height; int x, y, width, height;
if( !ClampCoords( dst, dstRect, out x, out y, out width, out height ) ) if( !ClampCoords( bmp, rect, out x, out y, out width, out height ) )
return; return;
int pixel = col.ToArgb(); int pixel = col.ToArgb();
for( int yy = 0; yy < height; yy++ ) { for( int yy = 0; yy < height; yy++ ) {
int* row = dst.GetRowPtr( y + yy ); int* row = bmp.GetRowPtr( y + yy );
for( int xx = 0; xx < width; xx++ ) for( int xx = 0; xx < width; xx++ )
row[x + xx] = pixel; row[x + xx] = pixel;
} }

View File

@ -45,8 +45,9 @@ namespace Launcher.Gui.Screens {
curInput.Redraw( drawer ); curInput.Redraw( drawer );
Rectangle r = curInput.MeasureCaret( drawer, inputFont ); Rectangle r = curInput.MeasureCaret( drawer, inputFont );
if( caretShow ) if( caretShow ) {
drawer.Clear( FastColour.White, r.X, r.Y, r.Width, r.Height ); drawer.Clear( FastColour.Black, r.X, r.Y, r.Width, r.Height );
}
if( lastRec == r ) game.DirtyArea = r; if( lastRec == r ) game.DirtyArea = r;
lastRec = r; lastRec = r;

View File

@ -66,7 +66,7 @@ namespace Launcher.Gui.Views {
const int progWidth = 200, progHalf = 5; const int progWidth = 200, progHalf = 5;
internal void DrawProgressBox( int progress ) { internal void DrawProgressBox( int progress ) {
progress = (progWidth * progress) / 100; progress = (progWidth * progress) / 100;
using( FastBitmap bmp = new FastBitmap( game.Framebuffer, true, false ) ) { using( FastBitmap bmp = game.LockBits() ) {
Rectangle r = new Rectangle( game.Width / 2 - progWidth / 2, Rectangle r = new Rectangle( game.Width / 2 - progWidth / 2,
game.Height / 2 + 10, progWidth, progHalf ); game.Height / 2 + 10, progWidth, progHalf );
DrawBoxBounds( bmp, r ); DrawBoxBounds( bmp, r );

View File

@ -64,7 +64,7 @@ namespace Launcher.Gui.Widgets {
public void RedrawBackground() { public void RedrawBackground() {
if( Window.Minimised ) return; if( Window.Minimised ) return;
using( FastBitmap dst = new FastBitmap( Window.Framebuffer, true, false ) ) using( FastBitmap dst = Window.LockBits() )
RedrawBackground( dst ); RedrawBackground( dst );
} }

View File

@ -1,7 +1,6 @@
// ClassicalSharp copyright 2014-2016 UnknownShadow200 | Licensed under MIT // ClassicalSharp copyright 2014-2016 UnknownShadow200 | Licensed under MIT
using System; using System;
using System.Drawing; using System.Drawing;
using System.Windows.Forms;
using ClassicalSharp; using ClassicalSharp;
namespace Launcher.Gui.Widgets { namespace Launcher.Gui.Widgets {
@ -67,7 +66,12 @@ namespace Launcher.Gui.Widgets {
args.SkipPartsCheck = true; args.SkipPartsCheck = true;
if( Window.Minimised ) return; if( Window.Minimised ) return;
DrawBorders( drawer ); using( FastBitmap bmp = Window.LockBits() ) {
DrawOuterBorder( bmp );
DrawInnerBorder( bmp );
Clear( bmp, FastColour.White, X + 2, Y + 2, Width - 4, Height - 4 );
BlendBoxTop( bmp );
}
DrawText( drawer, args ); DrawText( drawer, args );
} }
@ -75,24 +79,39 @@ namespace Launcher.Gui.Widgets {
static FastColour borderOut = new FastColour( 97, 81, 110 ); static FastColour borderOut = new FastColour( 97, 81, 110 );
const int border = 1; const int border = 1;
void DrawBorders( IDrawer2D drawer ) { void DrawOuterBorder( FastBitmap bmp ) {
FastColour col = borderOut; FastColour col = borderOut;
if( Active ) { if( Active ) {
drawer.Clear( col, X, Y, Width, border ); Clear( bmp, col, X, Y, Width, border );
drawer.Clear( col, X, Y + Height - border, Width, border ); Clear( bmp, col, X, Y + Height - border, Width, border );
drawer.Clear( col, X, Y, border, Height ); Clear( bmp, col, X, Y, border, Height );
drawer.Clear( col, X + Width - border, Y, border, Height ); Clear( bmp, col, X + Width - border, Y, border, Height );
} else { } else {
//Window.ResetArea( X, Y, Width, Window.ResetArea( X, Y, Width, border, bmp );
Window.ResetArea( X, Y + Height - border, Width, border, bmp );
Window.ResetArea( X, Y, border, Height, bmp );
Window.ResetArea( X + Width - border, Y, border, Height, bmp );
}
} }
col = borderIn; void DrawInnerBorder( FastBitmap bmp ) {
drawer.Clear( col, X + border, Y + border, Width - border * 2, border ); FastColour col = borderIn;
drawer.Clear( col, X + border, Y + Height - border * 2, Width - border * 2, border ); Clear( bmp, col, X + border, Y + border, Width - border * 2, border );
drawer.Clear( col, X + border, Y + border, border, Height - border * 2 ); Clear( bmp, col, X + border, Y + Height - border * 2, Width - border * 2, border );
drawer.Clear( col, X + Width - border * 2, Y + border, border, Height - border * 2 ); Clear( bmp, col, X + border, Y + border, border, Height - border * 2 );
Clear( bmp, col, X + Width - border * 2, Y + border, border, Height - border * 2 );
}
drawer.Clear( FastColour.White, X + 2, Y + 2, Width - 4, Height - 4 ); void BlendBoxTop( FastBitmap bmp ) {
Rectangle r = new Rectangle( X + border, Y, Width - border * 2, border );
r.Y += border; Gradient.Blend( bmp, r, FastColour.Black, 75 );
r.Y += border; Gradient.Blend( bmp, r, FastColour.Black, 50 );
r.Y += border; Gradient.Blend( bmp, r, FastColour.Black, 25 );
}
void Clear( FastBitmap bmp, FastColour col,
int x, int y, int width, int height ) {
Drawer2DExt.Clear( bmp, new Rectangle( x, y, width, height ), col );
} }
void DrawText( IDrawer2D drawer, DrawTextArgs args ) { void DrawText( IDrawer2D drawer, DrawTextArgs args ) {

View File

@ -92,9 +92,9 @@ namespace Launcher {
} }
if( ClassicBackground && terrainPixels != null ) { if( ClassicBackground && terrainPixels != null ) {
using( FastBitmap dst = new FastBitmap( Framebuffer, true, false ) ) { using( FastBitmap bmp = LockBits() ) {
ClearTile( 0, 0, Width, 48, tileSize, dst ); ClearTile( 0, 0, Width, 48, tileSize, bmp );
ClearTile( 0, 48, Width, Height - 48, 0, dst ); ClearTile( 0, 48, Width, Height - 48, 0, bmp );
} }
} else { } else {
ResetArea( 0, 0, Width, Height ); ResetArea( 0, 0, Width, Height );