Transparency symbol
"Jürgen Spitzmüller" <[email protected]> Sun, 05 Jul 2026 14:47:26 +0200
| Newsgroups | gmane.editors.lyx.devel |
|---|---|
| Message-ID | <[email protected]> |
Dear Koji I had a hard time to understand what the symbol used for transparent color means. I suggest to use the established symbol for that, greyish chessboard- like pattern. I think this will be more familiar to users (and it's also what is displayed in the system color widgets used by LyX). Agreed? -- Jürgen -- lyx-devel mailing list [email protected] https://lists.lyx.org/mailman/listinfo/lyx-devel
transp.diff
(text/x-patch, 3.1 KB)
diff --git a/src/frontends/qt/ColorCache.cpp b/src/frontends/qt/ColorCache.cpp
index fadaa153c6..a2ce5041c7 100644
--- a/src/frontends/qt/ColorCache.cpp
+++ b/src/frontends/qt/ColorCache.cpp
@@ -196,23 +196,22 @@ bool ColorCache::isLightColor(ARGBColor const & fg, ARGBColor const & bg)
return (L + 0.05) / (0.0 + 0.05) > (1.0 + 0.05) / (L + 0.05);
}
-QPixmap ColorCache::setSwatchBackground(int width, int height)
+QPixmap ColorCache::getTransparencySymbol(int width, int height)
{
QPixmap background(width, height);
- background.fill(Qt::white);
+ background.fill(Qt::lightGray);
- // paint a triangle
QPainter painter(&background);
- painter.setRenderHint(QPainter::Antialiasing);
- QPolygon polygon;
- polygon << QPoint(width, 0)
- << QPoint(0, height)
- << QPoint(0, 0);
- painter.setPen(QColor(Qt::black));
- painter.setBrush(QColor(Qt::black));
- painter.drawPolygon(polygon);
+ int squareSize = width / 8;
+
+ for (int i = 0; i < 8; ++i) {
+ for (int j = 0; j < 8; ++j) {
+ // Paint a chessboard-like structure
+ if ((i + j) % 2 == 1)
+ painter.fillRect(j * squareSize, i * squareSize, squareSize, squareSize, Qt::darkGray);
+ }
+ }
painter.end();
-
return background;
}
diff --git a/src/frontends/qt/ColorCache.h b/src/frontends/qt/ColorCache.h
index 81644f03c0..4899988ef2 100644
--- a/src/frontends/qt/ColorCache.h
+++ b/src/frontends/qt/ColorCache.h
@@ -60,7 +60,7 @@ public:
/// clear all colors
void clear() { initialized_ = false; }
- static QPixmap setSwatchBackground(int width, int height);
+ static QPixmap getTransparencySymbol(int width, int height);
static QPixmap mergePixmaps(QPixmap const *fg, QPixmap const *bg);
private:
diff --git a/src/frontends/qt/GuiBranches.cpp b/src/frontends/qt/GuiBranches.cpp
index e3ce31d9cd..4b9c62d229 100644
--- a/src/frontends/qt/GuiBranches.cpp
+++ b/src/frontends/qt/GuiBranches.cpp
@@ -77,7 +77,7 @@ GuiBranches::GuiBranches(QWidget * parent)
newBranchLE->installEventFilter(this);
newBranchLE->setValidator(new NoNewLineValidator(newBranchLE));
- swatchbg_ = ColorCache::setSwatchBackground(30, 10);
+ swatchbg_ = ColorCache::getTransparencySymbol(30, 10);
}
diff --git a/src/frontends/qt/GuiIndices.cpp b/src/frontends/qt/GuiIndices.cpp
index c4650391bf..c7e2f4a9fb 100644
--- a/src/frontends/qt/GuiIndices.cpp
+++ b/src/frontends/qt/GuiIndices.cpp
@@ -64,7 +64,7 @@ GuiIndices::GuiIndices(QWidget * parent)
indexOptionsLE->setValidator(new NoNewLineValidator(indexOptionsLE));
newIndexLE->setValidator(new NoNewLineValidator(newIndexLE));
- swatchbg_ = ColorCache::setSwatchBackground(30, 10);
+ swatchbg_ = ColorCache::getTransparencySymbol(30, 10);
}
diff --git a/src/frontends/qt/GuiPrefs.cpp b/src/frontends/qt/GuiPrefs.cpp
index f1357e42ce..f874c374b0 100644
--- a/src/frontends/qt/GuiPrefs.cpp
+++ b/src/frontends/qt/GuiPrefs.cpp
@@ -4721,7 +4721,7 @@ ColorSwatchDelegate::ColorSwatchDelegate(QObject *parent)
{
pane_ = static_cast<PrefColors*>(parent);
- bg_pixmap_ = ColorCache::setSwatchBackground(pane_->swatch_width_,
+ bg_pixmap_ = ColorCache::getTransparencySymbol(pane_->swatch_width_,
pane_->swatch_height_);
}