• OctoMY API
  • OctoMY API Reference
  • C++ Classes
  • OctoMY
  • DragNumber
  • DragNumber Class

    A draggable box of one to four numbers. More...

    Header: #include <DragNumber>
    Since: 1.0
    Inherits: QWidget

    Public Functions

    DragNumber(QWidget *parent = nullptr)
    QRectF arrowRect(int component) const
    double componentValue(int component) const
    int displayDecimals() const
    DragNumberLook look() const
    qreal numberColumnWidth() const
    QFont numberFont() const
    QRectF numberRect(int component) const
    void setColumns(const DragNumber::Columns &columns)
    void setComponentCount(int count)
    void setComponentValue(int component, double v)
    void setComponentValues(const QList<double> &values)
    void setConfig(const dragmotor::AxisConfig &cfg)
    void setNumberFont(const QFont &font)
    void setPresentation(DragNumber::Presentation presentation)

    Reimplemented Public Functions

    virtual QSize minimumSizeHint() const override
    virtual QSize sizeHint() const override

    Static Public Members

    void alignColumns(const QList<DragNumber *> &boxes)
    QList<DragNumber::Columns> columnsFor(const QList<DragNumber::ColumnSource> &rows, const QFont &font)
    void paintLook(QPainter *painter, const QRect &rect, const DragNumberLook &look)

    Reimplemented Protected Functions

    virtual bool eventFilter(QObject *watched, QEvent *event) override

    Detailed Description

    A press and a vertical drag on a number change it through the shared DragMotor engine. A vector shows as one box, <x, y, z>, with one prefix and one suffix, and one number takes a drag at a time (vector-drag-number §VND-1).

    The default Field presentation draws the numbers in Typography::monospace() on a column grid: the decimal point of each number sits on one column, and a group of boxes that share their Columns (alignColumns()) put their points and arrows at one x (§VND-5, §VND-9). The step arrows paint on the hovered number only (§VND-6). The Paint presentation keeps paint's ModulationCell look bit for bit (§DN-2).

    See also dragmotor and dragnumberformat::layout().

    Member Function Documentation

    [explicit] DragNumber::DragNumber(QWidget *parent = nullptr)

    Creates a one-number box in the Field presentation with parent.

    The default config is the harness-tuned baseline of §DT-5.

    [static] void DragNumber::alignColumns(const QList<DragNumber *> &boxes)

    Aligns the live boxes of boxes: columnsFor() over them, then setColumns() on each. A box that nobody aligns is a group of one.

    QRectF DragNumber::arrowRect(int component) const

    Returns where the arrows of component paint: the separator after it, or the slot for the last number (§VND-4, C8).

    [static] QList<DragNumber::Columns> DragNumber::columnsFor(const QList<DragNumber::ColumnSource> &rows, const QFont &font)

    Returns one Columns per row of rows, in order.

    Rows group by component count and by whether they have a suffix, so a vector with no unit keeps its columns beside a vector with one (§VND-10). In a group, the fraction is the largest decimals, and the prefix and suffix widths are the widest, measured in font. The values do not depend on a number, so a host with no live box for a row gets the same result.

    double DragNumber::componentValue(int component) const

    Returns the value of component, or 0 for an index out of range.

    See also setComponentValue().

    int DragNumber::displayDecimals() const

    Returns the decimals that the box shows: the value of setDecimals(), else 2 for a signed range, and 1 or 2 by the size of the max for an unsigned range (§VND-5).

    [override virtual protected] bool DragNumber::eventFilter(QObject *watched, QEvent *event)

    Reimplements: QObject::eventFilter(QObject *watched, QEvent *event).

    Handles the editor's keys (§VND-7): Escape closes it with no change, Tab and Shift+Tab commit and open the next or the previous number, or pass the focus on from the last or the first.

    Filters event for watched, and returns true when it handled the key, which stops the event there.

    DragNumberLook DragNumber::look() const

    Returns every input of the paint as a value (config-ui §CFGP-1).

    [override virtual] QSize DragNumber::minimumSizeHint() const

    Reimplements an access function for property: QWidget::minimumSizeHint.

    Returns the smallest useful size: three columns per number in Field. Narrower, the numbers show '#' (§VND-8).

    qreal DragNumber::numberColumnWidth() const

    Returns the width of one column of the number grid.

    QFont DragNumber::numberFont() const

    Returns the face of the numbers: the one setNumberFont() gave, or Typography::monospace() at the widget's size.

    See also setNumberFont().

    QRectF DragNumber::numberRect(int component) const

    Returns the cell of the number component, in logical px.

    [static] void DragNumber::paintLook(QPainter *painter, const QRect &rect, const DragNumberLook &look)

    Paints look into rect of painter, the pixels the widget paints for the same look.

    An item delegate calls it to paint a number cell with no widget (config-ui §CFGV-5a). The paint is clipped to rect.

    void DragNumber::setColumns(const DragNumber::Columns &columns)

    Sets the values that this box shares with its group to columns.

    void DragNumber::setComponentCount(int count)

    Sets the number of components to count, clamped to 1..4.

    A new component takes the config's value. More than one component switches the box to Field (§VND-2).

    void DragNumber::setComponentValue(int component, double v)

    Sets component to v: sanitized and clamped, with no step snap and no signal (§OPR-3b).

    See also componentValue().

    void DragNumber::setComponentValues(const QList<double> &values)

    Sets every component from values, with one repaint.

    void DragNumber::setConfig(const dragmotor::AxisConfig &cfg)

    Sets the motor config of every component to cfg, and re-seeds every component from cfg.value.

    void DragNumber::setNumberFont(const QFont &font)

    Sets the face of the numbers to font.

    See also numberFont().

    void DragNumber::setPresentation(DragNumber::Presentation presentation)

    Sets the look to presentation.

    Paint takes one number only, so it also sets the component count to 1.

    [override virtual] QSize DragNumber::sizeHint() const

    Reimplements an access function for property: QWidget::sizeHint.

    Returns the size that shows the whole range at its decimals, or today's text-sized cell for Paint.

    In Field the width does not depend on the value (§VND-8, D6).