mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
helper: Added createTagColorMap
This commit is contained in:
parent
c9679e21d0
commit
117587e1c5
2 changed files with 21 additions and 0 deletions
|
@ -538,3 +538,22 @@ std::vector <Range> combineHolidaysAndExclusions (
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Extract the tags from a set of intervals, and using a rotating color palette,
|
||||||
|
// map unique tags to color.
|
||||||
|
std::map <std::string, Color> createTagColorMap (
|
||||||
|
const Rules& rules,
|
||||||
|
Palette& palette,
|
||||||
|
const std::vector <Interval>& intervals)
|
||||||
|
{
|
||||||
|
// TODO Note: tags may have their own defined color.
|
||||||
|
|
||||||
|
std::map <std::string, Color> mapping;
|
||||||
|
for (auto& interval : intervals)
|
||||||
|
for (auto& tag : interval.tags ())
|
||||||
|
if (mapping.find (tag) == mapping.end ())
|
||||||
|
mapping[tag] = palette.next ();
|
||||||
|
|
||||||
|
return mapping;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <Extensions.h>
|
#include <Extensions.h>
|
||||||
#include <Interval.h>
|
#include <Interval.h>
|
||||||
#include <Timeline.h>
|
#include <Timeline.h>
|
||||||
|
#include <Palette.h>
|
||||||
#include <Color.h>
|
#include <Color.h>
|
||||||
|
|
||||||
// init.cpp
|
// init.cpp
|
||||||
|
@ -57,6 +58,7 @@ std::vector <Range> addRanges (const Range&, const std::vector <Range>&, const s
|
||||||
std::vector <Range> subtractRanges (const Range&, const std::vector <Range>&, const std::vector <Range>&);
|
std::vector <Range> subtractRanges (const Range&, const std::vector <Range>&, const std::vector <Range>&);
|
||||||
Range overallRangeFromIntervals (const std::vector <Interval>&);
|
Range overallRangeFromIntervals (const std::vector <Interval>&);
|
||||||
std::vector <Range> combineHolidaysAndExclusions (const Range&, const Rules&, const std::vector <Exclusion>&);
|
std::vector <Range> combineHolidaysAndExclusions (const Range&, const Rules&, const std::vector <Exclusion>&);
|
||||||
|
std::map <std::string, Color> createTagColorMap (const Rules&, Palette&, const std::vector <Interval>&);
|
||||||
|
|
||||||
// utiŀ.cpp
|
// utiŀ.cpp
|
||||||
std::string osName ();
|
std::string osName ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue