DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit 8f99465b717e816cb301548d7d3790de56c9ec28
parent 90898bce5f76a2abe13f0cd352ae9655ef8a8d0c
Author: falkTX <falktx@gmail.com>
Date:   Tue,  5 May 2015 01:16:10 +0200

Move all Image Widgets definitions into a single file

Diffstat:
Mdgl/ImageAboutWindow.hpp | 35++---------------------------------
Mdgl/ImageButton.hpp | 48++----------------------------------------------
Mdgl/ImageKnob.hpp | 87++-----------------------------------------------------------------------------
Mdgl/ImageSlider.hpp | 78++----------------------------------------------------------------------------
Mdgl/ImageSwitch.hpp | 46++--------------------------------------------
Adgl/ImageWidgets.hpp | 273+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdgl/Widget.hpp | 1+
Mdgl/src/ImageAboutWindow.cpp | 2+-
Mdgl/src/ImageButton.cpp | 2+-
Mdgl/src/ImageKnob.cpp | 2+-
Mdgl/src/ImageSlider.cpp | 2+-
Mdgl/src/ImageSwitch.cpp | 2+-
12 files changed, 289 insertions(+), 289 deletions(-)

diff --git a/dgl/ImageAboutWindow.hpp b/dgl/ImageAboutWindow.hpp @@ -17,38 +17,7 @@ #ifndef DGL_IMAGE_ABOUT_WINDOW_HPP_INCLUDED #define DGL_IMAGE_ABOUT_WINDOW_HPP_INCLUDED -#include "Image.hpp" -#include "Widget.hpp" -#include "Window.hpp" - -START_NAMESPACE_DGL - -// ----------------------------------------------------------------------- - -class ImageAboutWindow : public Window, - public Widget -{ -public: - explicit ImageAboutWindow(Window& parent, const Image& image = Image()); - explicit ImageAboutWindow(Widget* widget, const Image& image = Image()); - - void setImage(const Image& image); - -protected: - void onDisplay() override; - bool onKeyboard(const KeyboardEvent&) override; - bool onMouse(const MouseEvent&) override; - void onReshape(uint width, uint height) override; - -private: - Image fImgBackground; - - DISTRHO_DECLARE_NON_COPY_CLASS(ImageAboutWindow) - //DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ImageAboutWindow) -}; - -// ----------------------------------------------------------------------- - -END_NAMESPACE_DGL +#warning This is a deprecated file, please include ImageWidgets.hpp instead. +#include "ImageWidgets.hpp" #endif // DGL_IMAGE_ABOUT_WINDOW_HPP_INCLUDED diff --git a/dgl/ImageButton.hpp b/dgl/ImageButton.hpp @@ -17,51 +17,7 @@ #ifndef DGL_IMAGE_BUTTON_HPP_INCLUDED #define DGL_IMAGE_BUTTON_HPP_INCLUDED -#include "Image.hpp" -#include "Widget.hpp" - -START_NAMESPACE_DGL - -// ----------------------------------------------------------------------- - -class ImageButton : public Widget -{ -public: - class Callback - { - public: - virtual ~Callback() {} - virtual void imageButtonClicked(ImageButton* imageButton, int button) = 0; - }; - - explicit ImageButton(Window& parent, const Image& image) noexcept; - explicit ImageButton(Window& parent, const Image& imageNormal, const Image& imageHover, const Image& imageDown) noexcept; - explicit ImageButton(Widget* widget, const Image& image) noexcept; - explicit ImageButton(Widget* widget, const Image& imageNormal, const Image& imageHover, const Image& imageDown) noexcept; - explicit ImageButton(const ImageButton& imageButton) noexcept; - ImageButton& operator=(const ImageButton& imageButton) noexcept; - - void setCallback(Callback* callback) noexcept; - -protected: - void onDisplay() override; - bool onMouse(const MouseEvent&) override; - bool onMotion(const MotionEvent&) override; - -private: - Image fImageNormal; - Image fImageHover; - Image fImageDown; - Image* fCurImage; - int fCurButton; - - Callback* fCallback; - - DISTRHO_LEAK_DETECTOR(ImageButton) -}; - -// ----------------------------------------------------------------------- - -END_NAMESPACE_DGL +#warning This is a deprecated file, please include ImageWidgets.hpp instead. +#include "ImageWidgets.hpp" #endif // DGL_IMAGE_BUTTON_HPP_INCLUDED diff --git a/dgl/ImageKnob.hpp b/dgl/ImageKnob.hpp @@ -17,90 +17,7 @@ #ifndef DGL_IMAGE_KNOB_HPP_INCLUDED #define DGL_IMAGE_KNOB_HPP_INCLUDED -#include "Image.hpp" -#include "Widget.hpp" - -START_NAMESPACE_DGL - -// ----------------------------------------------------------------------- - -class ImageKnob : public Widget -{ -public: - enum Orientation { - Horizontal, - Vertical - }; - - class Callback - { - public: - virtual ~Callback() {} - virtual void imageKnobDragStarted(ImageKnob* imageKnob) = 0; - virtual void imageKnobDragFinished(ImageKnob* imageKnob) = 0; - virtual void imageKnobValueChanged(ImageKnob* imageKnob, float value) = 0; - }; - - explicit ImageKnob(Window& parent, const Image& image, Orientation orientation = Vertical) noexcept; - explicit ImageKnob(Widget* widget, const Image& image, Orientation orientation = Vertical) noexcept; - explicit ImageKnob(const ImageKnob& imageKnob); - ImageKnob& operator=(const ImageKnob& imageKnob); - ~ImageKnob() override; - - float getValue() const noexcept; - - void setDefault(float def) noexcept; - void setRange(float min, float max) noexcept; - void setStep(float step) noexcept; - void setValue(float value, bool sendCallback = false) noexcept; - void setUsingLogScale(bool yesNo) noexcept; - - void setCallback(Callback* callback) noexcept; - void setOrientation(Orientation orientation) noexcept; - void setRotationAngle(int angle); - - void setImageLayerCount(uint count) noexcept; - -protected: - void onDisplay() override; - bool onMouse(const MouseEvent&) override; - bool onMotion(const MotionEvent&) override; - bool onScroll(const ScrollEvent&) override; - -private: - Image fImage; - float fMinimum; - float fMaximum; - float fStep; - float fValue; - float fValueDef; - float fValueTmp; - bool fUsingDefault; - bool fUsingLog; - Orientation fOrientation; - - int fRotationAngle; - bool fDragging; - int fLastX; - int fLastY; - - Callback* fCallback; - - bool fIsImgVertical; - uint fImgLayerWidth; - uint fImgLayerHeight; - uint fImgLayerCount; - bool fIsReady; - GLuint fTextureId; - - float _logscale(float value) const; - float _invlogscale(float value) const; - - DISTRHO_LEAK_DETECTOR(ImageKnob) -}; - -// ----------------------------------------------------------------------- - -END_NAMESPACE_DGL +#warning This is a deprecated file, please include ImageWidgets.hpp instead. +#include "ImageWidgets.hpp" #endif // DGL_IMAGE_KNOB_HPP_INCLUDED diff --git a/dgl/ImageSlider.hpp b/dgl/ImageSlider.hpp @@ -17,81 +17,7 @@ #ifndef DGL_IMAGE_SLIDER_HPP_INCLUDED #define DGL_IMAGE_SLIDER_HPP_INCLUDED -#include "Image.hpp" -#include "Widget.hpp" - -START_NAMESPACE_DGL - -// ----------------------------------------------------------------------- - -class ImageSlider : public Widget -{ -public: - class Callback - { - public: - virtual ~Callback() {} - virtual void imageSliderDragStarted(ImageSlider* imageSlider) = 0; - virtual void imageSliderDragFinished(ImageSlider* imageSlider) = 0; - virtual void imageSliderValueChanged(ImageSlider* imageSlider, float value) = 0; - }; - - explicit ImageSlider(Window& parent, const Image& image) noexcept; - explicit ImageSlider(Widget* widget, const Image& image) noexcept; - explicit ImageSlider(const ImageSlider& imageSlider) noexcept; - ImageSlider& operator=(const ImageSlider& imageSlider) noexcept; - - float getValue() const noexcept; - - void setStartPos(const Point<int>& startPos) noexcept; - void setStartPos(int x, int y) noexcept; - void setEndPos(const Point<int>& endPos) noexcept; - void setEndPos(int x, int y) noexcept; - - void setInverted(bool inverted) noexcept; - void setRange(float min, float max) noexcept; - void setStep(float step) noexcept; - void setValue(float value, bool sendCallback = false) noexcept; - - void setCallback(Callback* callback) noexcept; - -protected: - void onDisplay() override; - bool onMouse(const MouseEvent&) override; - bool onMotion(const MotionEvent&) override; - -private: - Image fImage; - float fMinimum; - float fMaximum; - float fStep; - float fValue; - float fValueTmp; - - bool fDragging; - bool fInverted; - int fStartedX; - int fStartedY; - - Callback* fCallback; - - Point<int> fStartPos; - Point<int> fEndPos; - Rectangle<int> fSliderArea; - - void _recheckArea() noexcept; - - // these should not be used - void setAbsoluteX(int) const noexcept {} - void setAbsoluteY(int) const noexcept {} - void setAbsolutePos(int, int) const noexcept {} - void setAbsolutePos(const Point<int>&) const noexcept {} - - DISTRHO_LEAK_DETECTOR(ImageSlider) -}; - -// ----------------------------------------------------------------------- - -END_NAMESPACE_DGL +#warning This is a deprecated file, please include ImageWidgets.hpp instead. +#include "ImageWidgets.hpp" #endif // DGL_IMAGE_SLIDER_HPP_INCLUDED diff --git a/dgl/ImageSwitch.hpp b/dgl/ImageSwitch.hpp @@ -17,49 +17,7 @@ #ifndef DGL_IMAGE_SWITCH_HPP_INCLUDED #define DGL_IMAGE_SWITCH_HPP_INCLUDED -#include "Image.hpp" -#include "Widget.hpp" - -START_NAMESPACE_DGL - -// ----------------------------------------------------------------------- - -class ImageSwitch : public Widget -{ -public: - class Callback - { - public: - virtual ~Callback() {} - virtual void imageSwitchClicked(ImageSwitch* imageButton, bool down) = 0; - }; - - explicit ImageSwitch(Window& parent, const Image& imageNormal, const Image& imageDown) noexcept; - explicit ImageSwitch(Widget* widget, const Image& imageNormal, const Image& imageDown) noexcept; - explicit ImageSwitch(const ImageSwitch& imageSwitch) noexcept; - ImageSwitch& operator=(const ImageSwitch& imageSwitch) noexcept; - - bool isDown() const noexcept; - void setDown(bool down) noexcept; - - void setCallback(Callback* callback) noexcept; - -protected: - void onDisplay() override; - bool onMouse(const MouseEvent&) override; - -private: - Image fImageNormal; - Image fImageDown; - bool fIsDown; - - Callback* fCallback; - - DISTRHO_LEAK_DETECTOR(ImageSwitch) -}; - -// ----------------------------------------------------------------------- - -END_NAMESPACE_DGL +#warning This is a deprecated file, please include ImageWidgets.hpp instead. +#include "ImageWidgets.hpp" #endif // DGL_IMAGE_SWITCH_HPP_INCLUDED diff --git a/dgl/ImageWidgets.hpp b/dgl/ImageWidgets.hpp @@ -0,0 +1,273 @@ +/* + * DISTRHO Plugin Framework (DPF) + * Copyright (C) 2012-2015 Filipe Coelho <falktx@falktx.com> + * + * Permission to use, copy, modify, and/or distribute this software for any purpose with + * or without fee is hereby granted, provided that the above copyright notice and this + * permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef DGL_WIDGETS_HPP_INCLUDED +#define DGL_WIDGETS_HPP_INCLUDED + +#include "Image.hpp" +#include "Widget.hpp" +#include "Window.hpp" + +START_NAMESPACE_DGL + +// ----------------------------------------------------------------------- + +class ImageAboutWindow : public Window, + public Widget +{ +public: + explicit ImageAboutWindow(Window& parent, const Image& image = Image()); + explicit ImageAboutWindow(Widget* widget, const Image& image = Image()); + + void setImage(const Image& image); + +protected: + void onDisplay() override; + bool onKeyboard(const KeyboardEvent&) override; + bool onMouse(const MouseEvent&) override; + void onReshape(uint width, uint height) override; + +private: + Image fImgBackground; + + //DISTRHO_DECLARE_NON_COPY_CLASS(ImageAboutWindow) + DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ImageAboutWindow) +}; + +// ----------------------------------------------------------------------- + +class ImageButton : public Widget +{ +public: + class Callback + { + public: + virtual ~Callback() {} + virtual void imageButtonClicked(ImageButton* imageButton, int button) = 0; + }; + + explicit ImageButton(Window& parent, const Image& image) noexcept; + explicit ImageButton(Window& parent, const Image& imageNormal, const Image& imageHover, const Image& imageDown) noexcept; + explicit ImageButton(Widget* widget, const Image& image) noexcept; + explicit ImageButton(Widget* widget, const Image& imageNormal, const Image& imageHover, const Image& imageDown) noexcept; + explicit ImageButton(const ImageButton& imageButton) noexcept; + ImageButton& operator=(const ImageButton& imageButton) noexcept; + + void setCallback(Callback* callback) noexcept; + +protected: + void onDisplay() override; + bool onMouse(const MouseEvent&) override; + bool onMotion(const MotionEvent&) override; + +private: + Image fImageNormal; + Image fImageHover; + Image fImageDown; + Image* fCurImage; + int fCurButton; + + Callback* fCallback; + + DISTRHO_LEAK_DETECTOR(ImageButton) +}; + +// ----------------------------------------------------------------------- + +class ImageKnob : public Widget +{ +public: + enum Orientation { + Horizontal, + Vertical + }; + + class Callback + { + public: + virtual ~Callback() {} + virtual void imageKnobDragStarted(ImageKnob* imageKnob) = 0; + virtual void imageKnobDragFinished(ImageKnob* imageKnob) = 0; + virtual void imageKnobValueChanged(ImageKnob* imageKnob, float value) = 0; + }; + + explicit ImageKnob(Window& parent, const Image& image, Orientation orientation = Vertical) noexcept; + explicit ImageKnob(Widget* widget, const Image& image, Orientation orientation = Vertical) noexcept; + explicit ImageKnob(const ImageKnob& imageKnob); + ImageKnob& operator=(const ImageKnob& imageKnob); + ~ImageKnob() override; + + float getValue() const noexcept; + + void setDefault(float def) noexcept; + void setRange(float min, float max) noexcept; + void setStep(float step) noexcept; + void setValue(float value, bool sendCallback = false) noexcept; + void setUsingLogScale(bool yesNo) noexcept; + + void setCallback(Callback* callback) noexcept; + void setOrientation(Orientation orientation) noexcept; + void setRotationAngle(int angle); + + void setImageLayerCount(uint count) noexcept; + +protected: + void onDisplay() override; + bool onMouse(const MouseEvent&) override; + bool onMotion(const MotionEvent&) override; + bool onScroll(const ScrollEvent&) override; + +private: + Image fImage; + float fMinimum; + float fMaximum; + float fStep; + float fValue; + float fValueDef; + float fValueTmp; + bool fUsingDefault; + bool fUsingLog; + Orientation fOrientation; + + int fRotationAngle; + bool fDragging; + int fLastX; + int fLastY; + + Callback* fCallback; + + bool fIsImgVertical; + uint fImgLayerWidth; + uint fImgLayerHeight; + uint fImgLayerCount; + bool fIsReady; + GLuint fTextureId; + + float _logscale(float value) const; + float _invlogscale(float value) const; + + DISTRHO_LEAK_DETECTOR(ImageKnob) +}; + +// ----------------------------------------------------------------------- + +class ImageSlider : public Widget +{ +public: + class Callback + { + public: + virtual ~Callback() {} + virtual void imageSliderDragStarted(ImageSlider* imageSlider) = 0; + virtual void imageSliderDragFinished(ImageSlider* imageSlider) = 0; + virtual void imageSliderValueChanged(ImageSlider* imageSlider, float value) = 0; + }; + + explicit ImageSlider(Window& parent, const Image& image) noexcept; + explicit ImageSlider(Widget* widget, const Image& image) noexcept; + explicit ImageSlider(const ImageSlider& imageSlider) noexcept; + ImageSlider& operator=(const ImageSlider& imageSlider) noexcept; + + float getValue() const noexcept; + + void setStartPos(const Point<int>& startPos) noexcept; + void setStartPos(int x, int y) noexcept; + void setEndPos(const Point<int>& endPos) noexcept; + void setEndPos(int x, int y) noexcept; + + void setInverted(bool inverted) noexcept; + void setRange(float min, float max) noexcept; + void setStep(float step) noexcept; + void setValue(float value, bool sendCallback = false) noexcept; + + void setCallback(Callback* callback) noexcept; + +protected: + void onDisplay() override; + bool onMouse(const MouseEvent&) override; + bool onMotion(const MotionEvent&) override; + +private: + Image fImage; + float fMinimum; + float fMaximum; + float fStep; + float fValue; + float fValueTmp; + + bool fDragging; + bool fInverted; + int fStartedX; + int fStartedY; + + Callback* fCallback; + + Point<int> fStartPos; + Point<int> fEndPos; + Rectangle<int> fSliderArea; + + void _recheckArea() noexcept; + + // these should not be used + void setAbsoluteX(int) const noexcept {} + void setAbsoluteY(int) const noexcept {} + void setAbsolutePos(int, int) const noexcept {} + void setAbsolutePos(const Point<int>&) const noexcept {} + + DISTRHO_LEAK_DETECTOR(ImageSlider) +}; + +// ----------------------------------------------------------------------- + +class ImageSwitch : public Widget +{ +public: + class Callback + { + public: + virtual ~Callback() {} + virtual void imageSwitchClicked(ImageSwitch* imageButton, bool down) = 0; + }; + + explicit ImageSwitch(Window& parent, const Image& imageNormal, const Image& imageDown) noexcept; + explicit ImageSwitch(Widget* widget, const Image& imageNormal, const Image& imageDown) noexcept; + explicit ImageSwitch(const ImageSwitch& imageSwitch) noexcept; + ImageSwitch& operator=(const ImageSwitch& imageSwitch) noexcept; + + bool isDown() const noexcept; + void setDown(bool down) noexcept; + + void setCallback(Callback* callback) noexcept; + +protected: + void onDisplay() override; + bool onMouse(const MouseEvent&) override; + +private: + Image fImageNormal; + Image fImageDown; + bool fIsDown; + + Callback* fCallback; + + DISTRHO_LEAK_DETECTOR(ImageSwitch) +}; + +// ----------------------------------------------------------------------- + +END_NAMESPACE_DGL + +#endif // DGL_WIDGETS_HPP_INCLUDED diff --git a/dgl/Widget.hpp b/dgl/Widget.hpp @@ -27,6 +27,7 @@ START_NAMESPACE_DGL // Forward class names class App; +class ImageSlider; class NanoWidget; class Window; class StandaloneWindow; diff --git a/dgl/src/ImageAboutWindow.cpp b/dgl/src/ImageAboutWindow.cpp @@ -14,7 +14,7 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "../ImageAboutWindow.hpp" +#include "../ImageWidgets.hpp" START_NAMESPACE_DGL diff --git a/dgl/src/ImageButton.cpp b/dgl/src/ImageButton.cpp @@ -14,7 +14,7 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "../ImageButton.hpp" +#include "../ImageWidgets.hpp" START_NAMESPACE_DGL diff --git a/dgl/src/ImageKnob.cpp b/dgl/src/ImageKnob.cpp @@ -14,7 +14,7 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "../ImageKnob.hpp" +#include "../ImageWidgets.hpp" #include <cmath> diff --git a/dgl/src/ImageSlider.cpp b/dgl/src/ImageSlider.cpp @@ -14,7 +14,7 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "../ImageSlider.hpp" +#include "../ImageWidgets.hpp" #include <cmath> diff --git a/dgl/src/ImageSwitch.cpp b/dgl/src/ImageSwitch.cpp @@ -14,7 +14,7 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "../ImageSwitch.hpp" +#include "../ImageWidgets.hpp" START_NAMESPACE_DGL