Skip to content

Commit

Permalink
Merge pull request #143 from AGulev/master
Browse files Browse the repository at this point in the history
Add borderles implementations for mac
  • Loading branch information
AGulev authored Oct 5, 2024
2 parents 5ea480b + 027c89c commit c9e4af2
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 10 deletions.
16 changes: 13 additions & 3 deletions defos/src/defos_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
37 changes: 31 additions & 6 deletions example/example.gui
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ textures {
nodes {
position {
x: 525.0
y: 104.0
y: 141.0
}
scale {
x: 0.7
Expand All @@ -36,7 +36,7 @@ nodes {
nodes {
position {
x: 525.0
y: 69.0
y: 106.0
}
scale {
x: 0.7
Expand Down Expand Up @@ -406,7 +406,7 @@ nodes {
nodes {
position {
x: 525.0
y: 174.0
y: 211.0
}
scale {
x: 0.7
Expand All @@ -431,7 +431,7 @@ nodes {
nodes {
position {
x: 525.0
y: 34.0
y: 71.0
}
scale {
x: 0.7
Expand Down Expand Up @@ -561,7 +561,7 @@ nodes {
nodes {
position {
x: 525.0
y: 139.0
y: 176.0
}
scale {
x: 0.7
Expand Down Expand Up @@ -682,7 +682,7 @@ nodes {
nodes {
position {
x: 525.0
y: 209.0
y: 246.0
}
scale {
x: 0.7
Expand Down Expand Up @@ -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"
3 changes: 2 additions & 1 deletion example/example.gui_script
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c9e4af2

Please sign in to comment.