summaryrefslogtreecommitdiff
path: root/plugingui/nativewindow_cocoa.mm
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2019-10-09 18:02:19 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2019-10-09 18:02:19 +0200
commit2d6cbf8a0bb81bfe55a7d4e04d53a704f93c6b2e (patch)
tree80bab0705a6d5aec8569a3ed626a33a6224cf4f0 /plugingui/nativewindow_cocoa.mm
parent9b7299412d10e68c8aacc5f0debb7c80bf874120 (diff)
Make FileBrowser window always-on-top and try to position it inside the plugin gui window rectangle.
Diffstat (limited to 'plugingui/nativewindow_cocoa.mm')
-rw-r--r--plugingui/nativewindow_cocoa.mm39
1 files changed, 37 insertions, 2 deletions
diff --git a/plugingui/nativewindow_cocoa.mm b/plugingui/nativewindow_cocoa.mm
index aaacd0e..d8e889a 100644
--- a/plugingui/nativewindow_cocoa.mm
+++ b/plugingui/nativewindow_cocoa.mm
@@ -576,6 +576,18 @@ void NativeWindowCocoa::setFixedSize(std::size_t width, std::size_t height)
[priv->window setMaxSize:NSMakeSize(width, height + 22)];
}
+void NativeWindowCocoa::setAlwaysOnTop(bool always_on_top)
+{
+ if(always_on_top)
+ {
+ [priv->window setLevel: NSStatusWindowLevel];
+ }
+ else
+ {
+ [priv->window setLevel: NSNormalWindowLevel];
+ }
+}
+
void NativeWindowCocoa::resize(std::size_t width, std::size_t height)
{
[priv->window setContentSize:NSMakeSize(width, height)];
@@ -597,13 +609,15 @@ std::pair<std::size_t, std::size_t> NativeWindowCocoa::getSize() const
void NativeWindowCocoa::move(int x, int y)
{
- [priv->window setFrameTopLeftPoint:NSMakePoint(x, y)];
+ NSRect screen = [[NSScreen mainScreen] frame];
+ [priv->window setFrameTopLeftPoint:NSMakePoint(x, screen.size.height - y)];
}
std::pair<int, int> NativeWindowCocoa::getPosition() const
{
+ NSRect screen = [[NSScreen mainScreen] frame];
NSPoint pos = [[priv->window contentView] frame].origin;
- return {pos.x, pos.y};
+ return {pos.x, screen.size.height - pos.y};
}
void NativeWindowCocoa::show()
@@ -757,6 +771,27 @@ void* NativeWindowCocoa::getNativeWindowHandle() const
}
}
+Point NativeWindowCocoa::translateToScreen(const Point& point)
+{
+ NSRect e = [[NSScreen mainScreen] frame];
+ NSRect frame;
+ if(native_window)
+ {
+ frame = [priv->parent_view frame];
+ }
+ else
+ {
+ frame = [priv->view frame];
+ }
+
+ NSRect rect { { point.x + frame.origin.x,
+ frame.size.height - point.y + frame.origin.y},
+ {0.0, 0.0} };
+ rect = [priv->window convertRectToScreen:rect];
+
+ return { (int)rect.origin.x, (int)(e.size.height - rect.origin.y) };
+}
+
Window& NativeWindowCocoa::getWindow()
{
return window;