Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add window title and frame methods #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading