diff --git a/defos/src/defos_mac.mm b/defos/src/defos_mac.mm index 033bb3c..21f921c 100644 --- a/defos/src/defos_mac.mm +++ b/defos/src/defos_mac.mm @@ -93,7 +93,16 @@ void defos_toggle_fullscreen() { } void defos_toggle_borderless() { - // TODO: add defos_toggle_borderless for Mac + if (!window) return; + + NSUInteger currentStyleMask = [window styleMask]; + if (currentStyleMask == NSWindowStyleMaskBorderless) { + [window setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskResizable | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable]; + } else { + [window setStyleMask:NSWindowStyleMaskBorderless]; + } + + [window makeKeyAndOrderFront:nil]; } void defos_toggle_maximized() { @@ -122,8 +131,9 @@ bool defos_is_fullscreen() { } bool defos_is_borderless() { - // TODO: add defos_is_borderless for Mac - return true; + if (!window) return false; + NSUInteger currentStyleMask = [window styleMask]; + return currentStyleMask == NSWindowStyleMaskBorderless; } bool defos_is_maximized() { diff --git a/example/example.gui b/example/example.gui index a856c05..18fea8d 100644 --- a/example/example.gui +++ b/example/example.gui @@ -10,7 +10,7 @@ textures { nodes { position { x: 525.0 - y: 104.0 + y: 141.0 } scale { x: 0.7 @@ -36,7 +36,7 @@ nodes { nodes { position { x: 525.0 - y: 69.0 + y: 106.0 } scale { x: 0.7 @@ -406,7 +406,7 @@ nodes { nodes { position { x: 525.0 - y: 174.0 + y: 211.0 } scale { x: 0.7 @@ -431,7 +431,7 @@ nodes { nodes { position { x: 525.0 - y: 34.0 + y: 71.0 } scale { x: 0.7 @@ -561,7 +561,7 @@ nodes { nodes { position { x: 525.0 - y: 139.0 + y: 176.0 } scale { x: 0.7 @@ -682,7 +682,7 @@ nodes { nodes { position { x: 525.0 - y: 209.0 + y: 246.0 } scale { x: 0.7 @@ -769,4 +769,29 @@ nodes { overridden_fields: 18 template_node_child: true } +nodes { + position { + x: 525.0 + y: 33.0 + } + scale { + x: 0.7 + y: 0.7 + } + size { + x: 450.0 + y: 100.0 + } + type: TYPE_TEXT + text: "is_mouse_in_view" + font: "larryfont" + id: "is_borderless" + pivot: PIVOT_NW + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + } + inherit_alpha: true +} material: "/builtins/materials/gui.material" diff --git a/example/example.gui_script b/example/example.gui_script index 5b44e15..c04294f 100644 --- a/example/example.gui_script +++ b/example/example.gui_script @@ -152,6 +152,7 @@ function update(self, dt) gui.set_text(gui.get_node("is_fullscreen"),"is_fullscreen "..tostring(defos.is_fullscreen())) gui.set_text(gui.get_node("is_maximized"),"is_maximized "..tostring(defos.is_maximized())) gui.set_text(gui.get_node("is_mouse_in_view"),"is_mouse_in_view "..tostring(defos.is_mouse_in_view())) + gui.set_text(gui.get_node("is_borderless"),"is_borderless "..tostring(defos.is_borderless())) end function update_clipping_label(self) @@ -198,7 +199,7 @@ function on_input(self, action_id, action) end) dirtylarry:button("toggle_borderless", action_id, action, function () - if system_name == "Windows" then + if system_name == "Windows" or system_name == "Darwin" then defos.toggle_borderless() end end)