This commit is contained in:
Mirek Fidler 2026-04-08 09:47:44 +02:00
commit d1990eb90c
10 changed files with 28 additions and 32 deletions

View file

@ -73,6 +73,9 @@ extern const char *sClipFmtsRTF;
id menubar;
double Ctrl::display_scale = 1;
double Ctrl::display_unscale = 1;
void CocoInit(int argc, const char **argv, const char **envptr)
{
Ctrl::GlobalBackBuffer();
@ -102,16 +105,13 @@ void CocoInit(int argc, const char **argv, const char **envptr)
Font::SetFace(0, ToString((CFStringRef)[sysfont familyName]), Font::TTF);
Ctrl::SetUHDEnabled(true);
bool uhd = true;
for (NSScreen *screen in [NSScreen screens]) {
if([screen backingScaleFactor] < 2) {
uhd = false;
break;
}
}
SetUHDMode(uhd);
Ctrl::display_scale = 1;
for (NSScreen *screen in [NSScreen screens])
Ctrl::display_scale = max(Ctrl::display_scale, [screen backingScaleFactor]);
Ctrl::display_unscale = 1 / Ctrl::display_scale;
Font::SetDefaultFont(StdFont(fceil(DPI([sysfont pointSize]))));
Font::SetDefaultFont(StdFont(fceil(Ctrl::display_scale * [sysfont pointSize])));
GUI_DblClickTime_Write(1000 * NSEvent.doubleClickInterval);

View file

@ -6,8 +6,12 @@ private:
static Ptr<Ctrl> lastActive;
static bool always_use_bundled_icon;
static double display_scale;
static double display_unscale;
friend void CocoInit(int argc, const char **argv, const char **envptr);
friend void Coco_PaintCh(void *cgcontext, int type, int value, int state);
protected:
virtual void MMClose() {}
@ -33,3 +37,5 @@ public:
void RegisterCocoaDropFormats();
static Rect GetScreenArea(Point pt);
static double GetDisplayScale() { return display_scale; }
static double GetDisplayUnScale() { return display_unscale; }

View file

@ -12,8 +12,9 @@ void SystemDraw::Init(void *cgContext, void *view)
CGContextSetBlendMode(cgHandle, kCGBlendModeNormal);
CGContextSetTextPosition(cgHandle, 0, 0);
CGContextSetTextDrawingMode(cgHandle, kCGTextFill);
if(IsUHDMode())
CGContextScaleCTM(cgHandle, 0.5, 0.5);
double sc = Ctrl::GetDisplayUnScale();
if(sc != 1)
CGContextScaleCTM(cgHandle, sc, sc);
}
SystemDraw::SystemDraw(void *cgContext, void *nsview)

View file

@ -329,12 +329,9 @@ void ImageDraw::Init(int cx, int cy)
colorSpace, kCGImageAlphaPremultipliedFirst,
NULL, NULL), NULL);
CGContextTranslateCTM(cgHandle, 0, cy);
if(IsUHDMode()) {
CGContextScaleCTM(cgHandle, 2, -2);
CGContextTranslateCTM(cgHandle, 0, -cy / 2.0);
}
else
CGContextScaleCTM(cgHandle, 1, -1);
double sc = Ctrl::GetDisplayScale();
CGContextScaleCTM(cgHandle, sc, -sc);
CGContextTranslateCTM(cgHandle, 0, -cy / sc);
}
ImageDraw::ImageDraw(Size sz)

View file

@ -112,11 +112,8 @@ inline Upp::Rect MakeRect(const CGRect& r, int dpi) {
}
inline CGRect CGRectDPI(const Upp::Rect& r) {
double sc = GetDPIUnScaleRatio();
if(Upp::IsUHDMode())
return CGRectMake(sc * r.left, sc * r.top, sc * r.GetWidth(), sc * r.GetHeight());
else
return CGRectMake(r.left, r.top, r.GetWidth(), r.GetHeight());
double sc = Upp::GetDPIUnScaleRatio();
return CGRectMake(sc * r.left, sc * r.top, sc * r.GetWidth(), sc * r.GetHeight());
}
#endif

View file

@ -68,12 +68,12 @@ void TopWindow::Init()
int Ctrl::GetGtkTitleBarHeight(const TopWindow *tw)
{
return max(tw->custom_titlebar_cy, IsUHDMode() ? 60 : 31);
return max(tw->custom_titlebar_cy, DPI(31));
}
int Ctrl::GetGtkTitleBarButtonWidth()
{
return IsUHDMode() ? 94 : 47;
return DPI(47);
}
void TopWindow::SyncIcons()

View file

@ -17,8 +17,9 @@ void Coco_PaintCh(void *cgcontext, int type, int value, int state)
{
auto dopaint = [&] {
auto cg = (CGContextRef) cgcontext;
if(Upp::IsUHDMode())
CGContextScaleCTM(cg, 2, 2);
double sc = Upp::Ctrl::GetDisplayScale();
if(sc != 1)
CGContextScaleCTM(cg, sc, sc);
CGRect cr = CGRectMake(0, 0, 140, 140);
if(type == COCO_NSCOLOR) {
CGContextSaveGState(cg);

View file

@ -31,11 +31,7 @@ void IconShow::Paint(Draw& w)
return DPISmartRescale(image, scale * image.GetSize() / image_scale);
};
Size sz100 = GetSize(DPI_100);
Size sz150 = GetSize(DPI_150);
Size sz200 = GetSize(DPI_200);
Size sz300 = GetSize(DPI_300);
if(sz300.cx * sz300.cy > 20000) {
w.DrawRect(sz, SColorPaper);
w.DrawImage(DPI(5), DPI(5), image);

View file

@ -233,7 +233,6 @@ MainConfigDlg::MainConfigDlg(const Workspace& wspc_) : wspc(wspc_) {
append.SetImage(IdeImg::add()) << [=] {
FlagsDlg cfg;
if(cfg.Run() == IDOK) {
int q = config.GetCount();
cfg.Set(config.Add());
LoadList(config.GetCount() - 1);
}

View file

@ -1,2 +1 @@
PREMULTIPLIED
VERSION(20260403)