commit 7d2ba88fd907f613579a0d22739c4940ef45b89d
Author: Koji Yokota <[email protected]>
Date: Sat Mar 8 20:12:58 2025 +0900
Fix ColorCache::getAll()
---
src/frontends/qt/ColorCache.cpp | 21 ++++++++++-----------
src/frontends/qt/ColorCache.h | 6 ++++--
2 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/src/frontends/qt/ColorCache.cpp b/src/frontends/qt/ColorCache.cpp
index 290f47ee6f..5bb8523e17 100644
--- a/src/frontends/qt/ColorCache.cpp
+++ b/src/frontends/qt/ColorCache.cpp
@@ -95,7 +95,7 @@ QColor ColorCache::get(Color const & color, bool syscolors)
const
/// get the given color
-std::pair<QColor, QColor> ColorCache::getAll(Color const & color, bool
syscolors) const
+ColorPair ColorCache::getAll(Color const & color, bool syscolors) const
{
if (!initialized_)
const_cast<ColorCache *>(this)->init();
@@ -116,16 +116,15 @@ std::pair<QColor, QColor> ColorCache::getAll(Color const
& color, bool syscolors
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.
- std::pair<QColor, QColor> base_colors = getAll(color.baseColor,
syscolors);
- std::pair<QColor, QColor> merge_colors =
getAll(color.mergeColor, syscolors);
- return {QColor(
- (base_colors.first.toRgb().red() +
merge_colors.first.toRgb().red()) / 2,
- (base_colors.first.toRgb().green() +
merge_colors.first.toRgb().green()) / 2,
- (base_colors.first.toRgb().blue() +
merge_colors.first.toRgb().blue()) / 2),
- QColor(
- (base_colors.first.toRgb().red() +
merge_colors.first.toRgb().red()) / 2,
- (base_colors.first.toRgb().green() +
merge_colors.first.toRgb().green()) / 2,
- (base_colors.first.toRgb().blue() +
merge_colors.first.toRgb().blue()) / 2),
+ ColorPair base_colors = getAll(color.baseColor, syscolors);
+ ColorPair merge_colors = getAll(color.mergeColor, syscolors);
+ return {
+ QColor((base_colors.first.toRgb().red() +
merge_colors.first.toRgb().red()) / 2,
+ (base_colors.first.toRgb().green() +
merge_colors.first.toRgb().green()) / 2,
+ (base_colors.first.toRgb().blue() +
merge_colors.first.toRgb().blue()) / 2),
+ QColor((base_colors.second.toRgb().red() +
merge_colors.second.toRgb().red()) / 2,
+ (base_colors.second.toRgb().green() +
merge_colors.second.toRgb().green()) / 2,
+ (base_colors.second.toRgb().blue() +
merge_colors.second.toRgb().blue()) / 2),
};
}
// used by branches
diff --git a/src/frontends/qt/ColorCache.h b/src/frontends/qt/ColorCache.h
index 2aca7ee4a1..105a97df87 100644
--- a/src/frontends/qt/ColorCache.h
+++ b/src/frontends/qt/ColorCache.h
@@ -20,6 +20,8 @@
namespace lyx {
class Color;
+typedef std::pair<QColor, QColor> ColorPair;
+
/**
* Cache from Color to QColor.
@@ -37,7 +39,7 @@ public:
QColor get(Color const & color, bool use_system_colors) const;
/// get the given color
- std::pair<QColor, QColor> getAll(Color const & color, bool
use_system_colors) const;
+ ColorPair getAll(Color const & color, bool use_system_colors) const;
/// is this color replaced when LyXRC::use_system_color is true?
bool isSystem(ColorCode color) const;
@@ -55,7 +57,7 @@ private:
///
void init();
///
- std::pair<QColor, QColor> lcolors_[Color_ignore + 1];
+ ColorPair lcolors_[Color_ignore + 1];
///
bool initialized_;
///
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs