Perceptual Color

abstractdiagram.h
1// SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com>
2// SPDX-License-Identifier: BSD-2-Clause OR MIT
3
4#ifndef ABSTRACTDIAGRAM_H
5#define ABSTRACTDIAGRAM_H
6
7#include "constpropagatinguniquepointer.h"
8#include "importexport.h"
9#include <qcolor.h>
10#include <qglobal.h>
11#include <qimage.h>
12#include <qsize.h>
13#include <qwidget.h>
14class QHideEvent;
15class QShowEvent;
16
17#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
18#include <qtmetamacros.h>
19#else
20#include <qobjectdefs.h>
21#include <qstring.h>
22class QObject;
23#endif
24
25namespace PerceptualColor
26{
27class AbstractDiagramPrivate;
28
29/** @brief Base class for LCH diagrams.
30 *
31 * Provides some elements that are common for all LCH diagrams in this
32 * library.
33 *
34 * @internal
35 *
36 * @note Qt provides some possibilities to declare that a certain widget
37 * has a fixed ration between width and height. You can reimplement
38 * <tt>QWidget::hasHeightForWidth()</tt> (indicates that the widget’s preferred
39 * height depends on its width) and <tt>QWidget::heightForWidth()</tt>
40 * (returns the preferred height for this widget, given the width <tt>w</tt>).
41 * However, Qt’s layout management makes only very limited use of this
42 * information. It is ignored, when the surrounding window is resized by
43 * grabbing the window border with the mouse. It is however considered when
44 * the surrounding window is resized by grabbing a <tt>QSizeGrip</tt>
45 * widget. This behavior is inconsistent and would be surprising for the
46 * user. Furthermore, if the widget is yet touching the border of the
47 * screen, then the policy cannot be honored anyway; but it causes
48 * flickering. Another possibility is QSizePolicy::setHeightForWidth or
49 * QSizePolicy::setWidthForHeight which seem both to be “only supported for
50 * QGraphicsLayout’s subclasses”. Therefore, it’s better not to use at all
51 * these features; that’s the only way to provide a consistent and good
52 * user experience.
53 *
54 * @todo Circular diagrams should be right-aligned on RTL layouts.
55 *
56 * @todo Touchscreen support: Magnify the handle circle, when diagram is
57 * used on a touch device? */
59{
60 Q_OBJECT
61
62public:
63 Q_INVOKABLE explicit AbstractDiagram(QWidget *parent = nullptr);
64 /** @brief Default destructor */
65 virtual ~AbstractDiagram() noexcept override;
66
67protected:
68 virtual void actualVisibilityToggledEvent();
69 void callUpdate();
70 [[nodiscard]] QColor focusIndicatorColor() const;
71 [[nodiscard]] int gradientMinimumLength() const;
72 [[nodiscard]] int gradientThickness() const;
73 virtual void hideEvent(QHideEvent *event) override;
74 [[nodiscard]] bool isActuallyVisible() const;
75 [[nodiscard]] int maximumPhysicalSquareSize() const;
76 [[nodiscard]] qreal maximumWidgetSquareSize() const;
77 [[nodiscard]] QSize physicalPixelSize() const;
78 [[nodiscard]] QColor handleColorFromBackgroundLightness(qreal lightness) const;
79 [[nodiscard]] int handleOutlineThickness() const;
80 [[nodiscard]] qreal handleRadius() const;
81 virtual void showEvent(QShowEvent *event) override;
82 [[nodiscard]] int spaceForFocusIndicator() const;
83 [[nodiscard]] QImage transparencyBackground() const;
84
85private:
86 Q_DISABLE_COPY(AbstractDiagram)
87
88 /** @internal
89 *
90 * @brief Declare the private implementation as friend class.
91 *
92 * This allows the private class to access the protected members and
93 * functions of instances of <em>this</em> class. */
94 friend class AbstractDiagramPrivate;
95 /** @brief Pointer to implementation (pimpl) */
96 ConstPropagatingUniquePointer<AbstractDiagramPrivate> d_pointer;
97
98 /** @internal @brief Only for unit tests. */
99 friend class TestAbstractDiagram;
100};
101
102} // namespace PerceptualColor
103
104#endif // ABSTRACTDIAGRAM_H
Base class for LCH diagrams.
This file provides support for C++ symbol import and export.
#define PERCEPTUALCOLOR_IMPORTEXPORT
A macro that either exports dynamic library symbols or imports dynamic library symbols or does nothin...
The namespace of this library.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:38 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.