flat assembler
Message board for the users of flat assembler.

Index > Windows > How calculating GUI pos regarding screen resolution ?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 2140
Roman 22 Oct 2026, 00:02
I write my GUI.
My resolution screen 1920x1080.

But i want recalculating position gui elements regarding user screen resolution.
Because somebody have 1600x768 screen resolution, somebody have 1366x768 screen resolution,somebody have 2560x1440 screen resolution.

How right calculate the coefficient correctly ?
Post 22 Oct 2026, 00:02
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 2140
Roman 22 Oct 2026, 00:18
Neural net say this:
Code:
offsetX       = 50; GUI element pos
offsetY       = 100; GUI element pos
baseWidth  = 1920;
baseHeight = 1080;

actualOffsetX = offsetX * (screenWidth / baseWidth);
actualOffsetY = offsetY * (screenHeight / baseHeight);
    


This is right formula ?
Post 22 Oct 2026, 00:18
View user's profile Send private message Reply with quote
frankobach26



Joined: 10 Apr 2026
Posts: 19
Location: Kassel
frankobach26 22 Oct 2026, 15:08
Hello Roman perhaps this Info can Help

Code:
struct Screen { float w, h; };

float sx = screen.w / 1920.0f;
float sy = screen.h / 1080.0f;
float scale = fminf(sx, sy);

// positions: uniform scale keeps proportions
btn.x = 50 * scale;
btn.y = 100 * scale;

// sizes: uniform scale too
btn.w = 200 * scale;
btn.h =  60 * scale;

// full-bleed elements (status bar): stretch to screen
statusBar.w = screen.w;

    


the neural net's formula is "right" as a coordinate mapping,
but use scale = min(sx, sy) (uniform) for positions and sizes,
and use anchoring for elements that should stretch with the
window. That gives you a clean 1920×1080 design that works
on 1366×768, 1600×768 and 2560×1440 without distortion or cut-off elements
Post 22 Oct 2026, 15:08
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2026, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.