Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Positive/negative" graph meter style #1415

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

Explorer09
Copy link
Contributor

This is a proof of concept of the graph style as discussed in #1390. I post this so that people can try it and see how it looks.

Notice this code is based on #714 -- the first few commit are the same, while the last one is the real modification of the new graph style.

@Explorer09 Explorer09 force-pushed the graph-with-neg branch 3 times, most recently from f47a975 to 745f394 Compare March 28, 2024 13:54
@BenBE BenBE added the new feature Completely new feature label Apr 13, 2024
@Explorer09 Explorer09 force-pushed the graph-with-neg branch 3 times, most recently from 31cb513 to bedca8f Compare April 21, 2024 06:39
@Explorer09 Explorer09 force-pushed the graph-with-neg branch 4 times, most recently from ade4922 to 54d3d1c Compare April 26, 2024 18:59
@Explorer09 Explorer09 force-pushed the graph-with-neg branch 3 times, most recently from 728ef87 to 3033b1d Compare May 2, 2024 21:01
@BenBE BenBE self-assigned this May 2, 2024
This property distinguishes meters that have a (relatively) fixed
"total" value and meters that do not have a definite maximum value.
The former meters would be drawn as a "100% stacked bar" or "graph", and
the latter would have their "total" values updated automatically in bar
meter mode.

This commit is a prerequisite for the "Graph meter dynamic scaling and
coloring" feature.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
If "isPercentChart" of a meter is false, update its "total" value
automatically. The "total" value should be finite in order to ensure the
division works.

The newly introduced Meter_computeSum() function will be reused by the
"Graph meter dynamic scaling and coloring" feature.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
This is a prerequisite for the "Graph meter dynamic scaling and
coloring" feature.

powerOf2Floor() will utilize __builtin_clz() or stdc_bit_floor_ui()
(__builtin_clz() is preferred) if either is supported.

popCount8() will utilize ARM NEON instructions and x86 POPCNT
instruction if the machine supports either of them.

I am not adopting the C23 standard interface stdc_count_ones_uc() yet,
as I am not sure C libraries would implement it as fast as our version.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Rewrite the entire graph meter drawing code to support dynamic scaling
and colors.

Dynamic scaling is used for meter classes with "isPercentChart" set to
false. The "total" of a graph meter will align to a power of 2 to ease
the management of internal data structures.

The colors of a graph are based on the percentages of item values of
the meter. The rounding differences of each terminal character are
addressed through the different numbers of braille dots.

Due to low resolution of the character terminal, the rasterized colors
may not look nice, but better than nothing. :)

The code is designed with the anticipation that the graph height may be
changeable at runtime. However no UI or option has been implemented for
that yet. The graph height has a limit of 8191 (terminal rows).

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Specifically 'PIXPERROW_*' and 'GraphMeterMode_dots*' constants.
They were commented out rather than removed in the previous commit (for
ease of code reviewing). Now this commit removes the constant defines
for good.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
This special case of "details" value would print as ':' in the ASCII
display mode. It is used in "positive/negative" graph display only.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Completely new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants