Skip to content

Commit

Permalink
can-lehmann#83 Make orientation configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippMDoerner committed Sep 29, 2023
1 parent 20bca37 commit 7958558
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions examples/widgets/scale.nim
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ viewable App:
value: float64 = 100.0
invertScale: bool = false
pos: ScalePosition = ScaleLeft
orient: Orient = OrientX

method view(app: AppState): Widget =
result = gui:
Expand All @@ -39,6 +40,7 @@ method view(app: AppState): Widget =
inverted = app.invertScale
showFillLevel = true
precision = 0
orient = app.orient
marks = @[
(some "left", 25, app.pos),
(some "right", 50, ScaleRight),
Expand All @@ -53,6 +55,10 @@ method view(app: AppState): Widget =

Button:
proc clicked() =
app.orient = case app.orient
of OrientX: OrientY
of OrientY: OrientX

# app.invertScale = not app.invertScale
app.pos = case app.pos:
of ScaleTop: ScaleRight
Expand Down
5 changes: 4 additions & 1 deletion owlkettle/widgets.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3498,9 +3498,12 @@ renderable Scale of BaseWidget:

hooks valuePosition:
property:
echo "Update value position ", state.valuePosition
state.internalWidget.gtk_scale_set_value_pos(state.valuePosition.toGtk())

hooks orient:
property:
state.internalWidget.gtk_orientable_set_orientation(state.orient.toGtk())

export BaseWidget, BaseWidgetState, BaseWindow, BaseWindowState
export Window, Box, Overlay, Label, Icon, Picture, Button, HeaderBar, ScrolledWindow, Entry, Spinner
export SpinButton, Paned, ColorButton, Switch, LinkButton, ToggleButton, CheckButton, RadioGroup
Expand Down

0 comments on commit 7958558

Please sign in to comment.