#include "view.h"
#include <QApplication>
+#include <QFontMetrics>
#include <QMouseEvent>
#include <pv/widgets/popup.h>
namespace pv {
namespace view {
-const int CursorHeader::CursorHeaderHeight = 26;
+const int CursorHeader::Padding = 20;
+
+int CursorHeader::calculateTextHeight()
+{
+ QFontMetrics fm(font());
+ return fm.boundingRect(0, 0, INT_MAX, INT_MAX,
+ Qt::AlignLeft | Qt::AlignTop, "8").height();
+}
CursorHeader::CursorHeader(View &parent) :
MarginWidget(parent),
- _dragging(false)
+ _dragging(false),
+ _textHeight(calculateTextHeight())
{
setMouseTracking(true);
}
QSize CursorHeader::sizeHint() const
{
- return QSize(0, CursorHeaderHeight);
+ return QSize(0, _textHeight + Padding);
}
void CursorHeader::clear_selection()
{
Q_OBJECT
+ static const int Padding;
+
public:
CursorHeader(View &parent);
void mousePressEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *);
- static const int CursorHeaderHeight;
+ int calculateTextHeight();
std::weak_ptr<TimeMarker> _grabbed_marker;
QPoint _mouse_down_point;
bool _dragging;
+ const int _textHeight;
};
} // namespace view