Basic UI components

- Add first preliminary model of building and working with
  higher level components.
- Components for text input, path input, single selector and
  multi selector.
- Components renderings are based on ANTLR ST templates while
  there is support for building rendering output manually.
- Add these into sample.
- This is a base of additional work what goes to these components
  and concepts around it.
- Relates #360
This commit is contained in:
Janne Valkealahti
2022-02-04 12:44:23 +00:00
parent 65ff3820da
commit e3604a5bc5
28 changed files with 3432 additions and 1 deletions

View File

@@ -0,0 +1,64 @@
// used to select style if item is selected/unselected
selected_style(flag) ::= <%
<if(flag)>item-selected<else>item-unselected<endif>
%>
// selector rows
select_item(item) ::= <%
<if(item.onrow)>
<("> "); format="item-selector">
<else>
<(" ")>
<endif>
<if(item.enabled)>
<if(item.selected)>
<("[x]"); format=selected_style(item.selected)> <item.name>
<else>
<("[ ]"); format=selected_style(item.selected)> <item.name>
<endif>
<else>
<("[ ]"); format="item-disabled"> <item.name; format="item-disabled">
<endif>
%>
// start '? xxx' shows both running and result
question_name(model) ::= <<
<("?"); format="list-value"> <model.name; format="title">
>>
// within info section, dedicated instructions for user
info_filter(model) ::= <%
<if(model.input)>
, filtering '<model.input>'
<else>
, type to filter
<endif>
%>
// info section after '? xxx'
info(model) ::= <<
[Use arrows to move]<info_filter(model)>
>>
// get comma delited string
comma_delimited(values) ::= <%
<values; separator=",">
%>
// component result
result(model) ::= <<
<question_name(model)> <(comma_delimited(model.values)); format="value">
>>
// component is running
running(model) ::= <<
<question_name(model)> <info(model)>
<model.rows:{x|<select_item(x)>}; separator="\n">
>>
// main - hardcoded name
// model - model built by MultiItemSelectorContext
main(model) ::= <<
<if(model.isResult)><result(model)><else><running(model)><endif>
>>

View File

@@ -0,0 +1,38 @@
// message
message(model) ::= <%
<if(model.message && model.hasMessageLevelError)>
<(">>>"); format="level-error"> <model.message; format="level-error">
<elseif(model.message && model.hasMessageLevelWarn)>
<(">>"); format="level-warn"> <model.message; format="level-warn">
<elseif(model.message && model.hasMessageLevelInfo)>
<(">"); format="level-info"> <model.message; format="level-info">
<endif>
%>
// info section after '? xxx'
info(model) ::= <%
<if(model.input)>
<model.input>
<endif>
%>
// start '? xxx' shows both running and result
question_name(model) ::= <<
<("?"); format="list-value"> <model.name; format="title">
>>
// component result
result(model) ::= <<
<question_name(model)> <model.resultValue; format="value">
>>
// component is running
running(model) ::= <<
<question_name(model)> <info(model)>
<message(model)>
>>
// main
main(model) ::= <<
<if(model.resultValue)><result(model)><else><running(model)><endif>
>>

View File

@@ -0,0 +1,44 @@
// selector rows
select_item(item) ::= <%
<if(item.selected)>
<("> "); format="item-selector"><item.name; format="item-selector">
<else>
<(" ")><item.name>
<endif>
%>
// start '? xxx' shows both running and result
question_name(model) ::= <<
<("?"); format="list-value"> <model.name; format="title">
>>
// within info section, dedicated instructions for user
info_filter(model) ::= <%
<if(model.input)>
, filtering '<model.input>'
<else>
, type to filter
<endif>
%>
// info section after '? xxx'
info(model) ::= <<
[Use arrows to move]<info_filter(model)>
>>
// component result
result(model) ::= <<
<question_name(model)> <model.value; format="value">
>>
// component is running
running(model) ::= <<
<question_name(model)> <info(model)>
<model.rows:{x|<select_item(x)>}; separator="\n">
>>
// main - hardcoded name
// model - model built by SingleItemSelectorContext
main(model) ::= <<
<if(model.isResult)><result(model)><else><running(model)><endif>
>>

View File

@@ -0,0 +1,28 @@
// info section after '? xxx'
info(model) ::= <%
<if(model.input)>
<model.input>
<else>
<("[Default "); format="value"><model.defaultValue; format="value"><("]"); format="value">
<endif>
%>
// start '? xxx' shows both running and result
question_name(model) ::= <<
<("?"); format="list-value"> <model.name; format="title">
>>
// component result
result(model) ::= <<
<question_name(model)> <model.resultValue; format="value">
>>
// component is running
running(model) ::= <<
<question_name(model)> <info(model)>
>>
// main
main(model) ::= <<
<if(model.resultValue)><result(model)><else><running(model)><endif>
>>