From 795855806525f7b16475f480a8ac26642bcdd0b6 Mon Sep 17 00:00:00 2001 From: Philipp Doerner Date: Fri, 29 Sep 2023 16:48:35 +0200 Subject: [PATCH] #83 Make orientation configurable --- examples/widgets/scale.nim | 6 ++++++ owlkettle/widgets.nim | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/widgets/scale.nim b/examples/widgets/scale.nim index 013c783c..fb762a03 100644 --- a/examples/widgets/scale.nim +++ b/examples/widgets/scale.nim @@ -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: @@ -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), @@ -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 diff --git a/owlkettle/widgets.nim b/owlkettle/widgets.nim index 602542e4..eac5f306 100644 --- a/owlkettle/widgets.nim +++ b/owlkettle/widgets.nim @@ -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