fix tab color when all tracks have a different one

This commit is contained in:
vcoppe
2025-01-02 22:04:14 +01:00
parent bae0a3f93b
commit 2cb21a43c5
2 changed files with 14 additions and 13 deletions

View File

@@ -185,18 +185,18 @@ export class GPXFile extends GPXTreeNode<Track> {
}); });
} }
getStyle(): MergedLineStyles { getStyle(defaultColor?: string): MergedLineStyles {
return this.trk.map((track) => track.getStyle()).reduce((acc, style) => { return this.trk.map((track) => track.getStyle()).reduce((acc, style) => {
if (style) { if (style && style["gpx_style:color"] && !acc.color.includes(style["gpx_style:color"])) {
if (style["gpx_style:color"] && !acc.color.includes(style["gpx_style:color"])) { acc.color.push(style["gpx_style:color"]);
acc.color.push(style["gpx_style:color"]); } else if (defaultColor && !acc.color.includes(defaultColor)) {
} acc.color.push(defaultColor);
if (style["gpx_style:opacity"] && !acc.opacity.includes(style["gpx_style:opacity"])) { }
acc.opacity.push(style["gpx_style:opacity"]); if (style && style["gpx_style:opacity"] && !acc.opacity.includes(style["gpx_style:opacity"])) {
} acc.opacity.push(style["gpx_style:opacity"]);
if (style["gpx_style:width"] && !acc.width.includes(style["gpx_style:width"])) { }
acc.width.push(style["gpx_style:width"]); if (style && style["gpx_style:width"] && !acc.width.includes(style["gpx_style:width"])) {
} acc.width.push(style["gpx_style:width"]);
} }
return acc; return acc;
}, { }, {

View File

@@ -69,13 +69,14 @@
nodeColors = []; nodeColors = [];
if (node instanceof GPXFile) { if (node instanceof GPXFile) {
let style = node.getStyle(); let defaultColor = undefined;
let layer = gpxLayers.get(item.getFileId()); let layer = gpxLayers.get(item.getFileId());
if (layer) { if (layer) {
style.color.push(layer.layerColor); defaultColor = layer.layerColor;
} }
let style = node.getStyle(defaultColor);
style.color.forEach((c) => { style.color.forEach((c) => {
if (!nodeColors.includes(c)) { if (!nodeColors.includes(c)) {
nodeColors.push(c); nodeColors.push(c);