Mercurial > hg > svgui
comparison layer/ColourDatabase.h @ 1580:a2ff9c01889e
Merge from branch background-mode
author | Chris Cannam |
---|---|
date | Fri, 24 Jan 2020 15:11:08 +0000 |
parents | 57a4ee52ad69 |
children |
comparison
equal
deleted
inserted
replaced
1572:5f6fdd525158 | 1580:a2ff9c01889e |
---|---|
69 /** | 69 /** |
70 * Return true if the given colour exists in the database. | 70 * Return true if the given colour exists in the database. |
71 */ | 71 */ |
72 bool haveColour(QColor c) const; | 72 bool haveColour(QColor c) const; |
73 | 73 |
74 enum WithBackgroundMode { | |
75 WithAnyBackground, | |
76 WithDarkBackground, | |
77 WithLightBackground | |
78 }; | |
79 | |
74 /** | 80 /** |
75 * Return the index of the colour in the database that is closest | 81 * Return the index of the colour in the database that is closest |
76 * to the given one, by some simplistic measure (Manhattan | 82 * to the given one, by some simple measure. This always returns |
77 * distance in RGB space). This always returns some valid index, | 83 * some valid index, unless the database is empty, in which case |
78 * unless the database is empty, in which case it returns -1. | 84 * it returns -1. |
79 */ | 85 */ |
80 int getNearbyColourIndex(QColor c) const; | 86 int getNearbyColourIndex(QColor c, |
87 WithBackgroundMode mode = WithAnyBackground) const; | |
81 | 88 |
82 /** | 89 /** |
83 * Add a colour to the database, with the associated name. Return | 90 * Add a colour to the database, with the associated name. Return |
84 * the index of the colour in the database. Names are unique | 91 * the index of the colour in the database. Names are unique |
85 * within the database: if another colour exists already with the | 92 * within the database: if another colour exists already with the |
108 */ | 115 */ |
109 void setUseDarkBackground(int c, bool dark); | 116 void setUseDarkBackground(int c, bool dark); |
110 | 117 |
111 /** | 118 /** |
112 * Return a colour that contrasts with the one at index c, | 119 * Return a colour that contrasts with the one at index c, |
113 * according to some simplistic algorithm. The returned colour is | 120 * according to some simple algorithm. The returned colour is not |
114 * not necessarily in the database; pass it to | 121 * necessarily in the database; pass it to getNearbyColourIndex if |
115 * getNearbyColourIndex if you need one that is. | 122 * you need one that is. |
116 */ | 123 */ |
117 QColor getContrastingColour(int c) const; | 124 QColor getContrastingColour(int c) const; |
118 | 125 |
119 // for use in XML export | 126 // for use in XML export |
120 void getStringValues(int index, | 127 void getStringValues(int index, |