Skip to content

Commit b3d2aeb

Browse files
committed
Introduce isPercentChart member in MeterClass
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 could have their "total" values updated automatically in bar meter mode. This commit is a prerequisite for the feature "Graph meter dynamic scaling and percent graph drawing". Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
1 parent 7d59e04 commit b3d2aeb

16 files changed

Lines changed: 28 additions & 0 deletions

BatteryMeter.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const MeterClass BatteryMeter_class = {
6464
.defaultMode = TEXT_METERMODE,
6565
.supportedModes = METERMODE_DEFAULT_SUPPORTED,
6666
.maxItems = 1,
67+
.isPercentChart = true,
6768
.total = 100.0,
6869
.attributes = BatteryMeter_attributes,
6970
.name = "Battery",

CPUMeter.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ const MeterClass CPUMeter_class = {
352352
.defaultMode = BAR_METERMODE,
353353
.supportedModes = METERMODE_DEFAULT_SUPPORTED,
354354
.maxItems = CPU_METER_ITEMCOUNT,
355+
.isPercentChart = true,
355356
.total = 100.0,
356357
.attributes = CPUMeter_attributes,
357358
.name = "CPU",

DiskIOMeter.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ const MeterClass DiskIOMeter_class = {
158158
.defaultMode = TEXT_METERMODE,
159159
.supportedModes = METERMODE_DEFAULT_SUPPORTED,
160160
.maxItems = 1,
161+
.isPercentChart = true,
161162
.total = 1.0,
162163
.attributes = DiskIOMeter_attributes,
163164
.name = "DiskIO",

FileDescriptorMeter.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ const MeterClass FileDescriptorMeter_class = {
110110
.defaultMode = TEXT_METERMODE,
111111
.supportedModes = METERMODE_DEFAULT_SUPPORTED,
112112
.maxItems = 2,
113+
.isPercentChart = false,
113114
.total = 65536.0,
114115
.attributes = FileDescriptorMeter_attributes,
115116
.name = "FileDescriptors",

GPUMeter.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ const MeterClass GPUMeter_class = {
156156
.defaultMode = BAR_METERMODE,
157157
.supportedModes = METERMODE_DEFAULT_SUPPORTED,
158158
.maxItems = ARRAYSIZE(GPUMeter_attributes),
159+
.isPercentChart = true,
159160
.total = 100.0,
160161
.attributes = GPUMeter_attributes,
161162
.name = "GPU",

LoadAverageMeter.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ const MeterClass LoadAverageMeter_class = {
111111
.defaultMode = TEXT_METERMODE,
112112
.supportedModes = METERMODE_DEFAULT_SUPPORTED,
113113
.maxItems = 3,
114+
.isPercentChart = false,
114115
.total = 100.0,
115116
.attributes = LoadAverageMeter_attributes,
116117
.name = "LoadAverage",
@@ -129,6 +130,7 @@ const MeterClass LoadMeter_class = {
129130
.defaultMode = TEXT_METERMODE,
130131
.supportedModes = METERMODE_DEFAULT_SUPPORTED,
131132
.maxItems = 1,
133+
.isPercentChart = false,
132134
.total = 100.0,
133135
.attributes = LoadMeter_attributes,
134136
.name = "Load",

MemoryMeter.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ const MeterClass MemoryMeter_class = {
117117
.defaultMode = BAR_METERMODE,
118118
.supportedModes = METERMODE_DEFAULT_SUPPORTED,
119119
.maxItems = MEMORY_METER_ITEMCOUNT,
120+
.isPercentChart = true,
120121
.total = 100.0,
121122
.attributes = MemoryMeter_attributes,
122123
.name = "Memory",

Meter.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ typedef struct MeterClass_ {
7575
const char* const description; /* optional meter description in header setup menu */
7676
const uint8_t maxItems;
7777
const bool isMultiColumn; /* whether the meter draws multiple sub-columns (defaults to false) */
78+
79+
/* Specifies how the meter is rendered in bar or graph mode:
80+
true: a percent bar or graph with 'total' representing 100% or maximum.
81+
false: the meter has no definite maximum; 'total' repesents initial
82+
maximum value while actual maximum is updated automatically. */
83+
const bool isPercentChart;
7884
} MeterClass;
7985

8086
#define As_Meter(this_) ((const MeterClass*)((this_)->super.klass))
@@ -95,6 +101,7 @@ typedef struct MeterClass_ {
95101
#define Meter_name(this_) As_Meter(this_)->name
96102
#define Meter_uiName(this_) As_Meter(this_)->uiName
97103
#define Meter_isMultiColumn(this_) As_Meter(this_)->isMultiColumn
104+
#define Meter_isPercentChart(this_) As_Meter(this_)->isPercentChart
98105

99106
typedef struct GraphData_ {
100107
struct timeval time;

NetworkIOMeter.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ const MeterClass NetworkIOMeter_class = {
171171
.defaultMode = TEXT_METERMODE,
172172
.supportedModes = METERMODE_DEFAULT_SUPPORTED,
173173
.maxItems = 2,
174+
.isPercentChart = false,
174175
.total = 100.0,
175176
.attributes = NetworkIOMeter_attributes,
176177
.name = "NetworkIO",

SwapMeter.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const MeterClass SwapMeter_class = {
7575
.defaultMode = BAR_METERMODE,
7676
.supportedModes = METERMODE_DEFAULT_SUPPORTED,
7777
.maxItems = SWAP_METER_ITEMCOUNT,
78+
.isPercentChart = true,
7879
.total = 100.0,
7980
.attributes = SwapMeter_attributes,
8081
.name = "Swap",

0 commit comments

Comments
 (0)