KDDockWidgets API Documentation 2.1
Loading...
Searching...
No Matches
qtwidgets/views/SegmentedDropIndicatorOverlay.cpp
Go to the documentation of this file.
1/*
2 This file is part of KDDockWidgets.
3
4 SPDX-FileCopyrightText: 2019 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5 Author: SĂ©rgio Martins <sergio.martins@kdab.com>
6
7 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
8
9 Contact KDAB at <info@kdab.com> for commercial licensing options.
10*/
11
13#include "kddockwidgets/core/indicators/SegmentedDropIndicatorOverlay.h"
14
15#include <QPainter>
16
17using namespace KDDockWidgets;
18using namespace KDDockWidgets::QtWidgets;
19
23
26 : View<QWidget>(controller, Core::ViewType::None, parent)
27 , m_controller(controller)
28{
29}
30
32
34{
35 QPainter p(this);
37 drawSegments(&p);
38}
39
40void SegmentedDropIndicatorOverlay::drawSegments(QPainter *p)
41{
42 const std::unordered_map<DropLocation, QPolygon> &segments = m_controller->segments();
43 for (DropLocation loc :
47 auto it = segments.find(loc);
48 const Polygon segment = it == segments.cend() ? Polygon() : it->second;
49 drawSegment(p, segment);
50 }
51}
52
53void SegmentedDropIndicatorOverlay::drawSegment(QPainter *p, const QPolygon &segment)
54{
55 if (segment.isEmpty())
56 return;
57
60 p->setPen(pen);
62
63 if (segment.containsPoint(m_controller->hoveredPt(), Qt::OddEvenFill))
65
66 p->setBrush(brush);
67 p->drawPolygon(segment);
68}
const std::unordered_map< DropLocation, Polygon > & segments() const
SegmentedDropIndicatorOverlay(Core::SegmentedDropIndicatorOverlay *controller, QWidget *parent=nullptr)
Class to abstract QAction, so code still works with QtQuick and Flutter.
@ None
Just use the defaults.
DropLocation
Enum describing the different drop indicator types.
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule)
void setBrush(const QBrush &brush)
void setPen(const QColor &color)
void setRenderHint(QPainter::RenderHint hint, bool on)
bool containsPoint(const QPoint &point, Qt::FillRule fillRule) const const
OddEvenFill
bool isEmpty() const const

© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDDockWidgets
Advanced Dock Widget Framework for Qt
https://www.kdab.com/development-resources/qt-tools/kddockwidgets/
Generated by doxygen 1.9.8