DISTRHO Plugin Framework
ImageBaseWidgets.hpp
1 /*
2  * DISTRHO Plugin Framework (DPF)
3  * Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com>
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any purpose with
6  * or without fee is hereby granted, provided that the above copyright notice and this
7  * permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
10  * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
11  * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
13  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #ifndef DGL_IMAGE_BASE_WIDGETS_HPP_INCLUDED
18 #define DGL_IMAGE_BASE_WIDGETS_HPP_INCLUDED
19 
20 #include "StandaloneWindow.hpp"
21 #include "SubWidget.hpp"
22 
23 START_NAMESPACE_DGL
24 
25 // --------------------------------------------------------------------------------------------------------------------
26 
27 template <class ImageType>
29 {
30 public:
31  explicit ImageBaseAboutWindow(Window& parentWindow, const ImageType& image = ImageType());
32  explicit ImageBaseAboutWindow(TopLevelWidget* parentTopLevelWidget, const ImageType& image = ImageType());
33 
34  void setImage(const ImageType& image);
35 
36 protected:
37  void onDisplay() override;
38  bool onKeyboard(const KeyboardEvent&) override;
39  bool onMouse(const MouseEvent&) override;
40 
41  // FIXME needed?
42  void onReshape(uint width, uint height) override;
43 
44 private:
45  ImageType img;
46 
47  DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ImageBaseAboutWindow)
48 };
49 
50 // --------------------------------------------------------------------------------------------------------------------
51 
52 template <class ImageType>
53 class ImageBaseButton : public SubWidget
54 {
55 public:
56  class Callback
57  {
58  public:
59  virtual ~Callback() {}
60  virtual void imageButtonClicked(ImageBaseButton* imageButton, int button) = 0;
61  };
62 
63  explicit ImageBaseButton(Widget* parentWidget, const ImageType& image);
64  explicit ImageBaseButton(Widget* parentWidget, const ImageType& imageNormal, const ImageType& imageDown);
65  explicit ImageBaseButton(Widget* parentWidget, const ImageType& imageNormal, const ImageType& imageHover, const ImageType& imageDown);
66 
67  ~ImageBaseButton() override;
68 
69  void setCallback(Callback* callback) noexcept;
70 
71 protected:
72  void onDisplay() override;
73  bool onMouse(const MouseEvent&) override;
74  bool onMotion(const MotionEvent&) override;
75 
76 private:
77  struct PrivateData;
78  PrivateData* const pData;
79 
80  DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ImageBaseButton)
81 };
82 
83 // --------------------------------------------------------------------------------------------------------------------
84 
85 END_NAMESPACE_DGL
86 
87 #endif // DGL_IMAGE_BASE_WIDGETS_HPP_INCLUDED
ImageBaseAboutWindow::onDisplay
void onDisplay() override
ImageBaseButton
Definition: ImageBaseWidgets.hpp:53
ImageBaseAboutWindow::onReshape
void onReshape(uint width, uint height) override
Widget::KeyboardEvent
Definition: Widget.hpp:94
Window
Definition: Window.hpp:50
ImageBaseButton::onDisplay
void onDisplay() override
ImageBaseAboutWindow::onMouse
bool onMouse(const MouseEvent &) override
Widget::MotionEvent
Definition: Widget.hpp:183
ImageBaseAboutWindow::onKeyboard
bool onKeyboard(const KeyboardEvent &) override
ImageBaseAboutWindow
Definition: ImageBaseWidgets.hpp:28
ImageBaseButton::onMouse
bool onMouse(const MouseEvent &) override
StandaloneWindow
Definition: StandaloneWindow.hpp:27
ImageBaseButton::Callback
Definition: ImageBaseWidgets.hpp:56
SubWidget
Definition: SubWidget.hpp:39
Widget::MouseEvent
Definition: Widget.hpp:164
ImageBaseButton::onMotion
bool onMotion(const MotionEvent &) override
TopLevelWidget
Definition: TopLevelWidget.hpp:46
Widget
Definition: Widget.hpp:53