Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FTXUI
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
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Will2.Mcgregor@live.uwe.ac.uk
FTXUI
Commits
8d166502
Unverified
Commit
8d166502
authored
1 year ago
by
Arthur Sonzogni
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
List ftxui_CPUMeter (#744)
parent
e5978a8e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+1
-0
1 addition, 0 deletions
README.md
examples/component/button.cpp
+33
-10
33 additions, 10 deletions
examples/component/button.cpp
with
34 additions
and
10 deletions
README.md
+
1
−
0
View file @
8d166502
...
...
@@ -325,6 +325,7 @@ Feel free to add your projects here:
-
[
eCAL monitor
](
https://github.com/eclipse-ecal/ecal
)
-
[
Path Finder
](
https://github.com/Ruebled/Path_Finder
)
-
[
rw-tui
](
https://github.com/LeeKyuHyuk/rw-tui
)
-
[
ftxui_CPUMeter
](
https://github.com/tzzzzzzzx/ftxui_CPUMeter
)
### [cpp-best-practices/game_jam](https://github.com/cpp-best-practices/game_jam)
...
...
This diff is collapsed.
Click to expand it.
examples/component/button.cpp
+
33
−
10
View file @
8d166502
...
...
@@ -12,13 +12,39 @@
using
namespace
ftxui
;
// This is a helper function to create a button with a custom style.
// The style is defined by a lambda function that takes an EntryState and
// returns an Element.
// We are using `center` to center the text inside the button, then `border` to
// add a border around the button, and finally `flex` to make the button fill
// the available space.
ButtonOption
ButtonStyle
()
{
auto
option
=
ButtonOption
::
Animated
();
option
.
transform
=
[](
const
EntryState
&
s
)
{
auto
element
=
text
(
s
.
label
);
if
(
s
.
focused
)
{
element
|=
bold
;
}
return
element
|
center
|
borderEmpty
|
flex
;
};
return
option
;
}
int
main
()
{
int
value
=
50
;
// The tree of components. This defines how to navigate using the keyboard.
auto
buttons
=
Container
::
Horizontal
({
Button
(
"Decrease"
,
[
&
]
{
value
--
;
}),
Button
(
"Increase"
,
[
&
]
{
value
++
;
}),
auto
buttons
=
Container
::
Vertical
({
Container
::
Horizontal
({
Button
(
"-1"
,
[
&
]
{
value
--
;
},
ButtonStyle
()),
Button
(
"+1"
,
[
&
]
{
value
++
;
},
ButtonStyle
()),
})
|
flex
,
Container
::
Horizontal
({
Button
(
"-10"
,
[
&
]
{
value
-=
10
;
},
ButtonStyle
()),
Button
(
"-10"
,
[
&
]
{
value
+=
10
;
},
ButtonStyle
()),
})
|
flex
,
});
// Modify the way to render them on screen:
...
...
@@ -26,14 +52,11 @@ int main() {
return
vbox
({
text
(
"value = "
+
std
::
to_string
(
value
)),
separator
(),
gauge
(
value
*
0.01
f
),
separator
(),
buttons
->
Render
(),
})
|
border
;
buttons
->
Render
()
|
flex
,
})
|
flex
|
border
;
});
auto
screen
=
ScreenInteractive
::
F
itCompon
en
t
();
auto
screen
=
ScreenInteractive
::
F
ullscre
en
();
screen
.
Loop
(
component
);
return
0
;
}
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