src/colors.h

changeset 998
5be0ce31ce60
parent 974
b2fa5f89798a
child 1014
f0a8ecb6a357
child 1217
314e12e23c3a
equal deleted inserted replaced
997:1b49f34e533d 998:5be0ce31ce60
17 */ 17 */
18 18
19 #pragma once 19 #pragma once
20 #include <QColor> 20 #include <QColor>
21 #include "basics.h" 21 #include "basics.h"
22
23 class ColorData
24 {
25 public:
26 struct Entry
27 {
28 QString name;
29 QString hexcode;
30 QColor faceColor;
31 QColor edgeColor;
32 };
33
34 enum { EntryCount = 512 };
35 ColorData();
36 ~ColorData();
37 void loadFromLdconfig();
38 bool contains (int code) const;
39 const Entry& get (int code) const;
40
41 private:
42 Entry m_data[EntryCount];
43 };
22 44
23 class LDColor 45 class LDColor
24 { 46 {
25 public: 47 public:
26 LDColor() : m_index (0) {} 48 LDColor() : m_index (0) {}
54 bool operator<= (LDColor other) const { return index() <= other.index(); } 76 bool operator<= (LDColor other) const { return index() <= other.index(); }
55 bool operator> (LDColor other) const { return index() > other.index(); } 77 bool operator> (LDColor other) const { return index() > other.index(); }
56 bool operator>= (LDColor other) const { return index() >= other.index(); } 78 bool operator>= (LDColor other) const { return index() >= other.index(); }
57 79
58 private: 80 private:
81 const ColorData::Entry& data() const;
82
59 qint32 m_index; 83 qint32 m_index;
60 }; 84 };
61 85
62 // 86 //
63 // Parses ldconfig.ldr 87 // Parses ldconfig.ldr
68 LDConfigParser (QString inText, char sep); 92 LDConfigParser (QString inText, char sep);
69 93
70 bool getToken (QString& val, const int pos); 94 bool getToken (QString& val, const int pos);
71 bool findToken (int& result, char const* needle, int args); 95 bool findToken (int& result, char const* needle, int args);
72 bool compareToken (int inPos, QString text); 96 bool compareToken (int inPos, QString text);
73 bool parseLDConfigTag (char const* tag, QString& val); 97 bool parseTag (char const* tag, QString& val);
74 98
75 inline QString operator[] (const int idx) 99 inline QString operator[] (const int idx)
76 { 100 {
77 return m_tokens[idx]; 101 return m_tokens[idx];
78 } 102 }
80 private: 104 private:
81 QStringList m_tokens; 105 QStringList m_tokens;
82 int m_pos; 106 int m_pos;
83 }; 107 };
84 108
85 void InitColors(); 109 void initColors();
86 int Luma (const QColor& col); 110 int luma (const QColor& col);
87 int CountLDConfigColors();
88 void parseLDConfig();
89 111
90 enum 112 enum
91 { 113 {
92 MainColor = 16, 114 MainColor = 16,
93 EdgeColor = 24, 115 EdgeColor = 24,

mercurial