diff options
Diffstat (limited to 'platform/macos/godot_button_view.mm')
-rw-r--r-- | platform/macos/godot_button_view.mm | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/platform/macos/godot_button_view.mm b/platform/macos/godot_button_view.mm index 9106f0b0db..7d380cbe11 100644 --- a/platform/macos/godot_button_view.mm +++ b/platform/macos/godot_button_view.mm @@ -40,6 +40,9 @@ spacing = 20; mouse_in_group = false; rtl = false; + close_button = nullptr; + miniaturize_button = nullptr; + zoom_button = nullptr; return self; } @@ -48,15 +51,15 @@ spacing = button_spacing; rtl = is_rtl; - NSButton *close_button = [NSWindow standardWindowButton:NSWindowCloseButton forStyleMask:NSWindowStyleMaskTitled]; + close_button = [NSWindow standardWindowButton:NSWindowCloseButton forStyleMask:NSWindowStyleMaskTitled]; [close_button setFrameOrigin:NSMakePoint(rtl ? spacing * 2 : 0, 0)]; [self addSubview:close_button]; - NSButton *miniaturize_button = [NSWindow standardWindowButton:NSWindowMiniaturizeButton forStyleMask:NSWindowStyleMaskTitled]; + miniaturize_button = [NSWindow standardWindowButton:NSWindowMiniaturizeButton forStyleMask:NSWindowStyleMaskTitled]; [miniaturize_button setFrameOrigin:NSMakePoint(spacing, 0)]; [self addSubview:miniaturize_button]; - NSButton *zoom_button = [NSWindow standardWindowButton:NSWindowZoomButton forStyleMask:NSWindowStyleMaskTitled]; + zoom_button = [NSWindow standardWindowButton:NSWindowZoomButton forStyleMask:NSWindowStyleMaskTitled]; [zoom_button setFrameOrigin:NSMakePoint(rtl ? 0 : spacing * 2, 0)]; [self addSubview:zoom_button]; @@ -71,6 +74,19 @@ [self displayButtons]; } +- (void)setOffset:(NSPoint)button_offset { + if (zoom_button) { + offset.y = button_offset.y - zoom_button.frame.size.height / 2; + offset.x = button_offset.x - zoom_button.frame.size.width / 2; + + [self viewDidMoveToWindow]; + } +} + +- (NSPoint)getOffset { + return offset; +} + - (void)viewDidMoveToWindow { if (!self.window) { return; |