[vlc-commits] [Git][videolan/vlc][master] 7 commits: qml: use built-in color alpha function

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon May 6 16:35:28 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
0603a12b by Fatih Uzunoglu at 2024-05-06T15:30:01+00:00
qml: use built-in color alpha function

- - - - -
4a9e83a2 by Fatih Uzunoglu at 2024-05-06T15:30:01+00:00
qml: remove setColorAlpha property from VLCStyle

- - - - -
71e1ab15 by Fatih Uzunoglu at 2024-05-06T15:30:01+00:00
qt: do not expose `setColorAlpha()` anymore

- - - - -
908fc5aa by Fatih Uzunoglu at 2024-05-06T15:30:01+00:00
qml: use built-in color tint instead of custom blend in AcrylicBackground

- - - - -
30117791 by Fatih Uzunoglu at 2024-05-06T15:30:01+00:00
qt: do not expose `blendColors()` anymore

- - - - -
e1170346 by Fatih Uzunoglu at 2024-05-06T15:30:01+00:00
qml: remove blendColors property from VLCStyle

- - - - -
85a93c00 by Fatih Uzunoglu at 2024-05-06T15:30:01+00:00
qt: remove `blendColors()` in systempalette.cpp

- - - - -


11 changed files:

- modules/gui/qt/player/qml/Player.qml
- modules/gui/qt/player/qml/TracksMenu.qml
- modules/gui/qt/player/qml/controlbarcontrols/PlayButton.qml
- modules/gui/qt/player/qml/controlbarcontrols/TeletextWidget.qml
- modules/gui/qt/playlist/qml/PlaylistDelegate.qml
- modules/gui/qt/style/VLCStyle.qml
- modules/gui/qt/style/systempalette.cpp
- modules/gui/qt/style/systempalette.hpp
- modules/gui/qt/widgets/qml/AcrylicBackground.qml
- modules/gui/qt/widgets/qml/CSDWindowButtonSet.qml
- modules/gui/qt/widgets/qml/PopupIconToolButton.qml


Changes:

=====================================
modules/gui/qt/player/qml/Player.qml
=====================================
@@ -233,8 +233,8 @@ FocusScope {
 
             source: cover
 
-            screenColor: VLCStyle.setColorAlpha(bgtheme.bg.primary, .55)
-            overlayColor: VLCStyle.setColorAlpha(Qt.tint(bgtheme.fg.primary, bgtheme.bg.primary), 0.4)
+            screenColor: bgtheme.bg.primary.alpha(.55)
+            overlayColor: Qt.tint(bgtheme.fg.primary, bgtheme.bg.primary).alpha(0.4)
         }
     }
 
@@ -602,7 +602,7 @@ FocusScope {
 
             height: playlistpopup.height
 
-            color: VLCStyle.setColorAlpha(windowTheme.bg.primary, 0.8)
+            color: windowTheme.bg.primary.alpha(0.8)
 
 
             PL.PlaylistListView {


=====================================
modules/gui/qt/player/qml/TracksMenu.qml
=====================================
@@ -65,9 +65,7 @@ T.Popup {
 
     background: Rectangle {
         // NOTE: The opacity should be stronger on a light background for readability.
-        color: (popupTheme.palette.isDark)
-               ? VLCStyle.setColorAlpha(popupTheme.bg.primary, 0.8)
-               : VLCStyle.setColorAlpha(popupTheme.bg.primary, 0.96)
+        color: popupTheme.bg.primary.alpha(popupTheme.palette.isDark ? 0.8 : 0.96)
 
         Rectangle {
             anchors.left: parent.left


=====================================
modules/gui/qt/player/qml/controlbarcontrols/PlayButton.qml
=====================================
@@ -256,7 +256,7 @@ T.Control {
             blurRadius: VLCStyle.dp(9)
             yOffset: VLCStyle.dp(4)
 
-            color: VLCStyle.setColorAlpha(theme.accent, 0.29)
+            color: theme.accent.alpha(0.29)
         }
 
         DropShadowImage {
@@ -265,7 +265,7 @@ T.Control {
             blurRadius: VLCStyle.dp(14)
             yOffset: VLCStyle.dp(1)
 
-            color: VLCStyle.setColorAlpha(theme.accent, 1.0)
+            color: theme.accent.alpha(1.0)
         }
 
         Rectangle {


=====================================
modules/gui/qt/player/qml/controlbarcontrols/TeletextWidget.qml
=====================================
@@ -42,7 +42,7 @@ T.Pane {
     function _teletextButtonColor(item, base)
     {
         if (!item.enabled)
-            return VLCStyle.setColorAlpha(base, 0.2)
+            return base.alpha(0.2)
         else if (item.hovered && !item.down)
             return Qt.lighter(base)
         else


=====================================
modules/gui/qt/playlist/qml/PlaylistDelegate.qml
=====================================
@@ -129,7 +129,7 @@ T.ItemDelegate {
 
                 // based on design, ColorContext can't handle this case
                 if (!delegate.hovered)
-                    return VLCStyle.setColorAlpha(theme.indicator, 0)
+                    return theme.indicator.alpha(0)
 
                 return theme.indicator
             }


=====================================
modules/gui/qt/style/VLCStyle.qml
=====================================
@@ -311,10 +311,6 @@ QtObject {
     readonly property int controlLayoutHeight: MainCtx.dp(64, scale)
     readonly property int controlLayoutHeightPinned: MainCtx.dp(32, scale)
 
-    //"alias" ColorHelper functions
-    readonly property var blendColors: vlc_style.palette.blendColors
-    readonly property var setColorAlpha: vlc_style.palette.setColorAlpha
-
     function dp(size, scale) {
         if (scale === undefined)
             return MainCtx.dp(size, MainCtx.intfScaleFactor)


=====================================
modules/gui/qt/style/systempalette.cpp
=====================================
@@ -25,14 +25,6 @@
 
 namespace {
 
-QColor blendColors(QColor c1, QColor c2, float blend = 0.5)
-{
-    return QColor::fromRgbF(c2.redF()   + (c1.redF()   - c2.redF())   * blend,
-                  c2.greenF() + (c1.greenF() - c2.greenF()) * blend,
-                  c2.blueF()  + (c1.blueF()  - c2.blueF())  * blend,
-                  c2.alphaF() + (c1.alphaF() - c2.alphaF()) * blend);
-}
-
 QColor setColorAlpha(const QColor& c1, float alpha)
 {
     QColor c(c1);
@@ -337,15 +329,6 @@ bool SystemPalette::hasCSDImage() const
     return m_palettePriv->hasCSDImages();
 }
 
-QColor SystemPalette::blendColors(const QColor& c1, const QColor& c2, float blend)
-{
-    return ::blendColors(c1, c2, blend);
-}
-QColor SystemPalette::setColorAlpha(const QColor& c1, float alpha)
-{
-    return ::setColorAlpha(c1, alpha);
-}
-
 void SystemPalette::setSource(ColorSchemeModel::ColorScheme source)
 {
     if (m_source == source)


=====================================
modules/gui/qt/style/systempalette.hpp
=====================================
@@ -143,10 +143,6 @@ public:
     inline MainCtx* getCtx() const { return m_ctx; }
     bool hasCSDImage() const;
 
-    //function helper exposed to QML
-    Q_INVOKABLE QColor blendColors(const QColor& c1, const QColor& c2, float blend = 0.5);
-    Q_INVOKABLE QColor setColorAlpha(const QColor& c1, float alpha);
-
     void setColor(ColorContext::ColorSet colorSet,  ColorContext::ColorSection section,
                   ColorContext::ColorName name, ColorContext::ColorState state, QColor color);
     QColor getColor(ColorContext::ColorSet colorSet,  ColorContext::ColorSection section,


=====================================
modules/gui/qt/widgets/qml/AcrylicBackground.qml
=====================================
@@ -34,9 +34,8 @@ ViewBlockingRectangle {
 
     property color alternativeColor: tintColor
 
-    readonly property color _actualTintColor: VLCStyle.setColorAlpha(tintColor, 0.7)
-    property real _blend: usingAcrylic ? AcrylicController.uiTransluency : 0
+    readonly property color _actualTintColor: tintColor.alpha(0.7)
 
-
-    color: VLCStyle.blendColors(root._actualTintColor, root.alternativeColor, root._blend)
+    color: root._actualTintColor.tint(Qt.alpha(root.alternativeColor,
+                                               1 - (usingAcrylic ? AcrylicController.uiTransluency : 0)))
 }


=====================================
modules/gui/qt/widgets/qml/CSDWindowButtonSet.qml
=====================================
@@ -31,7 +31,7 @@ Row {
     width: implicitWidth
 
     property color color: theme.fg.primary
-    property color hoverColor: VLCStyle.setColorAlpha(theme.bg.primary, 0.5)
+    property color hoverColor: theme.bg.primary.alpha(0.5)
 
     readonly property bool useWinIcons: ((MainCtx.osName === MainCtx.Windows)&&(MainCtx.osVersion >= 10))
 


=====================================
modules/gui/qt/widgets/qml/PopupIconToolButton.qml
=====================================
@@ -111,9 +111,7 @@ Widgets.IconToolButton {
             radius: VLCStyle.dp(8, VLCStyle.scale)
 
             // NOTE: The opacity should be stronger on a light background for readability.
-            color: (popupTheme.palette.isDark)
-                   ? VLCStyle.setColorAlpha(popupTheme.bg.primary, 0.8)
-                   : VLCStyle.setColorAlpha(popupTheme.bg.primary, 0.96)
+            color: popupTheme.bg.primary.alpha(popupTheme.palette.isDark ? 0.8 : 0.96)
         }
     }
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/48b919841cd9e83febd58b8be6472c03051d5f5e...85a93c00c2ebeaeddad8555b7c942a02d58bee32

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/48b919841cd9e83febd58b8be6472c03051d5f5e...85a93c00c2ebeaeddad8555b7c942a02d58bee32
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list