Skip to main content
added 74 characters in body
Source Link
Ali1S232
  • 8.7k
  • 2
  • 41
  • 60

As far as I can tell from your question, you want your window to have same distance from all sides of screen, that means it's always in the center. to be more clear, center of window and center of the screen should both have same coordinates.

window has 3 panels, and all panels are squares with same size, so we can guess window.width is 3 times larger than window.height. you also want some padding, so there is some raw value for both width and height of window. let's say these raw values are equal to 85% of screen width and height respectively. using window.width = 3*window.height we can compute a new value for both width and height of window. the last step is to use minimum value from these generated values for width or height. here is a pseudo code:

 w1 = screen.width * 85%
 h1 = screen.height * 85%
 w2 = h1 * 3
 h2 = w1 / 3

 window.width = min(w1,w2)
 window.height = min(h1,h2)

 alpha = 0.35
 beta  = 0.7

 window.topleft = (screen.width / 2 - window.width /* 2(1-alpha), screen.height / 2 - window.height / 2*(1-beta))
 window.bottomright = (scree.width / 2 + window.width /* 2alpha , screen.height +/ 2+ window.height / 2*beta)

you need to find some good values for alpha and beta(both are between 0..1), alpha value higher than 0.5 will move window to right, while lower alpha values will result in window to be padded to left. also beta value will determine how much window goes near bottom of screen.

As far as I can tell from your question, you want your window to have same distance from all sides of screen, that means it's always in the center. to be more clear, center of window and center of the screen should both have same coordinates.

window has 3 panels, and all panels are squares with same size, so we can guess window.width is 3 times larger than window.height. you also want some padding, so there is some raw value for both width and height of window. let's say these raw values are equal to 85% of screen width and height respectively. using window.width = 3*window.height we can compute a new value for both width and height of window. the last step is to use minimum value from these generated values for width or height. here is a pseudo code:

 w1 = screen.width * 85%
 h1 = screen.height * 85%
 w2 = h1 * 3
 h2 = w1 / 3

 window.width = min(w1,w2)
 window.height = min(h1,h2)

 window.topleft = (screen.width - window.width / 2, screen.height - window.height / 2)
 window.bottomright = (scree.width + window.width / 2, screen.height + window.height / 2)

As far as I can tell from your question, you want your window to have same distance from all sides of screen, that means it's always in the center. to be more clear, center of window and center of the screen should both have same coordinates.

window has 3 panels, and all panels are squares with same size, so we can guess window.width is 3 times larger than window.height. you also want some padding, so there is some raw value for both width and height of window. let's say these raw values are equal to 85% of screen width and height respectively. using window.width = 3*window.height we can compute a new value for both width and height of window. the last step is to use minimum value from these generated values for width or height. here is a pseudo code:

 w1 = screen.width * 85%
 h1 = screen.height * 85%
 w2 = h1 * 3
 h2 = w1 / 3

 window.width = min(w1,w2)
 window.height = min(h1,h2)

 alpha = 0.35
 beta  = 0.7

 window.topleft = (screen.width / 2 - window.width * (1-alpha), screen.height / 2 - window.height *(1-beta))
 window.bottomright = (scree.width / 2 + window.width * alpha , screen.height / 2+ window.height *beta)

you need to find some good values for alpha and beta(both are between 0..1), alpha value higher than 0.5 will move window to right, while lower alpha values will result in window to be padded to left. also beta value will determine how much window goes near bottom of screen.

Source Link
Ali1S232
  • 8.7k
  • 2
  • 41
  • 60

As far as I can tell from your question, you want your window to have same distance from all sides of screen, that means it's always in the center. to be more clear, center of window and center of the screen should both have same coordinates.

window has 3 panels, and all panels are squares with same size, so we can guess window.width is 3 times larger than window.height. you also want some padding, so there is some raw value for both width and height of window. let's say these raw values are equal to 85% of screen width and height respectively. using window.width = 3*window.height we can compute a new value for both width and height of window. the last step is to use minimum value from these generated values for width or height. here is a pseudo code:

 w1 = screen.width * 85%
 h1 = screen.height * 85%
 w2 = h1 * 3
 h2 = w1 / 3

 window.width = min(w1,w2)
 window.height = min(h1,h2)

 window.topleft = (screen.width - window.width / 2, screen.height - window.height / 2)
 window.bottomright = (scree.width + window.width / 2, screen.height + window.height / 2)