Fixed MACOS

This commit is contained in:
Mirek Fidler 2026-04-27 15:22:50 +02:00
parent b12786d7fa
commit 623148b483
6 changed files with 17 additions and 16 deletions

View file

@ -110,7 +110,7 @@ void CocoInit(int argc, const char **argv, const char **envptr)
Ctrl::display_scale = max(Ctrl::display_scale, [screen backingScaleFactor]);
Ctrl::display_unscale = 1 / Ctrl::display_scale;
Font::SetDefaultFont(StdFont(fceil(Ctrl::display_scale * [sysfont pointSize])));
GUI_DblClickTime_Write(1000 * NSEvent.doubleClickInterval);

View file

@ -41,7 +41,7 @@ NSPasteboard *Pasteboard(bool dnd = false)
@implementation CocoClipboardOwner
-(void)pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type
{
RLOG(Upp::ToString(type));
LLOG(Upp::ToString(type));
Upp::GuiLock __;
auto render = [&](const Upp::String& fmt) -> Upp::String {
@ -53,7 +53,7 @@ NSPasteboard *Pasteboard(bool dnd = false)
NSPasteboard *pasteboard = Upp::Pasteboard(dnd);
if(Upp::IsStandardPasteboardType(type)) {
RLOG("Standard type - clearning contents!");
LLOG("Standard type - clearning contents!");
[pasteboard clearContents];
}

View file

@ -2,7 +2,7 @@
#ifdef GUI_COCOA
#define LLOG(x)
#define LLOG(x) DLOG(x)
namespace Upp {
@ -85,9 +85,7 @@ void SystemDraw::SysDrawImageOp(int x, int y, const Image& img, Color color)
if(cgimg) {
DLOG("Have cgimg");
Size isz = img.GetSize();
DDUMP(isz);
CGContextSaveGState(cgHandle);
Point off = GetOffset();
CGContextTranslateCTM(cgHandle, x + off.x, y + off.y);
@ -103,7 +101,6 @@ void SystemDraw::SysDrawImageOp(int x, int y, const Image& img, Color color)
sCleanImageCache(img);
ImageSysDataMaker m;
LLOG("SysImage cache pixels " << cache.GetSize() << ", count " << cache.GetCount());
m.img = IsNull(color) ? img : CachedSetColorKeepAlpha(img, color); // TODO: Can setcolor be optimized out? By masks e.g.?
ImageSysData& sd = cg_image_cache.Get(m);
if(sd.cgimg) {
@ -273,7 +270,6 @@ NSImage *GetNSImage(const Image& img)
void Ctrl::SetNSAppImage(const Image& img)
{
ImageSysDataMaker m;
LLOG("SysImage cache pixels " << cache.GetSize() << ", count " << cache.GetCount());
m.img = img;
ImageSysData& sd = cg_image_cache.Get(m);
static CGImageRef cgimg;
@ -297,7 +293,6 @@ void Ctrl::SetMouseCursor(const Image& img)
return;
}
ImageSysDataMaker m;
LLOG("SysImage cache pixels " << cache.GetSize() << ", count " << cache.GetCount());
m.img = img;
ImageSysData& sd = cg_image_cache.Get(m);
static CGImageRef cgimg;
@ -329,9 +324,13 @@ void ImageDraw::Init(int cx, int cy)
colorSpace, kCGImageAlphaPremultipliedFirst,
NULL, NULL), NULL);
CGContextTranslateCTM(cgHandle, 0, cy);
double sc = Ctrl::GetDisplayScale();
CGContextScaleCTM(cgHandle, sc, -sc);
CGContextTranslateCTM(cgHandle, 0, -cy / sc);
if(Ctrl::GetDisplayScale() == 2) { // scale can only be 1 or 2...
CGContextScaleCTM(cgHandle, 2, -2);
CGContextTranslateCTM(cgHandle, 0, -cy / 2.0);
}
else
CGContextScaleCTM(cgHandle, 1, -1);
}
ImageDraw::ImageDraw(Size sz)

View file

@ -4,7 +4,7 @@
namespace Upp {
#define LLOG(x) // DLOG(x)
#define LLOG(x) DLOG(x)
static void sInitXImage(XImage& ximg, Size sz)
{

View file

@ -66,6 +66,11 @@ Image CocoImg(int type, int value = 0, int state = 0)
Color CocoColor(int k, Color bg = SColorFace())
{
#if 0
static int ii = 0; _DBG_
String p = GetHomeDirFile("Color" + AsString(ii++) + ".png"); _DBG_
DDUMP(p); PNGEncoder().SaveFile(p, CocoImg(bg, COCO_NSCOLOR, k, 0));
#endif
return AvgColor(CocoImg(bg, COCO_NSCOLOR, k, 0));
}

View file

@ -304,7 +304,6 @@ String SaveIml(const Array<ImlImage>& iml, int format, const String& eol) {
out << eol;
}
DLOG("================");
int ii = 0;
while(ii < iml.GetCount()) {
int bl = 0;
@ -318,8 +317,6 @@ String SaveIml(const Array<ImlImage>& iml, int format, const String& eol) {
bl += (int)c.image.GetLength();
bn++;
}
DDUMP(bimg.GetCount());
DDUMP(bl);
String bs = PackImlData(bimg);
out << eol << "IMAGE_BEGIN_DATA" << eol;
bs.Cat(0, ((bs.GetCount() + 31) & ~31) - bs.GetCount());