Skip to content

Commit

Permalink
Add resizable field to BaseWindow (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
beef331 committed Sep 17, 2024
1 parent 978c6b8 commit 405e22b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
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

0 comments on commit 405e22b

Please sign in to comment.