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 |
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- /*
- * Carla Style, based on Qt5 fusion style
- * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies)
- * Copyright (C) 2013-2014 Filipe Coelho <falktx@falktx.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * For a full copy of the license see the doc/LGPL.txt file
- */
-
- #ifndef CARLA_STYLE_PRIVATE_HPP_INCLUDED
- #define CARLA_STYLE_PRIVATE_HPP_INCLUDED
-
- #include "CarlaStyle.hpp"
- #include "CarlaStyleAnimations.hpp"
-
- #include <QtCore/QHash>
-
- static inline
- const QColor& qt_palette_bg_color(const QPalette& pal)
- {
- #if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
- return pal.window().color();
- #else
- return pal.background().color();
- #endif
- }
-
- static inline
- const QColor& qt_palette_fg_color(const QPalette& pal)
- {
- #if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
- return pal.windowText().color();
- #else
- return pal.foreground().color();
- #endif
- }
-
- class QStyleAnimation;
-
- class CarlaStylePrivate : public QObject
- {
- #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) && defined(__clang_major__) && __clang_major__ >= 4
- # pragma clang diagnostic push
- # pragma clang diagnostic ignored "-Winconsistent-missing-override"
- #endif
- Q_OBJECT
- #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) && defined(__clang_major__) && __clang_major__ >= 4
- # pragma clang diagnostic pop
- #endif
-
- public:
- enum {
- menuItemHMargin = 3, // menu item hor text margin
- menuArrowHMargin = 6, // menu arrow horizontal margin
- menuRightBorder = 15, // right border on menus
- menuCheckMarkWidth = 12 // checkmarks width on menus
- };
-
- CarlaStylePrivate(CarlaStyle* const style)
- : fStyle(style),
- fAnimationFps(60)
- {
- }
-
- ~CarlaStylePrivate() override
- {
- qDeleteAll(fAnimations);
- }
-
- int animationFps() const
- {
- return fAnimationFps;
- }
-
- // Used for grip handles
- QColor lightShade() const
- {
- return QColor(255, 255, 255, 36);
- }
-
- QColor darkShade() const
- {
- return QColor(0, 0, 0, 60);
- }
-
- QColor topShadow() const
- {
- return QColor(0, 0, 0, 18);
- }
-
- QColor innerContrastLine() const
- {
- return QColor(255, 255, 255, 30);
- }
-
- QColor highlight(const QPalette& pal) const
- {
- return pal.color(QPalette::Active, QPalette::Highlight);
- }
-
- QColor highlightedText(const QPalette& pal) const
- {
- return pal.color(QPalette::Active, QPalette::HighlightedText);
- }
-
- QColor outline(const QPalette& pal) const
- {
- if (! pal.window().texture().isNull())
- return QColor(0, 0, 0, 160);
- const QColor& col = qt_palette_bg_color(pal);
- return col.blackF() > 0.4 ? col.lighter(160) : col.darker(140);
- }
-
- QColor highlightedOutline(const QPalette &pal) const
- {
- QColor highlightedOutline = highlight(pal).darker(125);
- if (highlightedOutline.value() > 160)
- highlightedOutline.setHsl(highlightedOutline.hue(), highlightedOutline.saturation(), 160);
- return highlightedOutline;
- }
-
- QColor tabFrameColor(const QPalette& pal) const
- {
- if (! pal.button().texture().isNull())
- return QColor(255, 255, 255, 8);
- return buttonColor(pal).lighter(104);
- }
-
- QColor buttonColor(const QPalette& pal) const
- {
- QColor buttonColor = pal.button().color();
- const int val = qGray(buttonColor.rgb());
- buttonColor = buttonColor.lighter(100 + qMax(1, (180 - val)/6));
- buttonColor.setHsv(buttonColor.hue(), buttonColor.saturation() * 0.75, buttonColor.value());
- return buttonColor;
- }
-
- QIcon tabBarcloseButtonIcon;
-
- QList<const QObject*> animationTargets() const
- {
- return fAnimations.keys();
- }
-
- CarlaStyleAnimation* animation(const QObject* target) const
- {
- return fAnimations.value(target);
- }
-
- void startAnimation(CarlaStyleAnimation* animation) const
- {
- stopAnimation(animation->target());
- fStyle->connect(animation, SIGNAL(destroyed()), SLOT(_removeAnimation()), Qt::UniqueConnection);
- fAnimations.insert(animation->target(), animation);
- animation->start();
- }
-
- void stopAnimation(const QObject* target) const
- {
- CarlaStyleAnimation* const animation = fAnimations.take(target);
- if (animation != nullptr && animation->state() != QAbstractAnimation::Stopped)
- animation->stop();
- }
-
- private:
- CarlaStyle* const fStyle;
- int fAnimationFps;
- mutable QHash<const QObject*, CarlaStyleAnimation*> fAnimations;
-
- private slots:
- void _removeAnimation()
- {
- if (QObject* const animation = fStyle->sender())
- fAnimations.remove(animation->parent());
- }
- };
-
- #endif // CARLA_STYLE_PRIVATE_HPP_INCLUDED
|