Skip to content

Commit

Permalink
Add window title and frame methods
Browse files Browse the repository at this point in the history
  • Loading branch information
pdoane committed Sep 26, 2024
1 parent 773066d commit b11ad5e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions generator.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1911,6 +1911,12 @@ fn generateAppKit(generator: anytype) !void {
[2][]const u8{ "NSWindow", "isVisible" },
[2][]const u8{ "NSWindow", "setIsVisible" },
[2][]const u8{ "NSWindow", "makeKeyAndOrderFront" },
[2][]const u8{ "NSWindow", "title" },
[2][]const u8{ "NSWindow", "setTitle" },
[2][]const u8{ "NSWindow", "frame" },
[2][]const u8{ "NSWindow", "setFrame" },
[2][]const u8{ "NSWindow", "contentRectForFrameRect" },
[2][]const u8{ "NSWindow", "frameRectForContentRect" },

[2][]const u8{ "NSView", "layer" },
[2][]const u8{ "NSView", "setLayer" },
Expand All @@ -1919,6 +1925,7 @@ fn generateAppKit(generator: anytype) !void {

[2][]const u8{ "NSScreen", "screens" },
[2][]const u8{ "NSScreen", "mainScreen" },
[2][]const u8{ "NSScreen", "frame" },

[2][]const u8{ "NSApplicationDelegate", "applicationDidFinishLaunching" },

Expand Down
18 changes: 18 additions & 0 deletions src/app_kit.zig
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,30 @@ pub const Window = opaque {
pub const alloc = InternalInfo.alloc;
pub const allocInit = InternalInfo.allocInit;

pub fn frameRectForContentRect(self_: *@This(), contentRect_: Rect) Rect {
return objc.msgSend(self_, "frameRectForContentRect:", Rect, .{contentRect_});
}
pub fn contentRectForFrameRect(self_: *@This(), frameRect_: Rect) Rect {
return objc.msgSend(self_, "contentRectForFrameRect:", Rect, .{frameRect_});
}
pub fn initWithContentRect_styleMask_backing_defer_screen(self_: *@This(), contentRect_: Rect, style_: WindowStyleMask, backingStoreType_: BackingStoreType, flag_: bool, screen_: ?*Screen) *@This() {
return objc.msgSend(self_, "initWithContentRect:styleMask:backing:defer:screen:", *@This(), .{ contentRect_, style_, backingStoreType_, flag_, screen_ });
}
pub fn makeKeyAndOrderFront(self_: *@This(), sender_: ?*objc.Id) void {
return objc.msgSend(self_, "makeKeyAndOrderFront:", void, .{sender_});
}
pub fn title(self_: *@This()) *String {
return objc.msgSend(self_, "title", *String, .{});
}
pub fn setTitle(self_: *@This(), title_: *String) void {
return objc.msgSend(self_, "setTitle:", void, .{title_});
}
pub fn contentView(self_: *@This()) ?*View {
return objc.msgSend(self_, "contentView", ?*View, .{});
}
pub fn frame(self_: *@This()) Rect {
return objc.msgSend(self_, "frame", Rect, .{});
}
pub fn isReleasedWhenClosed(self_: *@This()) bool {
return objc.msgSend(self_, "isReleasedWhenClosed", bool, .{});
}
Expand Down Expand Up @@ -206,6 +221,9 @@ pub const Screen = opaque {
pub fn mainScreen() ?*Screen {
return objc.msgSend(@This().InternalInfo.class(), "mainScreen", ?*Screen, .{});
}
pub fn frame(self_: *@This()) Rect {
return objc.msgSend(self_, "frame", Rect, .{});
}
};

pub const ApplicationDelegate = opaque {
Expand Down

0 comments on commit b11ad5e

Please sign in to comment.