]> sigrok.org Git - pulseview.git/commitdiff
Added TimeMarker popups
authorJoel Holdsworth <redacted>
Sun, 29 Sep 2013 14:08:58 +0000 (23:08 +0900)
committerJoel Holdsworth <redacted>
Sun, 13 Oct 2013 10:05:23 +0000 (11:05 +0100)
pv/view/ruler.cpp
pv/view/selectableitem.h
pv/view/timemarker.cpp
pv/view/timemarker.h
pv/view/trace.h

index 06cd1b1540ba3dca171d2cd286cdc35f66d1fd86..ad7082e63bf35a62d7c785ebfe3395db0d58b5db 100644 (file)
@@ -34,6 +34,8 @@
 #include <QPainter>
 #include <QTextStream>
 
+#include <pv/widgets/popup.h>
+
 using namespace boost;
 using namespace std;
 
@@ -225,6 +227,16 @@ void Ruler::mousePressEvent(QMouseEvent *e)
 
 void Ruler::mouseReleaseEvent(QMouseEvent *)
 {
+       using pv::widgets::Popup;
+
+       if (!_dragging)
+               if (shared_ptr<TimeMarker> m = _grabbed_marker.lock()) {
+                       Popup *const p = m->create_popup(&_view);
+                       p->set_position(mapToGlobal(QPoint(m->get_x(),
+                               height())), Popup::Bottom);
+                       p->show();
+               }
+
        _dragging = false;
        _grabbed_marker.reset();
 }
index 41f6811776bcc0fbc43f9df41fcf3db180c39b94..fa728c72745924f764c692a88b5fdb91c868aff0 100644 (file)
@@ -30,6 +30,11 @@ class QMenu;
 class QWidget;
 
 namespace pv {
+
+namespace widgets {
+class Popup;
+}
+
 namespace view {
 
 class SelectableItem : public QObject
@@ -56,6 +61,8 @@ public:
 public:
        virtual QMenu* create_context_menu(QWidget *parent);
 
+       virtual pv::widgets::Popup* create_popup(QWidget *parent) = 0;
+
 protected:
        static QPen highlight_pen();
 
index 40bb81731884c54fec36b1ed18bba5195c0879df..4c3645b4cd2b19e529efd0a2c8f43348b10fac6c 100644 (file)
@@ -24,6 +24,8 @@
 
 #include <QPainter>
 
+#include <pv/widgets/popup.h>
+
 using namespace std;
 
 namespace pv {
@@ -69,6 +71,28 @@ void TimeMarker::paint(QPainter &p, const QRect &rect)
        p.drawLine(QPointF(x, rect.top()), QPointF(x, rect.bottom()));
 }
 
+pv::widgets::Popup* TimeMarker::create_popup(QWidget *parent)
+{
+       using pv::widgets::Popup;
+
+       Popup *const popup = new Popup(parent);
+       QFormLayout *const form = new QFormLayout(popup);
+       popup->setLayout(form);
+
+       _value_widget = new QDoubleSpinBox(parent);
+       _value_widget->setValue(_time);
+       _value_widget->setDecimals(6);
+       _value_widget->setSuffix("s");
+       _value_widget->setSingleStep(1e-6);
+
+       connect(_value_widget, SIGNAL(valueChanged(double)),
+               this, SLOT(on_value_changed(double)));
+
+       form->addRow(tr("Time"), _value_widget);
+
+       return popup;
+}
+
 void TimeMarker::on_value_changed(double value)
 {
        if (!_updating_value_widget) {
index 03fdd0fb2e0d55faeab68ddd1f4881cfdc8f4679..fc058c2713134bab227eeb6ec0cece3c1d0f43a1 100644 (file)
@@ -86,6 +86,8 @@ public:
        virtual void paint_label(QPainter &p, const QRect &rect,
                unsigned int prefix) = 0;
 
+       pv::widgets::Popup* create_popup(QWidget *parent);
+
 private slots:
        void on_value_changed(double value);
 
index ff65a2138536945d2f95115ffbfc38738331862c..bae5d253619e783f0553f8365fa187dcd75affe3 100644 (file)
@@ -35,10 +35,6 @@ namespace pv {
 
 class SigSession;
 
-namespace widgets {
-class Popup;
-}
-
 namespace view {
 
 class View;