ASPiK SDK
csplitview.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 __csplitview__
6 #define __csplitview__
7 
8 #include "vstguifwd.h"
9 #include "cviewcontainer.h"
10 
11 namespace VSTGUI {
12 class CSplitViewSeparatorView;
13 
14 //-----------------------------------------------------------------------------
19 //-----------------------------------------------------------------------------
20 class CSplitView : public CViewContainer
21 {
22 public:
23  enum Style {
26  };
27 
29  enum ResizeMethod {
34  };
35 
36  CSplitView (const CRect& size, Style style = kHorizontal, CCoord separatorWidth = 10., ISplitViewSeparatorDrawer* drawer = nullptr);
37  ~CSplitView () noexcept override = default;
38 
39  //-----------------------------------------------------------------------------
41  //-----------------------------------------------------------------------------
43  virtual void setStyle (Style s);
44  Style getStyle () const { return style; }
45 
46  virtual void setResizeMethod (ResizeMethod method);
47  ResizeMethod getResizeMethod () const { return resizeMethod; }
48 
49  virtual void setSeparatorWidth (CCoord width);
50  CCoord getSeparatorWidth () const { return separatorWidth; }
51 
52  ISplitViewSeparatorDrawer* getDrawer ();
53  void storeViewSizes ();
54 
55  bool addViewToSeparator (int32_t sepIndex, CView* view);
57 
58  // overrides
59  bool addView (CView* pView) override;
60  bool addView (CView* pView, const CRect& mouseableArea, bool mouseEnabled = true) override;
61  bool addView (CView* pView, CView* pBefore) override;
62  bool removeView (CView* pView, bool withForget = true) override;
63  bool removeAll (bool withForget = true) override;
64  void setViewSize (const CRect& rect, bool invalid = true) override;
65  bool sizeToFit () override;
66  bool removed (CView* parent) override;
67  bool attached (CView* parent) override;
68 
69  bool requestNewSeparatorSize (CSplitViewSeparatorView* separatorView, const CRect& newSize);
70 //-----------------------------------------------------------------------------
71 protected:
72  void resizeFirstView (CPoint diff);
73  void resizeSecondView (CPoint diff);
74  void resizeLastView (CPoint diff);
75  void resizeViewsEqual (CPoint diff);
76 
77  Style style;
78  ResizeMethod resizeMethod;
79  CCoord separatorWidth;
80  ISplitViewSeparatorDrawer* separatorDrawer;
81 };
82 
83 //-----------------------------------------------------------------------------
90 //-----------------------------------------------------------------------------
92 {
93 public:
94  virtual ~ISplitViewController () noexcept = default;
95 
97  virtual bool getSplitViewSizeConstraint (int32_t index, CCoord& minSize, CCoord& maxSize, CSplitView* splitView) = 0;
101  virtual bool storeViewSize (int32_t index, const CCoord& size, CSplitView* splitView) = 0;
103  virtual bool restoreViewSize (int32_t index, CCoord& size, CSplitView* splitView) = 0;
104 };
105 
106 //-----------------------------------------------------------------------------
109 //-----------------------------------------------------------------------------
111 {
112 public:
113  virtual ~ISplitViewSeparatorDrawer () noexcept = default;
114 
115  enum Flags {
116  kMouseOver = 1 << 0,
117  kMouseDown = 1 << 1
118  };
121  virtual void drawSplitViewSeparator (CDrawContext* context, const CRect& size, int32_t flags, int32_t index, CSplitView* splitView) = 0;
122 };
123 
124 }
125 
126 #endif // __csplitview__
all views will be resized equally
Definition: csplitview.h:33
virtual bool storeViewSize(int32_t index, const CCoord &size, CSplitView *splitView)=0
void invalid() override
mark whole view as invalid
Definition: cviewcontainer.cpp:618
only the second view will be resized
Definition: csplitview.h:31
Container Class of CView objects.
Definition: cviewcontainer.h:52
a split container view with separators between its child views
Definition: csplitview.h:20
virtual void setResizeMethod(ResizeMethod method)
set the resize method, see CSplitView::ResizeMethod
Definition: csplitview.cpp:76
bool removed(CView *parent) override
view is removed from parent view
Definition: csplitview.cpp:468
Rect structure.
Definition: crect.h:17
Style getStyle() const
get the style of the split view, see CSplitView::Style
Definition: csplitview.h:44
A drawing context encapsulates the drawing context of the underlying OS.
Definition: cdrawcontext.h:29
only the first view will be resized
Definition: csplitview.h:30
ResizeMethod
Definition: csplitview.h:29
bool attached(CView *parent) override
view is attached to a parent view
Definition: csplitview.cpp:475
virtual void drawSplitViewSeparator(CDrawContext *context, const CRect &size, int32_t flags, int32_t index, CSplitView *splitView)=0
Style
Definition: csplitview.h:23
CCoord getSeparatorWidth() const
get the width of the separators
Definition: csplitview.h:50
subviews will be horizontally arranged
Definition: csplitview.h:24
bool removeAll(bool withForget=true) override
remove all child views
Definition: csplitview.cpp:434
ResizeMethod getResizeMethod() const
get the resize method, see CSplitView::ResizeMethod
Definition: csplitview.h:47
Definition: customcontrols.cpp:8
Definition: csplitview.h:110
virtual ISplitViewSeparatorDrawer * getSplitViewSeparatorDrawer(CSplitView *splitView)=0
bool sizeToFit() override
resize view to optimal size
Definition: csplitview.cpp:440
Split View Controller.
Definition: csplitview.h:91
only the last view will be resized
Definition: csplitview.h:32
virtual void setSeparatorWidth(CCoord width)
set the width of the separators
Definition: csplitview.cpp:82
Base Class of all view objects.
Definition: cview.h:44
bool addView(CView *pView) override
add a child view
Definition: csplitview.cpp:356
bool removeView(CView *pView, bool withForget=true) override
remove a child view
Definition: csplitview.cpp:402
virtual void setStyle(Style s)
set the style of the split view, see CSplitView::Style
Definition: csplitview.cpp:66
subviews will be vertically arranged
Definition: csplitview.h:25
virtual bool restoreViewSize(int32_t index, CCoord &size, CSplitView *splitView)=0
virtual bool getSplitViewSizeConstraint(int32_t index, CCoord &minSize, CCoord &maxSize, CSplitView *splitView)=0
Point structure.
Definition: cpoint.h:17
void setViewSize(const CRect &rect, bool invalid=true) override
set views size
Definition: csplitview.cpp:323