-
Notifications
You must be signed in to change notification settings - Fork 200
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
Added new slider widget to devel/hello-world
#1363
base: master
Are you sure you want to change the base?
Changes from all commits
1b79147
9d68aca
bbac6c4
81e5179
735f5d5
9055dc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,13 +12,23 @@ local HIGHLIGHT_PEN = dfhack.pen.parse{ | |
|
||
HelloWorldWindow = defclass(HelloWorldWindow, widgets.Window) | ||
HelloWorldWindow.ATTRS{ | ||
frame={w=20, h=14}, | ||
frame={w=25, h=25}, | ||
frame_title='Hello World', | ||
autoarrange_subviews=true, | ||
autoarrange_gap=1, | ||
autoarrange_gap=2, | ||
resizable=true, | ||
resize_min={w=25, h=20}, | ||
} | ||
|
||
function HelloWorldWindow:init() | ||
local LEVEL_OPTIONS = { | ||
{label='Low', value=1}, | ||
{label='Medium', value=2}, | ||
{label='High', value=3}, | ||
{label='Pro', value=4}, | ||
{label='Insane', value=5}, | ||
} | ||
|
||
self:addviews{ | ||
widgets.Label{text={{text='Hello, world!', pen=COLOR_LIGHTGREEN}}}, | ||
widgets.HotkeyLabel{ | ||
|
@@ -32,6 +42,30 @@ function HelloWorldWindow:init() | |
frame={w=10, h=5}, | ||
frame_style=gui.INTERIOR_FRAME, | ||
}, | ||
widgets.Divider{ | ||
frame={l=0,t=3} | ||
}, | ||
widgets.CycleHotkeyLabel{ | ||
view_id='level', | ||
frame={l=0, t=3, w=16}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. setting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. however, since 2 lines is way too many to put between the CycleHotkeyLabel and the Slider widget, maybe create a containing Panel that does not have autolayout properties. |
||
label='Level:', | ||
label_below=true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for a non-range slider, I think |
||
key_back='CUSTOM_SHIFT_C', | ||
key='CUSTOM_SHIFT_V', | ||
options=LEVEL_OPTIONS, | ||
initial_option=LEVEL_OPTIONS[1].value, | ||
on_change=function(val) | ||
self.subviews.level:setOption(val) | ||
end, | ||
Comment on lines
+57
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this widget should not be setting its own state in its own callback |
||
}, | ||
widgets.Slider{ | ||
frame={l=1, t=3}, | ||
num_stops=#LEVEL_OPTIONS, | ||
get_idx_fn=function() | ||
return self.subviews.level:getOptionValue() | ||
end, | ||
on_change=function(idx) self.subviews.level:setOption(idx) end, | ||
}, | ||
} | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please set the properties to make it a flat divider instead of a connected divider: