libAlgAudio  v1.99-440-g08538e5-dirty
The development library for AlgAudio framework.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ModuleGUI.hpp
Go to the documentation of this file.
1 #ifndef MODULEGUI_HPP
2 #define MODULEGUI_HPP
3 /*
4 This file is part of AlgAudio.
5 
6 AlgAudio, Copyright (C) 2015 CeTA - Audiovisual Technology Center
7 
8 AlgAudio is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as
10 published by the Free Software Foundation, either version 3 of the
11 License, or (at your option) any later version.
12 
13 AlgAudio is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License
19 along with AlgAudio. If not, see <http://www.gnu.org/licenses/>.
20 */
21 #include "Module.hpp"
22 #include "Canvas.hpp"
23 #include "UI/UIWidget.hpp"
24 
25 namespace AlgAudio{
26 
27 namespace Exceptions{
28 struct GUIBuild : public Exception{
29  GUIBuild(std::string t) : Exception(t) {}
30 };
31 } // namespace Exceptions
32 
40 class ModuleGUI{
41 public:
43  Point2D& position() { return module.lock()->position_in_canvas; }
44 
53  virtual std::shared_ptr<UIWidget> Widget() = 0;
54 
56  std::shared_ptr<Module> GetModule(){ return module.lock(); }
57 
60  virtual void SetHighlight(bool) = 0;
61 
63 
67  virtual Point2D WhereIsInlet(std::string inlet) = 0;
68  virtual Point2D WhereIsOutlet(std::string outlet) = 0;
69  virtual Point2D WhereIsParamInlet(std::string inlet) = 0;
70  virtual Point2D WhereIsParamRelativeOutlet(std::string inlet) = 0;
71  virtual Point2D WhereIsParamAbsoluteOutlet(std::string inlet) = 0;
73 
76  virtual std::string GetIoletParamID(UIWidget::ID) const = 0;
77 
82  virtual void SliderDragStart(UIWidget::ID){}
89  virtual void SliderDragEnd(UIWidget::ID){}
90 
93  virtual void OnInletsChanged() {};
94 
95  enum class WhatIsHereType{
96  Nothing,
97  Inlet,
98  Outlet,
102  SliderBody,
103  };
104  struct WhatIsHere{
109  std::string param_id;
110  };
114  virtual WhatIsHere GetWhatIsHere(Point2D) const = 0;
115 
116 protected:
117  ModuleGUI(std::shared_ptr<Module> mod) : module(mod){}
118  // A link to the module instance this GUI represents.
119  std::weak_ptr<Module> module;
120 };
121 
122 } // namespace AlgAudio
123 
124 #endif //MODULEGUI_HPP
WhatIsHereType
Definition: ModuleGUI.hpp:95
virtual std::shared_ptr< UIWidget > Widget()=0
virtual void SliderDragStart(UIWidget::ID)
Definition: ModuleGUI.hpp:82
virtual Point2D WhereIsInlet(std::string inlet)=0
virtual Point2D WhereIsParamRelativeOutlet(std::string inlet)=0
WhatIsHereType type
Definition: ModuleGUI.hpp:105
virtual void SliderDragEnd(UIWidget::ID)
Definition: ModuleGUI.hpp:89
virtual Point2D WhereIsOutlet(std::string outlet)=0
Definition: ModuleGUI.hpp:40
virtual Point2D WhereIsParamAbsoluteOutlet(std::string inlet)=0
Definition: ModuleGUI.hpp:28
virtual WhatIsHere GetWhatIsHere(Point2D) const =0
std::string param_id
Definition: ModuleGUI.hpp:109
Definition: ModuleGUI.hpp:104
Definition: Alertable.hpp:26
Definition: UIWidget.hpp:137
Point2D & position()
Definition: ModuleGUI.hpp:43
UIWidget::ID widget_id
Definition: ModuleGUI.hpp:107
virtual std::string GetIoletParamID(UIWidget::ID) const =0
virtual void OnInletsChanged()
Definition: ModuleGUI.hpp:93
ModuleGUI(std::shared_ptr< Module > mod)
Definition: ModuleGUI.hpp:117
GUIBuild(std::string t)
Definition: ModuleGUI.hpp:29
std::weak_ptr< Module > module
Definition: ModuleGUI.hpp:119
std::shared_ptr< Module > GetModule()
Definition: ModuleGUI.hpp:56
virtual Point2D WhereIsParamInlet(std::string inlet)=0
virtual void SliderDragStep(UIWidget::ID, Point2D_< float >)
Definition: ModuleGUI.hpp:86
Definition: Exception.hpp:29
virtual void SetHighlight(bool)=0