#307 fixes and cleanup
This commit is contained in:
@@ -118,11 +118,8 @@ local function app_button(args)
|
||||
|
||||
-- element redraw
|
||||
function e.redraw()
|
||||
-- write app title, centered
|
||||
e.w_set_cur(math.floor((e.frame.w - string.len(args.title)) / 2) + 1, 4)
|
||||
e.w_write(args.title)
|
||||
|
||||
-- draw button
|
||||
draw()
|
||||
end
|
||||
|
||||
|
||||
@@ -188,11 +188,9 @@ local function radio_2d_button(args)
|
||||
end
|
||||
end
|
||||
|
||||
-- handle focus
|
||||
-- handle focus & enable
|
||||
e.on_focused = e.redraw
|
||||
e.on_unfocused = e.redraw
|
||||
|
||||
-- handle enable
|
||||
e.on_enabled = e.redraw
|
||||
e.on_disabled = e.redraw
|
||||
|
||||
|
||||
@@ -132,11 +132,9 @@ local function radio_button(args)
|
||||
end
|
||||
end
|
||||
|
||||
-- handle focus
|
||||
-- handle focus & enable
|
||||
e.on_focused = e.redraw
|
||||
e.on_unfocused = e.redraw
|
||||
|
||||
-- handle enable
|
||||
e.on_enabled = e.redraw
|
||||
e.on_disabled = e.redraw
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ local function number_field(args)
|
||||
-- only handle if on an increment or decrement arrow
|
||||
if e.enabled then
|
||||
if core.events.was_clicked(event.type) then
|
||||
e.req_focus()
|
||||
e.take_focus()
|
||||
|
||||
if event.type == MOUSE_CLICK.UP then
|
||||
ifield.move_cursor(event.current.x)
|
||||
|
||||
@@ -43,7 +43,7 @@ local function text_field(args)
|
||||
-- only handle if on an increment or decrement arrow
|
||||
if e.enabled then
|
||||
if core.events.was_clicked(event.type) then
|
||||
e.req_focus()
|
||||
e.take_focus()
|
||||
|
||||
if event.type == MOUSE_CLICK.UP then
|
||||
ifield.move_cursor(event.current.x)
|
||||
|
||||
@@ -23,7 +23,7 @@ local element = require("graphics.element")
|
||||
---@param args power_indicator_args
|
||||
---@return graphics_element element, element_id id
|
||||
local function power(args)
|
||||
element.assert(type(args.value) == "number", "value is a required number field")
|
||||
element.assert(type(args.value) == "number", "value is a required field")
|
||||
element.assert(util.is_int(args.width), "width is a required field")
|
||||
|
||||
args.height = 1
|
||||
|
||||
@@ -33,7 +33,7 @@ local function rad(args)
|
||||
-- create new graphics element base object
|
||||
local e = element.new(args)
|
||||
|
||||
e.value = types.new_zero_radiation_reading()
|
||||
e.value = args.value or types.new_zero_radiation_reading()
|
||||
|
||||
local label_len = string.len(args.label)
|
||||
local data_start = 1
|
||||
|
||||
@@ -278,12 +278,6 @@ local function listbox(args)
|
||||
function e.redraw()
|
||||
draw_arrows(0)
|
||||
draw_bar()
|
||||
|
||||
-- redraw all children
|
||||
for i = 1, #list do
|
||||
local item = list[i] ---@type listbox_item
|
||||
item.e.redraw()
|
||||
end
|
||||
end
|
||||
|
||||
-- initial draw
|
||||
|
||||
Reference in New Issue
Block a user