Skip to content

Commit 40938c5

Browse files
committed
options for text size / color in graphs
1 parent 1d0eab5 commit 40938c5

File tree

6 files changed

+98
-21
lines changed

6 files changed

+98
-21
lines changed

IntelPresentMon/AppCef/Web/src/core/graph.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (C) 2022 Intel Corporation
22
// SPDX-License-Identifier: MIT
33
import { RgbaColor } from "./color"
4+
import { compareVersions } from "./signature";
45
import { Widget, WidgetType, GenerateKey } from './widget'
56
import { makeDefaultWidgetMetric } from "./widget-metric";
67

@@ -23,6 +24,8 @@ export interface Graph extends Widget {
2324
dividerColor: RgbaColor;
2425
backgroundColor: RgbaColor;
2526
borderColor: RgbaColor;
27+
textColor: RgbaColor;
28+
textSize: number;
2629
}
2730

2831
export function makeDefaultGraph(metricId: number): Graph {
@@ -68,8 +71,39 @@ export function makeDefaultGraph(metricId: number): Graph {
6871
b: 0,
6972
a: 0,
7073
},
74+
textColor: {
75+
r: 242,
76+
g: 242,
77+
b: 242,
78+
a: 1.0,
79+
},
80+
textSize: 11,
7181
};
7282
}
7383

84+
85+
interface Migration {
86+
version: string;
87+
migrate: (graph: Graph) => void;
88+
}
89+
90+
const migrations: Migration[] = [
91+
{
92+
version: '0.11.0',
93+
migrate: (graph: Graph) => {
94+
const def = makeDefaultGraph(0);
95+
graph.textColor = def.textColor;
96+
graph.textSize = def.textSize;
97+
}
98+
},
99+
];
100+
101+
migrations.sort((a, b) => compareVersions(a.version, b.version));
102+
74103
export function migrateGraph(graph: Graph, sourceVersion: string): void {
104+
for (const mig of migrations) {
105+
if (compareVersions(mig.version, sourceVersion) > 0) {
106+
mig.migrate(graph);
107+
}
108+
}
75109
}

IntelPresentMon/AppCef/Web/src/core/loadout.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ export interface LoadoutFile {
1010

1111
export const signature: Signature = {
1212
code: "p2c-cap-load",
13-
version: "0.10.0",
13+
version: "0.11.0",
1414
};

IntelPresentMon/AppCef/Web/src/core/preferences.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ export interface Preferences {
4646
readonly overlayBackgroundColor: RgbaColor;
4747
readonly graphFont: {
4848
readonly name: 'Verdana';
49-
readonly color: RgbaColor;
50-
readonly titleSize: 11.0;
5149
readonly axisSize: 10.0;
52-
readonly valueSize: 10.0;
5350
};
5451
adapterId:number|null;
5552
};
@@ -92,15 +89,7 @@ export function makeDefaultPreferences(): Preferences {
9289
},
9390
graphFont: {
9491
name: 'Verdana',
95-
color: {
96-
r: 242,
97-
g: 242,
98-
b: 242,
99-
a: 1.0,
100-
},
101-
titleSize: 11.0,
10292
axisSize: 10.0,
103-
valueSize: 10.0,
10493
},
10594
overlayWidth: 400,
10695
upscale: false,

IntelPresentMon/AppCef/Web/src/views/GraphConfigView.vue

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,22 @@
249249
></v-slider>
250250
</v-col>
251251
</v-row>
252+
253+
<v-row class="mt-8">
254+
<v-col cols="3">
255+
Font Size
256+
<p class="text--secondary text-sm-caption mb-0">Size of text in this readout widget</p>
257+
</v-col>
258+
<v-col cols="9">
259+
<v-slider
260+
v-model="textSize"
261+
:min="5"
262+
:max="80"
263+
:step="0.5"
264+
thumb-label="always"
265+
></v-slider>
266+
</v-col>
267+
</v-row>
252268

253269
<v-row class="mt-8">
254270
<v-col cols="3">
@@ -257,12 +273,15 @@
257273
</v-col>
258274
<v-col cols="9">
259275
<v-row dense>
260-
<v-col cols="6">
276+
<v-col cols="4">
261277
<color-picker v-model="gridColor" class="color-picker" label="Grid"></color-picker>
262278
</v-col>
263-
<v-col cols="6">
279+
<v-col cols="4">
264280
<color-picker v-model="backgroundColor" class="color-picker" label="Background"></color-picker>
265281
</v-col>
282+
<v-col cols="4">
283+
<color-picker v-model="textColor" class="color-picker" label="Text"></color-picker>
284+
</v-col>
266285
</v-row>
267286
</v-col>
268287
</v-row>
@@ -408,6 +427,18 @@ export default Vue.extend({
408427
Loadout.setGraphAttribute({ index: this.index, attr: 'borderColor', val: borderColor });
409428
},
410429
},
430+
textColor: {
431+
get(): RgbaColor { return this.graph.textColor; },
432+
set(textColor: RgbaColor) {
433+
Loadout.setGraphAttribute({ index: this.index, attr: 'textColor', val: textColor });
434+
},
435+
},
436+
textSize: {
437+
get(): number { return this.graph.textSize; },
438+
set(textSize: number) {
439+
Loadout.setGraphAttribute({ index: this.index, attr: 'textSize', val: textSize });
440+
},
441+
},
411442
},
412443
watch: {
413444
widgetTypeName(type: string, oldType: string) {

IntelPresentMon/AppCef/Web/src/views/ReadoutConfigView.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@
1212
<v-card class="page-card my-7">
1313
<v-subheader class="mt-0">Style Settings</v-subheader>
1414
<v-divider class="ma-0"></v-divider>
15+
16+
<v-row class="mt-8">
17+
<v-col cols="3">
18+
Font Size
19+
<p class="text--secondary text-sm-caption mb-0">Size of text in this readout widget</p>
20+
</v-col>
21+
<v-col cols="9">
22+
<v-slider
23+
v-model="fontSize"
24+
:min="5"
25+
:max="80"
26+
:step="0.5"
27+
thumb-label="always"
28+
></v-slider>
29+
</v-col>
30+
</v-row>
1531

1632
<v-row class="mt-8">
1733
<v-col cols="3">

IntelPresentMon/AppCef/source/util/MakeOverlaySpec.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,29 +101,22 @@ namespace p2c::client::util
101101
sheets.back()->InsertRaw<at::borderTop>(graphBorder);
102102
sheets.back()->InsertRaw<at::borderRight>(graphBorder);
103103
sheets.back()->InsertRaw<at::borderBottom>(graphBorder);
104-
sheets.back()->InsertRaw<at::textColor>(at::make::Color(ColorFromV8(traversedPref["graphFont"]["color"])));
105104
sheets.back()->InsertRaw<at::textFont>(traversedPref["graphFont"]["name"].AsWString());
106105
sheets.back()->InsertRaw<at::graphLineColor>(at::make::Color(Color::FromBytes(100, 255, 255, 220)));
107106
sheets.back()->InsertRaw<at::graphFillColor>(at::make::Color(Color::FromBytes(57, 210, 210, 25)));
108107
// TODO: clarify, consider which plot attributes apply to which sub-elements
109108
sheets.back()->InsertRaw<at::graphTimeWindow>((double)traversedPref["timeRange"]);
110109

111-
sheets.push_back(Stylesheet::Make({ {"$graph"}, {"$label"} }));
112-
sheets.back()->InsertRaw<at::textSize>((double)traversedPref["graphFont"]["titleSize"]);
113-
114110
sheets.push_back(Stylesheet::Make({ {"$graph"}, {"$label-units"} }));
115-
sheets.back()->InsertRaw<at::textSize>((double)traversedPref["graphFont"]["titleSize"]);
116111
sheets.back()->InsertRaw<at::marginLeft>(3.);
117112
sheets.back()->InsertRaw<at::marginRight>(3.);
118113

119114
sheets.push_back(Stylesheet::Make({ {"$label-wrap-left"}, {"$label-value"} }));
120115
sheets.back()->InsertRaw<at::marginLeft>(5.);
121-
sheets.back()->InsertRaw<at::textSize>((double)traversedPref["graphFont"]["titleSize"]);
122116
sheets.back()->InsertRaw<at::textJustification>(at::make::Enum(prim::Justification::Right));
123117

124118
sheets.push_back(Stylesheet::Make({ {"$label-wrap-right"}, {"$label-value"} }));
125119
sheets.back()->InsertRaw<at::marginLeft>(5.);
126-
sheets.back()->InsertRaw<at::textSize>((double)traversedPref["graphFont"]["titleSize"]);
127120
sheets.back()->InsertRaw<at::textJustification>(at::make::Enum(prim::Justification::Right));
128121

129122
sheets.push_back(Stylesheet::Make({ {"$label-wrap-left"}, {"$label-swatch"} }));
@@ -303,6 +296,8 @@ namespace p2c::client::util
303296
sheets.back()->InsertRaw<at::graphMinCount>((double)Traverse(vGraph)["graphType"]["countRange"][(size_t)0]);
304297
sheets.back()->InsertRaw<at::graphMaxCount>((double)Traverse(vGraph)["graphType"]["countRange"][1]);
305298
sheets.back()->InsertRaw<at::backgroundColor>(backgroundColor);
299+
sheets.push_back(Stylesheet::Make({ {}, {"$graph"} }));
300+
sheets.back()->InsertRaw<at::textColor>(at::make::Color(ColorFromV8(Traverse(vGraph)["textColor"])));
306301
// since border is 0px, these settings do nothing
307302
// sheets.back()->InsertRaw<at::borderColorLeft>(borderColor);
308303
// sheets.back()->InsertRaw<at::borderColorTop>(borderColor);
@@ -318,6 +313,18 @@ namespace p2c::client::util
318313
sheets.back()->InsertRaw<at::graphAutoscaleCount>(true);
319314
}
320315

316+
sheets.push_back(Stylesheet::Make({ { "$graph", tag }, {"$label"} }));
317+
sheets.back()->InsertRaw<at::textSize>((double)Traverse(vGraph)["textSize"]);
318+
319+
sheets.push_back(Stylesheet::Make({ { "$graph", tag }, {"$label-units"} }));
320+
sheets.back()->InsertRaw<at::textSize>((double)Traverse(vGraph)["textSize"]);
321+
322+
sheets.push_back(Stylesheet::Make({ { "$graph", tag }, {"$label-value"} }));
323+
sheets.back()->InsertRaw<at::textSize>((double)Traverse(vGraph)["textSize"]);
324+
325+
sheets.push_back(Stylesheet::Make({ { "$graph", tag }, {"$label-value"} }));
326+
sheets.back()->InsertRaw<at::textSize>((double)Traverse(vGraph)["textSize"]);
327+
321328
sheets.push_back(Stylesheet::Make({ { "$graph", tag }, {"$body"} }));
322329
sheets.back()->InsertRaw<at::height>((double)Traverse(vGraph)["height"]);
323330

0 commit comments

Comments
 (0)