Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
flow3r firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flow3r
flow3r firmware
Commits
c43b8134
Commit
c43b8134
authored
1 year ago
by
moon2
Browse files
Options
Downloads
Patches
Plain Diff
gr33nhouse: add category subpages
parent
1f694a83
Branches
Branches containing commit
No related tags found
1 merge request
!699
gr33nhouse: add category subpages
Pipeline
#13010
passed
1 year ago
Stage: check
Stage: build
Stage: deploy
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
python_payload/apps/gr33nhouse/applist.py
+121
-20
121 additions, 20 deletions
python_payload/apps/gr33nhouse/applist.py
python_payload/apps/gr33nhouse/confirmation.py
+8
-7
8 additions, 7 deletions
python_payload/apps/gr33nhouse/confirmation.py
with
129 additions
and
27 deletions
python_payload/apps/gr33nhouse/applist.py
+
121
−
20
View file @
c43b8134
...
@@ -18,18 +18,19 @@ class ViewState(Enum):
...
@@ -18,18 +18,19 @@ class ViewState(Enum):
LOADED
=
4
LOADED
=
4
class
AppList
(
BaseView
):
class
App
Sub
List
(
BaseView
):
_scroll_pos
:
float
=
0.0
_scroll_pos
:
float
=
0.0
_state
:
ViewState
=
ViewState
.
INITIAL
apps
:
list
[
Any
]
=
[]
apps
:
list
[
Any
]
=
[]
background
:
Flow3rView
background
:
Flow3rView
def
__init__
(
self
)
->
None
:
def
__init__
(
self
,
apps
)
->
None
:
super
().
__init__
()
super
().
__init__
()
self
.
background
=
Flow3rView
()
self
.
background
=
Flow3rView
()
self
.
_sc
=
ScrollController
()
self
.
_sc
=
ScrollController
()
self
.
apps
=
apps
self
.
_sc
.
set_item_count
(
len
(
self
.
apps
))
def
on_exit
(
self
)
->
bool
:
def
on_exit
(
self
)
->
bool
:
# request thinks after on_exit
# request thinks after on_exit
...
@@ -38,6 +39,98 @@ class AppList(BaseView):
...
@@ -38,6 +39,98 @@ class AppList(BaseView):
def
draw
(
self
,
ctx
:
Context
)
->
None
:
def
draw
(
self
,
ctx
:
Context
)
->
None
:
ctx
.
move_to
(
0
,
0
)
ctx
.
move_to
(
0
,
0
)
self
.
background
.
draw
(
ctx
)
ctx
.
save
()
ctx
.
gray
(
1.0
)
ctx
.
rectangle
(
-
120.0
,
-
15.0
,
240.0
,
30.0
,
).
fill
()
ctx
.
translate
(
0
,
-
30
*
self
.
_sc
.
current_position
())
offset
=
0
ctx
.
font
=
"
Camp Font 3
"
ctx
.
font_size
=
24
ctx
.
text_align
=
ctx
.
CENTER
ctx
.
text_baseline
=
ctx
.
MIDDLE
ctx
.
move_to
(
0
,
0
)
for
idx
,
app
in
enumerate
(
self
.
apps
):
target
=
idx
==
self
.
_sc
.
target_position
()
if
target
:
ctx
.
gray
(
0.0
)
else
:
ctx
.
gray
(
1.0
)
if
abs
(
self
.
_sc
.
current_position
()
-
idx
)
<=
5
:
xpos
=
0.0
if
target
and
(
width
:
=
ctx
.
text_width
(
app
[
"
name
"
]))
>
220
:
xpos
=
sin
(
self
.
_scroll_pos
)
*
(
width
-
220
)
/
2
ctx
.
move_to
(
xpos
,
offset
)
ctx
.
text
(
app
[
"
name
"
])
offset
+=
30
ctx
.
restore
()
def
think
(
self
,
ins
:
InputState
,
delta_ms
:
int
)
->
None
:
super
().
think
(
ins
,
delta_ms
)
self
.
_sc
.
think
(
ins
,
delta_ms
)
self
.
background
.
think
(
ins
,
delta_ms
)
self
.
_scroll_pos
+=
delta_ms
/
1000
if
not
self
.
is_active
():
return
if
self
.
input
.
buttons
.
app
.
left
.
pressed
or
self
.
input
.
buttons
.
app
.
left
.
repeated
:
self
.
_sc
.
scroll_left
()
self
.
_scroll_pos
=
0.0
elif
(
self
.
input
.
buttons
.
app
.
right
.
pressed
or
self
.
input
.
buttons
.
app
.
right
.
repeated
):
self
.
_sc
.
scroll_right
()
self
.
_scroll_pos
=
0.0
elif
self
.
input
.
buttons
.
app
.
middle
.
pressed
:
if
self
.
vm
is
None
:
raise
RuntimeError
(
"
vm is None
"
)
app
=
self
.
apps
[
self
.
_sc
.
target_position
()]
url
=
app
[
"
tarDownloadUrl
"
]
name
=
app
[
"
name
"
]
author
=
app
[
"
author
"
]
self
.
vm
.
push
(
ConfirmationView
(
url
=
url
,
name
=
name
,
author
=
author
,
)
)
class
AppList
(
BaseView
):
_scroll_pos
:
float
=
0.0
_state
:
ViewState
=
ViewState
.
INITIAL
items
:
list
[
Any
]
=
[
"
All
"
]
category_order
:
list
[
Any
]
=
[
"
Badge
"
,
"
Music
"
,
"
Media
"
,
"
Apps
"
,
"
Games
"
]
background
:
Flow3rView
def
__init__
(
self
)
->
None
:
super
().
__init__
()
self
.
background
=
Flow3rView
()
self
.
_sc
=
ScrollController
()
self
.
_sc
.
set_item_count
(
len
(
self
.
items
))
def
draw
(
self
,
ctx
):
ctx
.
move_to
(
0
,
0
)
if
self
.
_state
==
ViewState
.
INITIAL
or
self
.
_state
==
ViewState
.
LOADING
:
if
self
.
_state
==
ViewState
.
INITIAL
or
self
.
_state
==
ViewState
.
LOADING
:
ctx
.
rgb
(
*
colours
.
BLACK
)
ctx
.
rgb
(
*
colours
.
BLACK
)
ctx
.
rectangle
(
ctx
.
rectangle
(
...
@@ -78,6 +171,8 @@ class AppList(BaseView):
...
@@ -78,6 +171,8 @@ class AppList(BaseView):
return
return
elif
self
.
_state
==
ViewState
.
LOADED
:
elif
self
.
_state
==
ViewState
.
LOADED
:
ctx
.
move_to
(
0
,
0
)
self
.
background
.
draw
(
ctx
)
self
.
background
.
draw
(
ctx
)
ctx
.
save
()
ctx
.
save
()
...
@@ -90,7 +185,6 @@ class AppList(BaseView):
...
@@ -90,7 +185,6 @@ class AppList(BaseView):
).
fill
()
).
fill
()
ctx
.
translate
(
0
,
-
30
*
self
.
_sc
.
current_position
())
ctx
.
translate
(
0
,
-
30
*
self
.
_sc
.
current_position
())
offset
=
0
offset
=
0
ctx
.
font
=
"
Camp Font 3
"
ctx
.
font
=
"
Camp Font 3
"
...
@@ -99,7 +193,7 @@ class AppList(BaseView):
...
@@ -99,7 +193,7 @@ class AppList(BaseView):
ctx
.
text_baseline
=
ctx
.
MIDDLE
ctx
.
text_baseline
=
ctx
.
MIDDLE
ctx
.
move_to
(
0
,
0
)
ctx
.
move_to
(
0
,
0
)
for
idx
,
app
in
enumerate
(
self
.
app
s
):
for
idx
,
item
in
enumerate
(
self
.
item
s
):
target
=
idx
==
self
.
_sc
.
target_position
()
target
=
idx
==
self
.
_sc
.
target_position
()
if
target
:
if
target
:
ctx
.
gray
(
0.0
)
ctx
.
gray
(
0.0
)
...
@@ -108,10 +202,10 @@ class AppList(BaseView):
...
@@ -108,10 +202,10 @@ class AppList(BaseView):
if
abs
(
self
.
_sc
.
current_position
()
-
idx
)
<=
5
:
if
abs
(
self
.
_sc
.
current_position
()
-
idx
)
<=
5
:
xpos
=
0.0
xpos
=
0.0
if
target
and
(
width
:
=
ctx
.
text_width
(
app
[
"
name
"
]
))
>
220
:
if
target
and
(
width
:
=
ctx
.
text_width
(
item
))
>
220
:
xpos
=
sin
(
self
.
_scroll_pos
)
*
(
width
-
220
)
/
2
xpos
=
sin
(
self
.
_scroll_pos
)
*
(
width
-
220
)
/
2
ctx
.
move_to
(
xpos
,
offset
)
ctx
.
move_to
(
xpos
,
offset
)
ctx
.
text
(
app
[
"
name
"
]
)
ctx
.
text
(
item
)
offset
+=
30
offset
+=
30
ctx
.
restore
()
ctx
.
restore
()
...
@@ -136,8 +230,21 @@ class AppList(BaseView):
...
@@ -136,8 +230,21 @@ class AppList(BaseView):
self
.
_state
=
ViewState
.
ERROR
self
.
_state
=
ViewState
.
ERROR
return
return
categories
=
[
app
.
get
(
"
menu
"
)
for
app
in
self
.
apps
]
categories
=
[
c
for
c
in
categories
if
c
and
isinstance
(
c
,
str
)]
categories
=
list
(
set
(
categories
))
def
sortkey
(
obj
):
try
:
return
self
.
category_order
.
index
(
obj
)
except
ValueError
:
return
len
(
self
.
category_order
)
categories
.
sort
(
key
=
sortkey
)
self
.
items
=
[
"
All
"
]
+
categories
self
.
_sc
.
set_item_count
(
len
(
self
.
items
))
self
.
_state
=
ViewState
.
LOADED
self
.
_state
=
ViewState
.
LOADED
self
.
_sc
.
set_item_count
(
len
(
self
.
apps
))
print
(
"
App list loaded
"
)
print
(
"
App list loaded
"
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
f
"
Load failed:
{
e
}
"
)
print
(
f
"
Load failed:
{
e
}
"
)
...
@@ -166,15 +273,9 @@ class AppList(BaseView):
...
@@ -166,15 +273,9 @@ class AppList(BaseView):
elif
self
.
input
.
buttons
.
app
.
middle
.
pressed
:
elif
self
.
input
.
buttons
.
app
.
middle
.
pressed
:
if
self
.
vm
is
None
:
if
self
.
vm
is
None
:
raise
RuntimeError
(
"
vm is None
"
)
raise
RuntimeError
(
"
vm is None
"
)
if
self
.
_sc
.
target_position
():
app
=
self
.
apps
[
self
.
_sc
.
target_position
()]
category
=
self
.
items
[
self
.
_sc
.
target_position
()]
url
=
app
[
"
tarDownloadUrl
"
]
apps
=
[
app
for
app
in
self
.
apps
if
app
.
get
(
"
menu
"
)
==
category
]
name
=
app
[
"
name
"
]
else
:
author
=
app
[
"
author
"
]
apps
=
list
(
self
.
apps
)
self
.
vm
.
push
(
self
.
vm
.
push
(
AppSubList
(
apps
=
apps
))
ConfirmationView
(
url
=
url
,
name
=
name
,
author
=
author
,
)
)
This diff is collapsed.
Click to expand it.
python_payload/apps/gr33nhouse/confirmation.py
+
8
−
7
View file @
c43b8134
...
@@ -52,6 +52,7 @@ class ConfirmationView(BaseView):
...
@@ -52,6 +52,7 @@ class ConfirmationView(BaseView):
ctx
.
move_to
(
0
,
-
30
)
ctx
.
move_to
(
0
,
-
30
)
ctx
.
text
(
self
.
name
)
ctx
.
text
(
self
.
name
)
if
self
.
author
:
ctx
.
font_size
=
16
ctx
.
font_size
=
16
ctx
.
move_to
(
0
,
0
)
ctx
.
move_to
(
0
,
0
)
ctx
.
text
(
"
by
"
)
ctx
.
text
(
"
by
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment