2 * This file is part of the PulseView project.
4 * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef PULSEVIEW_PV_WIDGETS_POPUP_HPP
21 #define PULSEVIEW_PV_WIDGETS_POPUP_HPP
23 #include <QScrollArea>
30 // A regular QScrollArea has a fixed size and provides scroll bars when the
31 // content can't be shown in its entirety. However, we want no horizontal
32 // scroll bar and want the scroll area to adjust its width to fit the content
34 // Inspired by https://stackoverflow.com/questions/21253755/qscrollarea-with-dynamically-changing-contents?answertab=votes#tab-top
35 class QWidthAdjustingScrollArea : public QScrollArea
40 QWidthAdjustingScrollArea(QWidget* parent = nullptr);
41 void setWidget(QWidget* w);
42 bool eventFilter(QObject* obj, QEvent* ev);
46 class Popup : public QWidget
60 static const unsigned int ArrowLength;
61 static const unsigned int ArrowOverlap;
62 static const unsigned int MarginWidth;
65 Popup(QWidget *parent);
67 const QPoint& point() const;
68 Position position() const;
70 void set_position(const QPoint point, Position pos);
72 bool eventFilter(QObject *obj, QEvent *event);
77 bool space_for_arrow() const;
79 QPolygon arrow_polygon() const;
81 QRegion arrow_region() const;
83 QRect bubble_rect() const;
85 QRegion bubble_region() const;
87 QRegion popup_region() const;
89 void reposition_widget();
92 void closeEvent(QCloseEvent*);
94 void paintEvent(QPaintEvent*);
96 void resizeEvent(QResizeEvent*);
98 void mouseReleaseEvent(QMouseEvent *event);
101 void showEvent(QShowEvent *);
111 } // namespace widgets
114 #endif // PULSEVIEW_PV_WIDGETS_POPUP_HPP