Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSX preparations #1786

Merged
merged 18 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Packages/MIES/MIES_MiesUtilities.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -6991,6 +6991,7 @@ Function StoreWindowCoordinatesHook(s)
string win

switch(s.eventCode)
case EVENT_WINDOW_HOOK_SUBWINDOWKILL:
case EVENT_WINDOW_HOOK_KILL:
win = s.winName
NVAR JSONid = $GetSettingsJSONid()
Expand Down
46 changes: 32 additions & 14 deletions Packages/MIES/MIES_PackageSettings.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ static Function PS_ApplyStoredWindowCoordinate(variable JSONid, string win)

AssertOnAndClearRTError()
try
MoveWindow/W=$win left, top, right, bottom; AbortOnRTE
if(IsSubWindow(win))
// correct for pixel/points confusion
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect the reason is:
"By default, panels are drawn using pixels if the screen resolution is 96 DPI but using points for higher-DPI settings. This gives backward compatibility on standard screens and reasonably-sized controls on high-resolution screens."

from DisplayHelpTopic "Control Panel Resolution on Windows"
from DisplayHelpTopic "Control Panel Units"

at 100% GUI scaling in windows print screenresolution results in 96 in IP.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why is that only relevant for exterior subwindows?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think because MoveWindow coordinates are always in "points".

Whereas MoveSubWindow are in "points" or "control panel units". If it is "control panel units" then the mentioned distinction for screenresolution == 96 dpi -> pixels, otherwise points kicks in.

What is a bit unclear to me is, that the MoveSubWindow docu states: "coordinates are taken to be fixed locations measured in points, or control panel units for control panel hosts".

Because according to that, it should be like:

if(IsControlPanelHost(subWin))
  // "control panel units"
  if(screenresolution == 96)
    return pixels
  else
    return points
  endif
else
  return points
endif

MoveSubWindow/W=$win fnum=(0, PointsToPixel(bottom - top), PointsToPixel(right - left), 0); AbortOnRTE
else
MoveWindow/W=$win left, top, right, bottom; AbortOnRTE
endif
catch
err = ClearRTError()
printf "Applying window coordinates for %s failed with %d\r", win, err
Expand All @@ -156,27 +161,33 @@ End
/// The windows must have been registered beforehand with PS_InitCoordinates().
static Function PS_StoreWindowCoordinates(variable JSONid)

string list, win, part
variable i, numEntries, store
string list, win, part, subWindows, subWin
variable i, j, numEntries, store, numSubWindows

list = WinList("*", ";", "WIN:65") // Graphs + Panels

numEntries = ItemsInList(list)
for(i = 0; i < numEntries; i += 1)
win = StringFromList(i, list)
store = str2num(GetUserData(win, "", PS_STORE_COORDINATES))

if(IsNaN(store) || store == 0)
continue
endif
subWindows = GetAllWindows(win)

for(j = 0; j < numSubWindows; j += 1)
subWin = StringFromList(j, subWindows)
store = str2num(GetUserData(subWin, "", PS_STORE_COORDINATES))

if(IsNaN(store) || store == 0)
continue
endif

AssertOnAndClearRTError()
try
PS_StoreWindowCoordinate(JSONid, win); AbortOnRTE
catch
ClearRTError()
// silently ignore
endtry
AssertOnAndClearRTError()
try
PS_StoreWindowCoordinate(JSONid, win); AbortOnRTE
catch
ClearRTError()
// silently ignore
endtry
endfor
endfor
End

Expand All @@ -186,6 +197,13 @@ End
Function PS_StoreWindowCoordinate(variable JSONid, string win)

string path, name
variable store

store = str2num(GetUserData(win, "", PS_STORE_COORDINATES))

if(IsNaN(store) || store == 0)
return NaN
endif

name = GetUserData(win, "", PS_WINDOW_NAME)
ASSERT(!IsEmpty(name), "Invalid empty name")
Expand Down