Add proportionality support for GameUI panels (#35)

* Add proportionality support for GameUI panels

* Add Android platform define

* Fix button wrong state on fast clicking

Co-authored-by: JusicP <slender87844@gmail.com>
This commit is contained in:
nillerusr
2022-01-09 17:04:47 +03:00
committed by GitHub
parent 1f3436945f
commit 9d77bb17c5
20 changed files with 296 additions and 150 deletions

View File

@@ -1224,12 +1224,24 @@ void Frame::PerformLayout()
// move everything into place
int wide, tall;
GetSize(wide, tall);
float scale = 1;
if (IsProportional())
{
int screenW, screenH;
surface()->GetScreenSize(screenW, screenH);
int proW, proH;
surface()->GetProportionalBase(proW, proH);
scale = ((float)(screenH) / (float)(proH));
}
#if !defined( _X360 )
int DRAGGER_SIZE = GetDraggerSize();
int CORNER_SIZE = GetCornerSize();
int CORNER_SIZE2 = CORNER_SIZE * 2;
int BOTTOMRIGHTSIZE = GetBottomRightSize();
int BOTTOMRIGHTSIZE = GetBottomRightSize() * scale;
_topGrip->SetBounds(CORNER_SIZE, 0, wide - CORNER_SIZE2, DRAGGER_SIZE);
_leftGrip->SetBounds(0, CORNER_SIZE, DRAGGER_SIZE, tall - CORNER_SIZE2);
@@ -1260,18 +1272,6 @@ void Frame::PerformLayout()
_minimizeToSysTrayButton->MoveToFront();
_menuButton->SetBounds(5+2, 5+3, GetCaptionHeight()-5, GetCaptionHeight()-5);
#endif
float scale = 1;
if (IsProportional())
{
int screenW, screenH;
surface()->GetScreenSize( screenW, screenH );
int proW,proH;
surface()->GetProportionalBase( proW, proH );
scale = ( (float)( screenH ) / (float)( proH ) );
}
#if !defined( _X360 )
int offset_start = (int)( 20 * scale );