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 resizable field to BaseWindow #172

Merged
merged 1 commit into from
Sep 17, 2024
Merged
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
1 change: 1 addition & 0 deletions docs/widgets.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ renderable BaseWindow of BaseWidget
- `defaultSize: tuple[width, height: int] = (800, 600)` Initial size of the window
- `fullscreened: bool`
- `iconName: string`
- `resizable: bool = true`

###### Events

Expand Down
2 changes: 2 additions & 0 deletions owlkettle/bindings/gtk.nim
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,8 @@ proc gtk_window_new*(windowType: GtkWindowType): GtkWidget
proc gtk_window_set_title*(window: GtkWidget, title: cstring)
proc gtk_window_set_titlebar*(window, titlebar: GtkWidget)
proc gtk_window_set_default_size*(window: GtkWidget, width, height: cint)
proc gtk_window_set_resizable*(window: GtkWidget, resizable: cbool)
proc gtk_window_get_resizable*(window: GtkWidget): cbool
proc gtk_window_set_transient_for*(window, parent: GtkWidget)
proc gtk_window_set_modal*(window: GtkWidget, modal: cbool)
proc gtk_window_set_focus*(window, focus: GtkWidget)
Expand Down
8 changes: 7 additions & 1 deletion owlkettle/widgets.nim
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ renderable BaseWindow of BaseWidget:
defaultSize: tuple[width, height: int] = (800, 600) ## Initial size of the window
fullscreened: bool
iconName: string
resizable: bool = true

proc close() ## Called when the window is closed

Expand Down Expand Up @@ -148,6 +149,11 @@ renderable BaseWindow of BaseWidget:
property:
gtk_window_set_icon_name(state.internalWidget, state.iconName.cstring)

hooks resizable:
property:
gtk_window_set_resizable(state.internalWidget, cbool(state.resizable))


renderable Window of BaseWindow:
title: string
titlebar: Widget ## Custom widget set as the titlebar of the window
Expand All @@ -156,7 +162,7 @@ renderable Window of BaseWindow:
hooks:
beforeBuild:
state.internalWidget = gtk_window_new(GTK_WINDOW_TOPLEVEL)

hooks title:
property:
if state.titlebar.isNil:
Expand Down
Loading