/* nanogui/slider.h -- Fractional slider widget with mouse control NanoGUI was developed by Wenzel Jakob . The widget drawing code is based on the NanoVG demo application by Mikko Mononen. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE.txt file. */ /** \file */ #pragma once #include NAMESPACE_BEGIN(nanogui) /** * \class Slider slider.h nanogui/slider.h * * \brief Fractional slider widget with mouse control. */ class NANOGUI_EXPORT Slider : public Widget { public: Slider(Widget *parent); float value() const { return mValue; } void setValue(float value) { mValue = value; } const Color &highlightColor() const { return mHighlightColor; } void setHighlightColor(const Color &highlightColor) { mHighlightColor = highlightColor; } std::pair range() const { return mRange; } void setRange(std::pair range) { mRange = range; } std::pair highlightedRange() const { return mHighlightedRange; } void setHighlightedRange(std::pair highlightedRange) { mHighlightedRange = highlightedRange; } std::function callback() const { return mCallback; } void setCallback(const std::function &callback) { mCallback = callback; } std::function finalCallback() const { return mFinalCallback; } void setFinalCallback(const std::function &callback) { mFinalCallback = callback; } virtual Vector2i preferredSize(NVGcontext *ctx) const override; virtual bool mouseDragEvent(const Vector2i &p, const Vector2i &rel, int button, int modifiers) override; virtual bool mouseButtonEvent(const Vector2i &p, int button, bool down, int modifiers) override; virtual void draw(NVGcontext* ctx) override; virtual void save(Serializer &s) const override; virtual bool load(Serializer &s) override; protected: float mValue; std::function mCallback; std::function mFinalCallback; std::pair mRange; std::pair mHighlightedRange; Color mHighlightColor; public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; NAMESPACE_END(nanogui)