Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CarlaStylePrivate.hpp 4.6KB

10 years ago
Frontend widget enhancements (#767) * optimization: MainWindow resize event (no more issue #148) minimap: Brightness-aware shading on side gaps * CarlaStyle: more careful rounded corner drawing Rounded rectangles have transparent corners even with opaque colors. During compositing colors from several such objects are mixed, producing unexpected artifacts. Also outer contour must have bigger rounding - values for inner/outer rects are spreaded to be around of original 2.0px, to preserve original look. * CarlaStyle: better separator color Create separator color from softened text color. * paramspinbox: Keep scrollbar size closer to outer frame Unless QStyle allowes any widget style, or it is entries and scrollbars provide essential way to control or read frame parameters, scrollbar is still set a bit smaller to counter theme-side deviations between scrollbar and spinbox visible height while real height is equal. * CarlaStyle: better light shade * CarlaStyle: fix visible spinbox height regression When spinbox is in one row with scrollbar or entry field, all vertically expanding, spinbox look a bit lower. * CarlaStyle: completed spinbox buttons light border * CarlaStyle: fixed spinbox button rects, better borderwidth balance Integer button rectangles now produce pixel-aligned non-overlaping, still centered rectangles. SpinBox border width is reduced to minimum, right enough to keep entry widget corners out of outer rounded border parts. * CarlaStyle: constification (SpinBox drawing) * CarlaStyle: spinbox drawing fixes Rely to correct buttons rectangles, handle correctly both even and odd spinbox heights. Disappeared buttons highlight glitch, appeared when moving mouse one button to another. * CarlaStyle, SpinBox: contrast highlight margin between buttons * CarlaStyle spinbox: more careful buttons highlight * CarlaStyle, spinbox: better arrows placement * paramspinbox: Hide scrollbar border * CarlaStyle: nicer rounded corners in deep-dark colors (less radius deviation) * CarlaStyle CT_ToolButton: took less space than combobox in same layout As in designer, carla_host.ui has plus/minus buttons size 25x24, with height equal to adjacent combobox. It seems, system carla style already got fix.
6 years ago
10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. * Carla Style, based on Qt5 fusion style
  3. * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies)
  4. * Copyright (C) 2013-2014 Filipe Coelho <falktx@falktx.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Lesser General Public License for more details.
  14. *
  15. * For a full copy of the license see the doc/LGPL.txt file
  16. */
  17. #ifndef CARLA_STYLE_PRIVATE_HPP_INCLUDED
  18. #define CARLA_STYLE_PRIVATE_HPP_INCLUDED
  19. #include "CarlaStyle.hpp"
  20. #include "CarlaStyleAnimations.hpp"
  21. #include <QtCore/QHash>
  22. class QStyleAnimation;
  23. class CarlaStylePrivate : public QObject
  24. {
  25. #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) && defined(__clang_major__) && __clang_major__ >= 4
  26. # pragma clang diagnostic push
  27. # pragma clang diagnostic ignored "-Winconsistent-missing-override"
  28. #endif
  29. Q_OBJECT
  30. #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) && defined(__clang_major__) && __clang_major__ >= 4
  31. # pragma clang diagnostic pop
  32. #endif
  33. public:
  34. enum {
  35. menuItemHMargin = 3, // menu item hor text margin
  36. menuArrowHMargin = 6, // menu arrow horizontal margin
  37. menuRightBorder = 15, // right border on menus
  38. menuCheckMarkWidth = 12 // checkmarks width on menus
  39. };
  40. CarlaStylePrivate(CarlaStyle* const style)
  41. : fStyle(style),
  42. fAnimationFps(60)
  43. {
  44. }
  45. ~CarlaStylePrivate() override
  46. {
  47. qDeleteAll(fAnimations);
  48. }
  49. int animationFps() const
  50. {
  51. return fAnimationFps;
  52. }
  53. // Used for grip handles
  54. QColor lightShade() const
  55. {
  56. return QColor(255, 255, 255, 36);
  57. }
  58. QColor darkShade() const
  59. {
  60. return QColor(0, 0, 0, 60);
  61. }
  62. QColor topShadow() const
  63. {
  64. return QColor(0, 0, 0, 18);
  65. }
  66. QColor innerContrastLine() const
  67. {
  68. return QColor(255, 255, 255, 30);
  69. }
  70. QColor highlight(const QPalette& pal) const
  71. {
  72. return pal.color(QPalette::Active, QPalette::Highlight);
  73. }
  74. QColor highlightedText(const QPalette& pal) const
  75. {
  76. return pal.color(QPalette::Active, QPalette::HighlightedText);
  77. }
  78. QColor outline(const QPalette& pal) const
  79. {
  80. if (! pal.window().texture().isNull())
  81. return QColor(0, 0, 0, 160);
  82. return pal.background().color().darker(140);
  83. }
  84. QColor highlightedOutline(const QPalette &pal) const
  85. {
  86. QColor highlightedOutline = highlight(pal).darker(125);
  87. if (highlightedOutline.value() > 160)
  88. highlightedOutline.setHsl(highlightedOutline.hue(), highlightedOutline.saturation(), 160);
  89. return highlightedOutline;
  90. }
  91. QColor tabFrameColor(const QPalette& pal) const
  92. {
  93. if (! pal.button().texture().isNull())
  94. return QColor(255, 255, 255, 8);
  95. return buttonColor(pal).lighter(104);
  96. }
  97. QColor buttonColor(const QPalette& pal) const
  98. {
  99. QColor buttonColor = pal.button().color();
  100. const int val = qGray(buttonColor.rgb());
  101. buttonColor = buttonColor.lighter(100 + qMax(1, (180 - val)/6));
  102. buttonColor.setHsv(buttonColor.hue(), buttonColor.saturation() * 0.75, buttonColor.value());
  103. return buttonColor;
  104. }
  105. QIcon tabBarcloseButtonIcon;
  106. QList<const QObject*> animationTargets() const
  107. {
  108. return fAnimations.keys();
  109. }
  110. CarlaStyleAnimation* animation(const QObject* target) const
  111. {
  112. return fAnimations.value(target);
  113. }
  114. void startAnimation(CarlaStyleAnimation* animation) const
  115. {
  116. stopAnimation(animation->target());
  117. fStyle->connect(animation, SIGNAL(destroyed()), SLOT(_removeAnimation()), Qt::UniqueConnection);
  118. fAnimations.insert(animation->target(), animation);
  119. animation->start();
  120. }
  121. void stopAnimation(const QObject* target) const
  122. {
  123. CarlaStyleAnimation* const animation = fAnimations.take(target);
  124. if (animation != nullptr && animation->state() != QAbstractAnimation::Stopped)
  125. animation->stop();
  126. }
  127. private:
  128. CarlaStyle* const fStyle;
  129. int fAnimationFps;
  130. mutable QHash<const QObject*, CarlaStyleAnimation*> fAnimations;
  131. private slots:
  132. void _removeAnimation()
  133. {
  134. if (QObject* const animation = fStyle->sender())
  135. fAnimations.remove(animation->parent());
  136. }
  137. };
  138. #endif // CARLA_STYLE_PRIVATE_HPP_INCLUDED