openMSX
ImGuiAdjust.hh
Go to the documentation of this file.
1#ifndef IMGUI_ADJUST_HH
2#define IMGUI_ADJUST_HH
3
4#include "gl_vec.hh"
5
6namespace openmsx {
7
8// Keep the imgui window in the 'same' position in the main view port (= the
9// main openMSX window) when that view port changes size. This happens when
10// changing scale_factor, but also when switching to/from fullscreen.
11//
12// Without this adjustment, after the resize, the window can e.g. move from the
13// border to somewhere in the middle of the view port, or even outside the view
14// port. This is not desired for stuff like the OSD icons or the reverse-bar.
15//
16// The heuristic for keeping the window in the 'same' position is:
17// * Only make adjustment when the window is shown fully inside the main view port.
18// * Separately for the horizontal and vertical direction:
19// * Check if the window is closer to the left or the right (or top or bottom)
20// border of the viewport.
21// * Keep this closet distance the same after rescaling. In other words, if the
22// window was e.g. close to the bottom, it will remain near the bottom.
23// * And some stuff for boundary conditions, see comments in the code for details.
25{
26public:
27 // should be called right before the call to im::Window()
28 void pre();
29
30 // should be called right after the call to im::Window()
31 bool post();
32
33private:
34 gl::vec2 oldViewPortSize;
35 gl::vec2 oldRelWindowPos;
36 bool oldIsOnMainViewPort = false;
37 bool setMainViewPort = false;
38};
39
40} // namespace openmsx
41
42#endif
This file implemented 3 utility functions:
Definition Autofire.cc:11