X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fview%2Ftrace.h;h=7fd8c67afb8e917a5384d27fe87b61edd996c7b0;hb=0067d80499d36944277e6fed2d7ad5394c85c03f;hp=05adf6cf58b1b579d9b5e969bef33bb1175c8e21;hpb=bda016e024cb6785fc4d0b49e60aa7bcbd7fba95;p=pulseview.git diff --git a/pv/view/trace.h b/pv/view/trace.h index 05adf6cf..7fd8c67a 100644 --- a/pv/view/trace.h +++ b/pv/view/trace.h @@ -29,17 +29,19 @@ #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 @@ -48,13 +50,13 @@ private: 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. @@ -64,7 +66,7 @@ public: /** * Get the colour of the signal. */ - QColor get_colour() const; + QColor colour() const; /** * Set the colour of the signal. @@ -72,48 +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 background layer of 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_back(QPainter &p, int left, int right); - - /** - * Paints the mid-layer of 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_mid(QPainter &p, int left, int right); - - /** - * Paints the foreground layer of 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_fore(QPainter &p, int left, int right); - - /** - * 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. @@ -121,26 +82,20 @@ public: */ virtual void paint_label(QPainter &p, int right, bool hover); - /** - * Determines if a point is in the header label rect. - * @param left the x-coordinate of the left edge of the header - * area. - * @param right the x-coordinate of the right edge of the header - * area. - * @param point the point to test. - */ - bool pt_in_label_rect(int left, int right, const QPoint &point); - virtual QMenu* create_context_menu(QWidget *parent); pv::widgets::Popup* create_popup(QWidget *parent); /** - * Gets the y-offset of the axis. + * Computes the outline rectangle of a label. + * @param right the x-coordinate of the right edge of the header + * area. + * @return Returns the rectangle of the signal label. */ - int get_y() const; + QRectF label_rect(int right) const; protected: + /** * Gets the text colour. * @remarks This colour is computed by comparing the lightness @@ -160,42 +115,29 @@ protected: void add_colour_option(QWidget *parent, QFormLayout *form); - virtual void populate_popup_form(QWidget *parent, QFormLayout *form); - -private: - - /** - * Computes an caches the size of the label text. - */ - void compute_text_size(QPainter &p); + void create_popup_form(); - /** - * 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. - */ - QRectF get_label_rect(int right); + virtual void populate_popup_form(QWidget *parent, QFormLayout *form); -private slots: +private Q_SLOTS: void on_text_changed(const QString &text); void on_colour_changed(const QColor &colour); -signals: + void on_popup_closed(); + +Q_SIGNALS: + void visibility_changed(); void text_changed(); void colour_changed(); protected: - pv::SigSession &_session; - pv::view::View *_view; - QString _name; QColor _colour; - int _v_offset; - QSizeF _text_size; +private: + pv::widgets::Popup *_popup; + QFormLayout *_popup_form; }; } // namespace view