ASPiK SDK
uiviewswitchcontainer.h
1 // This file is part of VSTGUI. It is subject to the license terms
2 // in the LICENSE file found in the top-level directory of this
3 // distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
4 
5 #ifndef __uiviewswitchcontainer__
6 #define __uiviewswitchcontainer__
7 
8 #include "../lib/cviewcontainer.h"
9 #include "../lib/controls/icontrollistener.h"
10 #include "../lib/vstguifwd.h"
11 #include "uidescriptionfwd.h"
12 #include <vector>
13 
14 namespace VSTGUI {
15 class IViewSwitchController;
16 
17 //-----------------------------------------------------------------------------
19 {
20 public:
21  explicit UIViewSwitchContainer (const CRect& size);
22  ~UIViewSwitchContainer () noexcept override;
23 
24  IViewSwitchController* getController () const { return controller; }
25  void setController (IViewSwitchController* controller); // owns controller if it is a CBaseObject
26 
27  void setCurrentViewIndex (int32_t viewIndex);
28  int32_t getCurrentViewIndex () const { return currentViewIndex; }
29 
30  void setAnimationTime (uint32_t ms);
31  uint32_t getAnimationTime () const { return animationTime; }
32 
33  enum AnimationStyle {
34  kFadeInOut,
35  kMoveInOut,
36  kPushInOut
37  };
38 
39  void setAnimationStyle (AnimationStyle style);
40  AnimationStyle getAnimationStyle () const { return animationStyle; }
41 
42  bool attached (CView* parent) override;
43  bool removed (CView* parent) override;
44 //-----------------------------------------------------------------------------
45  CLASS_METHODS (UIViewSwitchContainer, CViewContainer)
46 protected:
47  IViewSwitchController* controller;
48  int32_t currentViewIndex;
49  uint32_t animationTime;
50  AnimationStyle animationStyle;
51 };
52 
53 //-----------------------------------------------------------------------------
55 {
56 public:
57  explicit IViewSwitchController (UIViewSwitchContainer* viewSwitch) : viewSwitch (viewSwitch) {}
58  virtual ~IViewSwitchController () noexcept = default;
59 
60  void init () { viewSwitch->setController (this); }
61 
62  UIViewSwitchContainer* getViewSwitchContainer () const { return viewSwitch; }
63 
64  virtual CView* createViewForIndex (int32_t index) = 0;
65  virtual void switchContainerAttached () = 0;
66  virtual void switchContainerRemoved () = 0;
67 protected:
68  UIViewSwitchContainer* viewSwitch;
69 };
70 
71 //-----------------------------------------------------------------------------
73 {
74 public:
75  UIDescriptionViewSwitchController (UIViewSwitchContainer* viewSwitch, const IUIDescription* uiDescription, IController* uiController);
76 
77  CView* createViewForIndex (int32_t index) override;
78  void switchContainerAttached () override;
79  void switchContainerRemoved () override;
80 
81  void setTemplateNames (UTF8StringPtr templateNames); // comma separated
82  void getTemplateNames (std::string& str); // comma separated
83 
84  void setSwitchControlTag (int32_t tag) { switchControlTag = tag; }
85  int32_t getSwitchControlTag () const { return switchControlTag; }
86 protected:
87  void valueChanged (CControl* pControl) override;
88 
89  const IUIDescription* uiDescription;
90  IController* uiController;
91  int32_t switchControlTag;
92  int32_t currentIndex;
93  SharedPointer<CControl> switchControl;
94  std::vector<std::string> templateNames;
95 };
96 
97 } // namespace
98 
99 #endif // __uiviewswitchcontainer__
Container Class of CView objects.
Definition: cviewcontainer.h:52
Rect structure.
Definition: crect.h:17
bool removed(CView *parent) override
view is removed from parent view
Definition: uiviewswitchcontainer.cpp:141
Definition: iuidescription.h:19
Definition: xmlparse.c:181
Definition: vstguibase.h:299
Base Object with reference counter.
Definition: vstguibase.h:276
bool attached(CView *parent) override
view is attached to a parent view
Definition: uiviewswitchcontainer.cpp:131
Definition: uiviewswitchcontainer.h:54
Definition: customcontrols.cpp:8
base class of all VSTGUI controls
Definition: ccontrol.h:76
extension to IControlListener used by UIDescription
Definition: icontroller.h:20
Base Class of all view objects.
Definition: cview.h:44
Definition: uiviewswitchcontainer.h:18
Definition: uiviewswitchcontainer.h:72
Definition: icontrollistener.h:14