fabric/rangeslider.h

fabric/rangeslider.h

fabric/rangeslider.h

Classes

Name
classRangeSlider

Source code

/*
 * Copyright (c) Kitware Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0.txt
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <QSlider>

class QStylePainter;
class RangeSliderPrivate;

class RangeSlider : public QSlider
{
    Q_OBJECT
#if !defined(DOXYGEN_SHOULD_SKIP_THIS)
    Q_PROPERTY(int minimumValue READ minimumValue WRITE setMinimumValue)
    Q_PROPERTY(int maximumValue READ maximumValue WRITE setMaximumValue)
    Q_PROPERTY(int minimumPosition READ minimumPosition WRITE setMinimumPosition)
    Q_PROPERTY(int maximumPosition READ maximumPosition WRITE setMaximumPosition)
    Q_PROPERTY(bool symmetricMoves READ symmetricMoves WRITE setSymmetricMoves)
    Q_PROPERTY(QString handleToolTip READ handleToolTip WRITE setHandleToolTip)
#endif

public:
    // Superclass typedef
    typedef QSlider Superclass;
    explicit RangeSlider(Qt::Orientation o, QWidget *par = nullptr);
    explicit RangeSlider(QWidget *par = nullptr);
    virtual ~RangeSlider();

    int minimumValue() const;

    int maximumValue() const;

    int minimumPosition() const;
    void setMinimumPosition(int min);

    int maximumPosition() const;
    void setMaximumPosition(int max);

    void setPositions(int min, int max);

    bool symmetricMoves() const;
    void setSymmetricMoves(bool symmetry);

    QString handleToolTip() const;
    void setHandleToolTip(const QString &toolTip);

    bool isMinimumSliderDown() const;
    bool isMaximumSliderDown() const;

Q_SIGNALS:
    void minimumValueChanged(int min);
    void maximumValueChanged(int max);
    void valuesChanged(int min, int max);

    void minimumPositionChanged(int min);

    void maximumPositionChanged(int max);

    void positionsChanged(int min, int max);

public Q_SLOTS:
    void setMinimumValue(int min);

    void setMaximumValue(int max);

    void setValues(int min, int max);

protected Q_SLOTS:
    void onRangeChanged(int minimum, int maximum);

protected:
    RangeSlider(RangeSliderPrivate *impl, Qt::Orientation o, QWidget *par = nullptr);
    RangeSlider(RangeSliderPrivate *impl, QWidget *par = nullptr);

    // Description:
    // Standard Qt UI events
    virtual void mousePressEvent(QMouseEvent *ev) override;
    virtual void mouseMoveEvent(QMouseEvent *ev) override;
    virtual void mouseReleaseEvent(QMouseEvent *ev) override;

    // Description:
    // Rendering is done here.
    virtual void paintEvent(QPaintEvent *ev) override;
    virtual void initMinimumSliderStyleOption(QStyleOptionSlider *option) const;
    virtual void initMaximumSliderStyleOption(QStyleOptionSlider *option) const;

    // Description:
    // Reimplemented for the tooltips
    virtual bool event(QEvent *event) override;

protected:
    QScopedPointer<RangeSliderPrivate> d_ptr;

private:
    Q_DECLARE_PRIVATE(RangeSlider);
    Q_DISABLE_COPY(RangeSlider);
};

Updated on 2024-11-06 at 17:10:29 +0000