From 214470fc17e73bbf4664f4c1678a7dd30c905bf2 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Mon, 31 Aug 2015 20:13:08 -0600 Subject: [PATCH] Signal: Added scale_handle_offset, scale_handle_dragged and scale_handle_released --- pv/view/analogsignal.cpp | 10 ++++++++++ pv/view/analogsignal.hpp | 11 +++++++++++ pv/view/logicsignal.cpp | 10 ++++++++++ pv/view/logicsignal.hpp | 11 +++++++++++ pv/view/signal.hpp | 16 ++++++++++++++++ 5 files changed, 58 insertions(+) diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index efde294..df1edcf 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -82,6 +82,16 @@ std::pair AnalogSignal::v_extents() const return make_pair(-NominalHeight / 2, NominalHeight / 2); } +int AnalogSignal::scale_handle_offset() const +{ + return -NominalHeight / 3; +} + +void AnalogSignal::scale_handle_dragged(int offset) +{ + (void)offset; +} + void AnalogSignal::paint_back(QPainter &p, const ViewItemPaintParams &pp) { if (channel_->enabled()) diff --git a/pv/view/analogsignal.hpp b/pv/view/analogsignal.hpp index 72ff23b..58c2d3c 100644 --- a/pv/view/analogsignal.hpp +++ b/pv/view/analogsignal.hpp @@ -59,6 +59,17 @@ public: */ std::pair v_extents() const; + /** + * Returns the offset to show the drag handle. + */ + int scale_handle_offset() const; + + /** + * Handles the scale handle being dragged to an offset. + * @param offset the offset the scale handle was dragged to. + */ + void scale_handle_dragged(int offset); + /** * Paints the background layer of the signal with a QPainter * @param p the QPainter to paint into. diff --git a/pv/view/logicsignal.cpp b/pv/view/logicsignal.cpp index d529cab..573d1b7 100644 --- a/pv/view/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -150,6 +150,16 @@ std::pair LogicSignal::v_extents() const return make_pair(-SignalHeight - SignalMargin, SignalMargin); } +int LogicSignal::scale_handle_offset() const +{ + return SignalHeight; +} + +void LogicSignal::scale_handle_dragged(int offset) +{ + (void)offset; +} + void LogicSignal::paint_back(QPainter &p, const ViewItemPaintParams &pp) { if (channel_->enabled()) diff --git a/pv/view/logicsignal.hpp b/pv/view/logicsignal.hpp index 0705613..71dcc03 100644 --- a/pv/view/logicsignal.hpp +++ b/pv/view/logicsignal.hpp @@ -86,6 +86,17 @@ public: */ std::pair v_extents() const; + /** + * Returns the offset to show the drag handle. + */ + int scale_handle_offset() const; + + /** + * Handles the scale handle being dragged to an offset. + * @param offset the offset the scale handle was dragged to. + */ + void scale_handle_dragged(int offset); + /** * Paints the background layer of the signal with a QPainter * @param p the QPainter to paint into. diff --git a/pv/view/signal.hpp b/pv/view/signal.hpp index d96a85c..714b44f 100644 --- a/pv/view/signal.hpp +++ b/pv/view/signal.hpp @@ -81,6 +81,22 @@ public: void delete_pressed(); + /** + * Returns the offset to show the drag handle. + */ + virtual int scale_handle_offset() const = 0; + + /** + * Handles the scale handle being dragged to an offset. + * @param offset the offset the scale handle was dragged to. + */ + virtual void scale_handle_dragged(int offset) = 0; + + /** + * Handles the scale handle being being released. + */ + virtual void scale_handle_released() {}; + private Q_SLOTS: void on_disable(); -- 2.30.2