X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Ftrace.h;h=83eb826546184e87e91005a7e461cb9e1f8bc5fc;hp=ffd87fa45524feae6e5d2cade3d3ef86cdb368da;hb=6dcdb3258f6f0b25e69154b5919405a194b7e724;hpb=e0fc58100fbcd6c3bfd5aecb213d7541a3436622 diff --git a/pv/view/trace.h b/pv/view/trace.h index ffd87fa4..83eb8265 100644 --- a/pv/view/trace.h +++ b/pv/view/trace.h @@ -18,41 +18,45 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_TRACE_H -#define PULSEVIEW_PV_TRACE_H +#ifndef PULSEVIEW_PV_VIEW_TRACE_H +#define PULSEVIEW_PV_VIEW_TRACE_H #include #include +#include #include #include #include -#include "selectableitem.h" +#include "rowitem.h" + +class QFormLayout; namespace pv { -class SigSession; +namespace widgets { +class Popup; +} namespace view { -class View; - -class Trace : public SelectableItem +class Trace : public RowItem { Q_OBJECT private: + static const QPen AxisPen; static const int LabelHitPadding; protected: - Trace(SigSession &session, QString name); + Trace(QString name); public: /** * Gets the name of this signal. */ - QString get_name() const; + QString name() const; /** * Sets the name of the signal. @@ -62,7 +66,7 @@ public: /** * Get the colour of the signal. */ - QColor get_colour() const; + QColor colour() const; /** * Set the colour of the signal. @@ -70,32 +74,7 @@ public: void set_colour(QColor colour); /** - * Gets the vertical layout offset of this signal. - */ - int get_v_offset() const; - - /** - * Sets the vertical layout offset of this signal. - */ - void set_v_offset(int v_offset); - - /** - * Returns true if the trace is visible and enabled. - */ - virtual bool enabled() const = 0; - - virtual void set_view(pv::view::View *view); - - /** - * Paints the trace with a QPainter - * @param p the QPainter to paint into. - * @param left the x-coordinate of the left edge of the signal - * @param right the x-coordinate of the right edge of the signal - **/ - virtual void paint(QPainter &p, int left, int right) = 0; - - /** - * Paints the signal label into a QGLWidget. + * Paints the signal label. * @param p the QPainter to paint into. * @param right the x-coordinate of the right edge of the header * area. @@ -103,47 +82,60 @@ public: */ virtual void paint_label(QPainter &p, int right, bool hover); + virtual QMenu* create_context_menu(QWidget *parent); + + pv::widgets::Popup* create_popup(QWidget *parent); + /** - * Determines if a point is in the header label rect. - * @param left the x-coordinate of the left edge of the header - * area. + * Computes the outline rectangle of a label. * @param right the x-coordinate of the right edge of the header * area. - * @param point the point to test. + * @return Returns the rectangle of the signal label. */ - bool pt_in_label_rect(int left, int right, const QPoint &point); + QRectF label_rect(int right) const; -private: +protected: /** - * Computes an caches the size of the label text. + * Gets the text colour. + * @remarks This colour is computed by comparing the lightness + * of the trace colour against a threshold to determine whether + * white or black would be more visible. */ - void compute_text_size(QPainter &p); + QColor get_text_colour() const; /** - * Computes the outline rectangle of a label. - * @param p the QPainter to lay out text with. - * @param right the x-coordinate of the right edge of the header - * area. - * @return Returns the rectangle of the signal label. + * Paints a zero axis across the viewport. + * @param p the QPainter to paint into. + * @param y the y-offset of the axis. + * @param left the x-coordinate of the left edge of the view. + * @param right the x-coordinate of the right edge of the view. */ - QRectF get_label_rect(int right); + void paint_axis(QPainter &p, int y, int left, int right); -signals: - void text_changed(); + void add_colour_option(QWidget *parent, QFormLayout *form); -protected: - pv::SigSession &_session; - pv::view::View *_view; + void create_popup_form(); + + virtual void populate_popup_form(QWidget *parent, QFormLayout *form); + +private Q_SLOTS: + void on_text_changed(const QString &text); + void on_colour_changed(const QColor &colour); + + void on_popup_closed(); + +protected: QString _name; QColor _colour; - int _v_offset; - QSizeF _text_size; +private: + pv::widgets::Popup *_popup; + QFormLayout *_popup_form; }; } // namespace view } // namespace pv -#endif // PULSEVIEW_PV_TRACEL_H +#endif // PULSEVIEW_PV_VIEW_TRACE_H