X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fruler.hpp;h=50bbf2cdc0038075d8fbdea98cc0ba2b3af938fa;hp=438b862c53440c12d41e3f8fce33c76d6e98c05a;hb=7a01bd3654ed046216308fa64edfd79be7cd525f;hpb=2acdb232d6bb452cfdfaea3ef5218fb4da592329 diff --git a/pv/view/ruler.hpp b/pv/view/ruler.hpp index 438b862c..50bbf2cd 100644 --- a/pv/view/ruler.hpp +++ b/pv/view/ruler.hpp @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_RULER_H -#define PULSEVIEW_PV_VIEW_RULER_H +#ifndef PULSEVIEW_PV_VIEW_RULER_HPP +#define PULSEVIEW_PV_VIEW_RULER_HPP #include @@ -28,43 +28,65 @@ namespace pv { namespace view { +class TimeItem; +class ViewItem; + class Ruler : public MarginWidget { Q_OBJECT private: - static const int RulerHeight; + + /// Height of the ruler in multipes of the text height + static const float RulerHeight; + static const int MinorTickSubdivision; - static const int ScaleUnits[3]; - static const int HoverArrowSize; + /// Height of the hover arrow in multiples of the text height + static const float HoverArrowSize; public: Ruler(View &parent); +public: + QSize sizeHint() const; + /** - * Find a tick spacing and number formatting that does not cause - * the values to collide. - * @param p A QPainter used to determine the needed space for the values. - * @param scale A pv::view::View's scale. - * @param offset A pv::view::View's offset. - * - * @return The tick period to use in 'first' and the prefix in 'second'. + * The extended area that the header widget would like to be sized to. + * @remarks This area is the area specified by sizeHint, extended by + * the area to overlap the viewport. */ - static std::pair calculate_tick_spacing( - QPainter& p, double scale, double offset); + QSize extended_size_hint() const; -public: - QSize sizeHint() const; +private: + /** + * Gets the time items. + */ + std::vector< std::shared_ptr > items(); + + /** + * Gets the first view item which has a label that contains @c pt . + * @param pt the point to search with. + * @return the view item that has been found, or and empty + * @c shared_ptr if no item was found. + */ + std::shared_ptr get_mouse_over_item( + const QPoint &pt); private: void paintEvent(QPaintEvent *event); + void mouseDoubleClickEvent(QMouseEvent *e); + private: /** * Draw a hover arrow under the cursor position. + * @param p The painter to draw into. + * @param text_height The height of a single text ascent. */ - void draw_hover_mark(QPainter &p); + void draw_hover_mark(QPainter &p, int text_height); + + int calculate_text_height() const; private Q_SLOTS: void hover_point_changed(); @@ -73,4 +95,4 @@ private Q_SLOTS: } // namespace view } // namespace pv -#endif // PULSEVIEW_PV_VIEW_RULER_H +#endif // PULSEVIEW_PV_VIEW_RULER_HPP