From: Joel Holdsworth Date: Tue, 1 Sep 2015 02:13:08 +0000 (-0600) Subject: Signal: Added scale_handle_offset, scale_handle_dragged and scale_handle_released X-Git-Tag: pulseview-0.3.0~76 X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=214470fc17e73bbf4664f4c1678a7dd30c905bf2 Signal: Added scale_handle_offset, scale_handle_dragged and scale_handle_released --- diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index efde2941..df1edcf9 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 72ff23b3..58c2d3cb 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 d529cabf..573d1b78 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 0705613e..71dcc036 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 d96a85cf..714b44f6 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();