Skip to content

Commit

Permalink
Add ScrolledWindow.propagateNaturalWidth and propagateNaturalHeight f…
Browse files Browse the repository at this point in the history
…ields
  • Loading branch information
can-lehmann committed Jun 10, 2024
1 parent 976ed07 commit 68c1db0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/widgets.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,8 @@ renderable ScrolledWindow of BaseWidget

- All fields from [BaseWidget](#BaseWidget)
- `child: Widget`
- `propagateNaturalWidth: bool = false`
- `propagateNaturalHeight: bool = false`

###### 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 @@ -808,6 +808,8 @@ proc gtk_scrolled_window_new*(hAdjustment, vAdjustment: GtkAdjustment): GtkWidge
proc gtk_scrolled_window_get_hadjustment*(window: GtkWidget): GtkAdjustment
proc gtk_scrolled_window_get_vadjustment*(window: GtkWidget): GtkAdjustment
proc gtk_scrolled_window_set_child*(window, child: GtkWidget)
proc gtk_scrolled_window_set_propagate_natural_width*(window: GtkWidget, prop: cbool)
proc gtk_scrolled_window_set_propagate_natural_height*(window: GtkWidget, prop: cbool)

# Gtk.Range
proc gtk_range_get_value*(widget: GtkWidget): cdouble
Expand Down
11 changes: 11 additions & 0 deletions owlkettle/widgets.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,9 @@ renderable ScrolledWindow of BaseWidget:
proc edgeReached(edge: Edge) ## Called when the user reaches the limits of the scrollbar

child: Widget

propagateNaturalWidth: bool = false
propagateNaturalHeight: bool = false

hooks:
beforeBuild:
Expand All @@ -1154,6 +1157,14 @@ renderable ScrolledWindow of BaseWidget:
(build, update):
state.updateChild(state.child, widget.valChild, gtk_scrolled_window_set_child)

hooks propagateNaturalWidth:
property:
gtk_scrolled_window_set_propagate_natural_width(state.internalWidget, cbool(ord(state.propagateNaturalWidth)))

hooks propagateNaturalHeight:
property:
gtk_scrolled_window_set_propagate_natural_height(state.internalWidget, cbool(ord(state.propagateNaturalHeight)))

adder add:
if widget.hasChild:
raise newException(ValueError, "Unable to add multiple children to a ScrolledWindow. Use a Box widget to display multiple widgets in a ScrolledWindow.")
Expand Down

0 comments on commit 68c1db0

Please sign in to comment.