custom EditField & reorganized panels

develop
Taxi Service 2023-04-04 17:38:38 +02:00
parent ea9f3ef9d1
commit aa8870fcad
1 changed files with 134 additions and 103 deletions

@ -81,6 +81,10 @@ function ItemSelection:init()
end end
self:addviews{ self:addviews{
widgets.Panel{
view_id='header',
frame={t=0, h=3},
subviews={
widgets.Label{ widgets.Label{
frame={t=0, l=0, r=16}, frame={t=0, l=0, r=16},
text={ text={
@ -114,8 +118,23 @@ function ItemSelection:init()
on_click=self:callback('submit'), on_click=self:callback('submit'),
visible=function() return self.num_selected >= self.quantity end, visible=function() return self.num_selected >= self.quantity end,
}, },
},
},
}
self:addviews{
widgets.Panel{
view_id='body',
frame={t=self.subviews.header.frame.h, b=4},
subviews={
widgets.EditField{
view_id='search',
frame={l=1, t=0},
label_text='Search: ',
on_char=function(ch) return ch:match('[%l -]') end,
},
widgets.CycleHotkeyLabel{ widgets.CycleHotkeyLabel{
frame={l=1, t=3}, frame={l=1, t=2},
key='CUSTOM_SHIFT_R', key='CUSTOM_SHIFT_R',
label='Sort by:', label='Sort by:',
options={ options={
@ -125,72 +144,84 @@ function ItemSelection:init()
}, },
on_change=self:callback('on_sort'), on_change=self:callback('on_sort'),
}, },
widgets.Panel{
frame={l=0, t=3, r=0, b=0},
frame_style=gui.INTERIOR_FRAME,
subviews={
widgets.FilteredList{ widgets.FilteredList{
view_id='flist', view_id='flist',
frame={t=5, l=1, r=1, b=5}, frame={t=0, b=0},
case_sensitive=false, case_sensitive=false,
choices=choices, choices=choices,
icon_width=2, icon_width=2,
on_submit=self:callback('toggle_group'), on_submit=self:callback('toggle_group'),
edit_on_char=function(ch) return ch:match('[%l -]') end,
}, },
widgets.Label{
frame={l=1, t=5},
text_pen=COLOR_LIGHTCYAN,
text={">"},
}, },
widgets.Panel{
frame={l=0, t=6, r=0, b=4},
frame_style=gui.INTERIOR_FRAME,
}, },
},
},
widgets.Panel{
view_id='footer',
frame={l=1, r=1, b=0, h=3},
subviews={
--[[
add an explanation for this terribleness
--]]
widgets.HotkeyLabel{ widgets.HotkeyLabel{
frame={l=0, b=2}, frame={l=0, h=1, t=0},
key='KEYBOARD_CURSOR_RIGHT_FAST', key='KEYBOARD_CURSOR_RIGHT_FAST',
key_sep='ight: ', key_sep='----: ', --these hypens are overwritten by the next Label
label='Use one', label='Use one',
auto_width=true, auto_width=true,
on_activate=function() self:increment_group(self.subviews.flist.list:getSelected()) end, on_activate=function() self:increment_group(self.subviews.flist.list:getSelected()) end,
}, },
widgets.Label{ widgets.Label{
frame={l=6, b=2, w=5}, frame={l=6, w=5, t=0},
text_pen=COLOR_LIGHTGREEN, text_pen=COLOR_LIGHTGREEN,
text='Right', text='Right',
}, },
widgets.HotkeyLabel{ widgets.HotkeyLabel{
frame={l=1, b=1}, frame={l=1, h=1, t=1},
key='KEYBOARD_CURSOR_LEFT_FAST', key='KEYBOARD_CURSOR_LEFT_FAST',
key_sep='eft: ', key_sep='---: ', --these hypens are overwritten by the next Label
label='Use one fewer', label='Use one fewer',
auto_width=true, auto_width=true,
on_activate=function() self:decrement_group(self.subviews.flist.list:getSelected()) end, on_activate=function() self:decrement_group(self.subviews.flist.list:getSelected()) end,
}, },
widgets.Label{ widgets.Label{
frame={l=7, b=1, w=4}, frame={l=7, w=4, t=1},
text_pen=COLOR_LIGHTGREEN, text_pen=COLOR_LIGHTGREEN,
text='Left', text='Left',
}, },
widgets.HotkeyLabel{ widgets.HotkeyLabel{
frame={l=6, b=0}, frame={l=6, t=2, h=2},
key='SELECT', key='SELECT',
label='Use all/none', label='Use all/none',
auto_width=true, auto_width=true,
on_activate=function() self:toggle_group(self.subviews.flist.list:getSelected()) end, on_activate=function() self:toggle_group(self.subviews.flist.list:getSelected()) end,
}, },
widgets.HotkeyLabel{ widgets.HotkeyLabel{
frame={r=5, b=2}, frame={r=5, t=0},
key='LEAVESCREEN', key='LEAVESCREEN',
label='Go back', label='Go back',
auto_width=true, auto_width=true,
on_activate=self:callback('on_cancel'), on_activate=self:callback('on_cancel'),
}, },
widgets.HotkeyLabel{ widgets.HotkeyLabel{
frame={r=4, b=0}, frame={r=4, t=2},
key='CUSTOM_SHIFT_C', key='CUSTOM_SHIFT_C',
label='Continue', label='Continue',
auto_width=true, auto_width=true,
on_activate=self:callback('submit'), on_activate=self:callback('submit'),
}, },
},
},
} }
self.subviews.flist.list.frame.t = 0
self.subviews.flist.edit.visible = false
self.subviews.flist.edit = self.subviews.search
self.subviews.search.on_change = self.subviews.flist:callback('onFilterChange')
end end
-- resort and restore selection -- resort and restore selection