aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/color_utils.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@zing.org>2014-10-25 12:36:32 -0700
committerGerald Combs <gerald@wireshark.org>2014-10-25 19:39:36 +0000
commit3d2ec1613b826faf6d10702147cea96286e44516 (patch)
tree05c80a73c1f255dfe5e861c0d162e4c7267468ad /ui/qt/color_utils.cpp
parent41f6923b3049dfb57bef544a4c580f256f807e85 (diff)
Qt: ByteViewText fixups.
Calculate our X coordinate using floating point arithmetic. This should hopefully fix the wierd subpixel text shifting for some font sizes. Add alpha blending convenience routines to ColorUtils. Use them to create the offset colors. The button color palette wasn't working very well under Ubuntu. Use QFontMetricsF::lineSpacing for our line height. Note that we don't support the BOLD gui.hex_dump_highlight_style preference. Leave a hint for anyone wishing to do so. Comment out related code for now. Change-Id: Ief77c9c8d00e05560cae6ecd781bd309027f6f5a Reviewed-on: https://code.wireshark.org/review/4927 Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/color_utils.cpp')
-rw-r--r--ui/qt/color_utils.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/ui/qt/color_utils.cpp b/ui/qt/color_utils.cpp
index 0603a26b98..4210d29734 100644
--- a/ui/qt/color_utils.cpp
+++ b/ui/qt/color_utils.cpp
@@ -60,6 +60,26 @@ QColor ColorUtils::fromColorT(color_t color)
return fromColorT(&color);
}
+QRgb ColorUtils::alphaBlend(const QColor &color1, const QColor &color2, qreal alpha)
+{
+ alpha = qBound(0.0, alpha, 1.0);
+
+ int r1 = color1.red() * alpha;
+ int g1 = color1.green() * alpha;
+ int b1 = color1.blue() * alpha;
+ int r2 = color2.red() * (1 - alpha);
+ int g2 = color2.green() * (1 - alpha);
+ int b2 = color2.blue() * (1 - alpha);
+
+ QColor alpha_color(r1 + r2, g1 + g2, b1 + b2);
+ return alpha_color.rgb();
+}
+
+QRgb ColorUtils::alphaBlend(const QBrush &brush1, const QBrush &brush2, qreal alpha)
+{
+ return alphaBlend(brush1.color(), brush2.color(), alpha);
+}
+
/*
* Editor modelines
*