mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 06:05:58 -06:00
QHD macos fixes
This commit is contained in:
parent
623148b483
commit
601bf3d66f
8 changed files with 24 additions and 12 deletions
|
|
@ -293,7 +293,7 @@ Rect Ctrl::GetWorkArea() const
|
|||
Rect MakeScreenRect(NSScreen *screen, CGRect r)
|
||||
{
|
||||
r.origin.y = [screen frame].size.height - r.origin.y - r.size.height;
|
||||
return MakeRect(r, DPI(1));
|
||||
return MakeRect(r, Upp::Ctrl::SCL(1));
|
||||
}
|
||||
|
||||
void Ctrl::GetWorkArea(Array<Rect>& rc)
|
||||
|
|
|
|||
|
|
@ -39,3 +39,4 @@ public:
|
|||
static Rect GetScreenArea(Point pt);
|
||||
static double GetDisplayScale() { return display_scale; }
|
||||
static double GetDisplayUnScale() { return display_unscale; }
|
||||
static int SCL(int x) { return (int)(display_scale * x); }
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ bool SystemDraw::IsPaintingOp(const Rect& r) const
|
|||
if(cr.IsEmpty())
|
||||
return false;
|
||||
return true;
|
||||
return nsview ? [(NSView *)nsview needsToDrawRect:MakeRectCG(1.0 / DPI(1) * cr)] : true;
|
||||
// return nsview ? [(NSView *)nsview needsToDrawRect:MakeRectCG(1.0 / DPI(1) * cr)] : true;
|
||||
}
|
||||
|
||||
Rect SystemDraw::GetPaintRect() const
|
||||
|
|
|
|||
|
|
@ -111,11 +111,6 @@ inline Upp::Rect MakeRect(const CGRect& r, int dpi) {
|
|||
return Upp::RectC(dpi * r.origin.x, dpi * r.origin.y, dpi * r.size.width, dpi * r.size.height);
|
||||
}
|
||||
|
||||
inline CGRect CGRectDPI(const Upp::Rect& r) {
|
||||
double sc = Upp::GetDPIUnScaleRatio();
|
||||
return CGRectMake(sc * r.left, sc * r.top, sc * r.GetWidth(), sc * r.GetHeight());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ struct MMImp {
|
|||
}
|
||||
NSPoint np = [view convertPoint:[e locationInWindow] fromView:nil];
|
||||
Rect r = view->ctrl->GetRect();
|
||||
Upp::Point p(DPI(np.x), DPI(np.y));
|
||||
Upp::Point p(Upp::Ctrl::SCL(np.x), Upp::Ctrl::SCL(np.y));
|
||||
coco_mouse_pos = p + r.TopLeft();
|
||||
|
||||
if(event == Ctrl::MOUSEMOVE) {
|
||||
|
|
@ -300,7 +300,7 @@ struct MMImp {
|
|||
clip.action = info.draggingSourceOperationMask & NSDragOperationMove ? DND_MOVE
|
||||
: DND_COPY;
|
||||
NSPoint np = [nsview convertPoint:[info draggingLocation] fromView:nil];
|
||||
coco_mouse_pos = Upp::Point(DPI(np.x), DPI(np.y)) + ctrl->GetScreenRect().TopLeft();
|
||||
coco_mouse_pos = Upp::Point(Upp::Ctrl::SCL(np.x), Upp::Ctrl::SCL(np.y)) + ctrl->GetScreenRect().TopLeft();
|
||||
ctrl->DnD(coco_mouse_pos, clip);
|
||||
if(paste && clip.IsAccepted() && clip.GetAction() == DND_COPY)
|
||||
Ctrl::local_dnd_copy = true;
|
||||
|
|
@ -358,7 +358,7 @@ struct MMImp {
|
|||
Upp::GuiLock __;
|
||||
if(ctrl) {
|
||||
Upp::SystemDraw w([[NSGraphicsContext currentContext] CGContext], self);
|
||||
Upp::MMImp::Paint(ctrl, w, MakeRect(r, Upp::DPI(1)));
|
||||
Upp::MMImp::Paint(ctrl, w, MakeRect(r, Upp::Ctrl::SCL(1)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ bool Ctrl::IsWndForeground() const
|
|||
|
||||
NSRect DesktopRect(const Rect& r)
|
||||
{
|
||||
double scalei = 1.0 / DPI(1);
|
||||
double scalei = 1.0 / Upp::Ctrl::SCL(1);
|
||||
return NSMakeRect(scalei * r.left,
|
||||
scalei * (Ctrl::GetScreenArea(r.TopLeft()).GetHeight() - r.top - r.GetHeight()),
|
||||
scalei * r.GetWidth(), scalei * r.GetHeight());
|
||||
|
|
@ -187,6 +187,11 @@ Vector<Ctrl *> Ctrl::GetTopCtrls()
|
|||
|
||||
void WakeUpGuiThread();
|
||||
|
||||
inline CGRect CGRectDPI(const Upp::Rect& r) {
|
||||
double sc = 1.0 / Upp::Ctrl::SCL(1);
|
||||
return CGRectMake(sc * r.left, sc * r.top, sc * r.GetWidth(), sc * r.GetHeight());
|
||||
}
|
||||
|
||||
void Ctrl::WndInvalidateRect(const Rect& r)
|
||||
{
|
||||
GuiLock __;
|
||||
|
|
@ -317,7 +322,7 @@ void TopWindow::SyncCaption()
|
|||
|
||||
CGSize MMFrameSize(Size sz, dword style)
|
||||
{
|
||||
double scale = 1.0 / DPI(1);
|
||||
double scale = 1.0 / Upp::Ctrl::SCL(1);
|
||||
return [NSWindow frameRectForContentRect:
|
||||
(NSRect)CGRectMake(100, 100, scale * sz.cx, scale * sz.cy) styleMask:style].size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,12 +140,21 @@ void ChHostSkin()
|
|||
|
||||
SColorPaper_Write(CocoColor(COCO_PAPER));
|
||||
|
||||
if(Atoi(GetEnv("UPP_SCALE__"))) {
|
||||
if(IsDarkTheme())
|
||||
ChDarkSkin();
|
||||
else
|
||||
ChStdSkin();
|
||||
return;
|
||||
}
|
||||
|
||||
SColorFace_Write(CocoColor(COCO_WINDOW, White()));
|
||||
SColorHighlight_Write(CocoColor(COCO_SELECTEDPAPER));
|
||||
SColorHighlightText_Write(CocoColor(COCO_SELECTEDTEXT));
|
||||
SColorText_Write(CocoColor(COCO_TEXT));
|
||||
SColorDisabled_Write(CocoColor(COCO_DISABLED));
|
||||
|
||||
|
||||
ChBaseSkin();
|
||||
|
||||
RoundStyleArrows();
|
||||
|
|
|
|||
|
|
@ -189,7 +189,9 @@ TestChStyle::TestChStyle()
|
|||
GUI_APP_MAIN
|
||||
{
|
||||
RDUMPM(Environment());
|
||||
|
||||
RDUMP(GetDPIScale());
|
||||
RDUMP(GetDPIScaleRatio());
|
||||
|
||||
RDUMP(SColorDisabled());
|
||||
RDUMP(SColorText());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue