1
0
Fork 0

Change: position error window closer to cursor on large screens (#11923)

pull/11927/head
Patric Stout 2024-01-30 14:57:49 +01:00 committed by GitHub
parent 2b1f78d2ca
commit a05b7acec8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 17 deletions

View File

@ -223,26 +223,20 @@ public:
return pt; return pt;
} }
/* Find the free screen space between the main toolbar at the top, and the statusbar at the bottom. constexpr int distance_to_cursor = 200;
* Add a fixed distance 20 to make it less cluttered.
*/
int scr_top = GetMainViewTop() + 20;
int scr_bot = GetMainViewBottom() - 20;
Point pt = RemapCoords(this->position.x, this->position.y, GetSlopePixelZOutsideMap(this->position.x, this->position.y)); /* Position the error window just above the cursor. This makes the
const Viewport *vp = GetMainWindow()->viewport; * error window clearly visible, without being in the way of what
if (this->face == INVALID_COMPANY) { * the user is doing. */
/* move x pos to opposite corner */ Point pt;
pt.x = UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left; pt.x = _cursor.pos.x - sm_width / 2;
pt.x = (pt.x < (_screen.width >> 1)) ? _screen.width - sm_width - 20 : 20; // Stay 20 pixels away from the edge of the screen. pt.y = _cursor.pos.y - (distance_to_cursor + sm_height);
/* move y pos to opposite corner */ if (pt.y < GetMainViewTop()) {
pt.y = UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top; /* Window didn't fit above cursor, so place it below. */
pt.y = (pt.y < (_screen.height >> 1)) ? scr_bot - sm_height : scr_top; pt.y = _cursor.pos.y + distance_to_cursor;
} else {
pt.x = std::min(std::max(UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left - (sm_width / 2), 0), _screen.width - sm_width);
pt.y = std::min(std::max(UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top - (sm_height / 2), scr_top), scr_bot - sm_height);
} }
return pt; return pt;
} }