]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/ColorCache.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / ColorCache.cpp
index 69520fc7384ab3de81d6d820e77fa78022752d3d..5b7a416afcc38d7bd5d8a3ebd53718da16bb9060 100644 (file)
 #include <config.h>
 
 #include "ColorCache.h"
-
-#include "Color.h"
-
-#include <string>
-
+#include "ColorSet.h"
 
 namespace lyx {
 
@@ -28,14 +24,24 @@ void ColorCache::init()
 
 
 /// get the given color
-QColor ColorCache::get(ColorCode color) const
+QColor ColorCache::get(Color color) const
 {
        if (!initialized_)
                const_cast<ColorCache *>(this)->init();
-       if (color <= Color_ignore)
-               return lcolors_[color];
+       if (color <= Color_ignore && color.mergeColor == Color_ignore)
+               return lcolors_[color.baseColor];
+       if (color.mergeColor != Color_ignore) {
+               // FIXME: This would ideally be done in the Color class, but
+               // that means that we'd have to use the Qt code in the core.
+               QColor base_color = get(color.baseColor).toRgb();
+               QColor merge_color = get(color.mergeColor).toRgb();
+               return QColor(
+                       (base_color.red() + merge_color.red()) / 2,
+                       (base_color.green() + merge_color.green()) / 2,
+                       (base_color.blue() + merge_color.blue()) / 2);
+       }
        // used by branches
-       return QColor(lcolor.getX11Name(color).c_str()); 
+       return QColor(lcolor.getX11Name(color.baseColor).c_str()); 
 }