X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fviews%2Ftrace%2Fruler.hpp;h=d7cab4d74caa54f1ef4600d9d1bf37a9d1f0bef8;hp=448204b2410410bb7e78c7f635c2392d49937603;hb=581724de334181fc5338f1efa87954264cf90520;hpb=4a07615736968fc8d635c8d187b8a5d6b8a0e2eb diff --git a/pv/views/trace/ruler.hpp b/pv/views/trace/ruler.hpp index 448204b2..d7cab4d7 100644 --- a/pv/views/trace/ruler.hpp +++ b/pv/views/trace/ruler.hpp @@ -46,6 +46,12 @@ namespace trace { class TimeItem; class ViewItem; +struct TickPositions +{ + vector> major; + vector minor; +}; + /** * The Ruler class manages and displays the time scale above the trace canvas. * It may also contain @ref TimeItem instances used to identify or highlight @@ -69,7 +75,6 @@ private: public: Ruler(View &parent); -public: QSize sizeHint() const override; /** @@ -112,6 +117,12 @@ public: unsigned precision = 0, bool sign = true); + pv::util::Timestamp get_time_from_x_pos(uint32_t x) const; + +protected: + virtual void contextMenuEvent(QContextMenuEvent *event) override; + void resizeEvent(QResizeEvent*) override; + private: /** * Gets the time items. @@ -126,10 +137,10 @@ private: */ shared_ptr get_mouse_over_item(const QPoint &pt) override; - void paintEvent(QPaintEvent *event) override; - void mouseDoubleClickEvent(QMouseEvent *event) override; + void paintEvent(QPaintEvent *event) override; + /** * Draw a hover arrow under the cursor position. * @param p The painter to draw into. @@ -139,18 +150,6 @@ private: int calculate_text_height() const; - struct TickPositions - { - vector> major; - vector minor; - }; - - /** - * Holds the tick positions so that they don't have to be recalculated on - * every redraw. Set by 'paintEvent()' when needed. - */ - boost::optional tick_position_cache_; - /** * Calculates the major and minor tick positions. * @@ -171,14 +170,22 @@ private: const unsigned int minor_tick_count, function format_function); -protected: - void resizeEvent(QResizeEvent*) override; - private Q_SLOTS: - void hover_point_changed(const QPoint &hp); + void on_hover_point_changed(const QWidget* widget, const QPoint &hp); - // Resets the 'tick_position_cache_'. void invalidate_tick_position_cache(); + + void on_createMarker(); + void on_toggleHoverMarker(); + +private: + /** + * Holds the tick positions so that they don't have to be recalculated on + * every redraw. Set by 'paintEvent()' when needed. + */ + boost::optional tick_position_cache_; + + uint32_t context_menu_x_pos_; }; } // namespace trace