#include <QPainter>
#include <QRect>
+#include <pv/widgets/popup.h>
+
using namespace boost;
using namespace std;
void Header::mouseReleaseEvent(QMouseEvent *event)
{
+ using pv::widgets::Popup;
+
assert(event);
if (event->button() == Qt::LeftButton) {
+ if (_dragging)
+ _view.normalize_layout();
+ else
+ {
+ const shared_ptr<Trace> mouse_over_trace =
+ get_mouse_over_trace(event->pos());
+ if (mouse_over_trace) {
+ Popup *const p =
+ mouse_over_trace->create_popup(&_view);
+ p->set_position(mapToGlobal(QPoint(width(),
+ mouse_over_trace->get_y())),
+ Popup::Right);
+ p->show();
+ }
+ }
+
_dragging = false;
_drag_traces.clear();
- _view.normalize_layout();
}
}
#include "trace.h"
#include "view.h"
+#include <pv/widgets/popup.h>
+
namespace pv {
namespace view {
return menu;
}
+pv::widgets::Popup* Trace::create_popup(QWidget *parent)
+{
+ using pv::widgets::Popup;
+ Popup *const popup = new Popup(parent);
+ QFormLayout *const form = new QFormLayout(popup);
+ popup->setLayout(form);
+ populate_popup_form(popup, form);
+ return popup;
+}
+
int Trace::get_y() const
{
return _v_offset - _view->v_offset();
p.drawLine(QPointF(left, y + 0.5f), QPointF(right, y + 0.5f));
}
+void Trace::populate_popup_form(QWidget *parent, QFormLayout *form)
+{
+ form->addRow("Name", new QLineEdit(parent));
+}
+
void Trace::compute_text_size(QPainter &p)
{
_text_size = QSize(
class SigSession;
+namespace widgets {
+class Popup;
+}
+
namespace view {
class View;
virtual QMenu* create_context_menu(QWidget *parent);
-protected:
+ pv::widgets::Popup* create_popup(QWidget *parent);
+
/**
* Gets the y-offset of the axis.
*/
int get_y() const;
+protected:
/**
* Gets the text colour.
* @remarks This colour is computed by comparing the lightness
*/
void paint_axis(QPainter &p, int y, int left, int right);
+ virtual void populate_popup_form(QWidget *parent, QFormLayout *form);
+
private:
/**