Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-77635

Improve color handling in QML

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • P2: Important
    • None
    • None
    • None
    • All

    Description

      QTBUG-14731 provided support for accessing red, green and blue values of color type, but overall the QML color API is still pretty static.

      Color is a fundamental property of visual interfaces. When developing interactive, real-time graphical systems procedural handling of the core types is often necessary when highlighting items with accented colors, pulsating colors to indicate an operation is ongoing, adding gradients and shadows to emphasise (e.g. top of visual stack) or deemphasize (e.g. disabled, secondary) items, transitioning between visual UI states, and so on. You can do a lot with shaders, but is often too laborous route for performing simple color operations.

      As many modern UI toolkits are a mixture of QML and shaders would be nice to align the color type operations as much as possible between QML and shader languages like GLSL.

      Some examples:

      Making a color semi-transparent by overriding alpha channel:
      colorB = Qt.color(colorA.rgb, opacity)

      Accessing hue, saturation, value, e.g. increase saturation by 20%:
      color.s = color.s * 1.2

      Scalar multiplication
      darkGray = 0.5 * gray

      Mixing colors:
      color = mix(colorA, colorB, 0.5) // Qt.tint is horrible API

      Producing colors as combination from other colors:
      colorX = Qt.color(colorA.rg, colorB.b, colorC.a)

       Swizzling:
      colorA.rgb = colorB.bgr

       

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-77635
          # Subject Branch Project Status CR V

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              jpetrell Joona Petrell
              Votes:
              4 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes