1 #pragma once
2 
3 #ifndef COLUMNFAN_INCLUDED
4 #define COLUMNFAN_INCLUDED
5 
6 #include "tcommon.h"
7 
8 #undef DVAPI
9 #undef DVVAR
10 #ifdef TOONZLIB_EXPORTS
11 #define DVAPI DV_EXPORT_API
12 #define DVVAR DV_EXPORT_VAR
13 #else
14 #define DVAPI DV_IMPORT_API
15 #define DVVAR DV_IMPORT_VAR
16 #endif
17 
18 class TOStream;
19 class TIStream;
20 
21 //=============================================================================
22 //! The ColumnFan class is used to menage display columns.
23 /*!The class allows to fold a column by column index, deactivate(), to
24    open folded columns, activate() and to know if column is folded or not,
25    isActive().
26 
27    Class provides column layer-axis coordinate too.
28    It's possible to know column index by column layer-axis coordinate,
29    colToLayerAxis()
30    and vice versa, layerAxisToCol().
31 */
32 //=============================================================================
33 
34 class DVAPI ColumnFan {
35   class Column {
36   public:
37     bool m_active;
38     int m_pos;
Column()39     Column() : m_active(true), m_pos(0) {}
40   };
41   std::vector<Column> m_columns;
42   std::map<int, int> m_table;
43   int m_firstFreePos;
44   int m_unfolded, m_folded;
45   bool m_cameraActive;
46   int m_cameraColumnDim;
47   /*!
48   Called by activate() and deactivate() to update columns coordinates.
49   */
50   void update();
51 
52 public:
53   /*!
54 Constructs a ColumnFan with default value.
55 */
56   ColumnFan();
57 
58   //! Adjust column sizes when switching orientation
59   void setDimensions(int unfolded, int cameraColumn);
60 
61   /*!
62 Set column \b col not folded.
63 \sa deactivate() and isActive()
64 */
65   void activate(int col);
66   /*!
67 Fold column \b col.
68 \sa activate() and isActive()
69 */
70   void deactivate(int col);
71   /*!
72 Return true if column \b col is active, column is not folded, else return false.
73 \sa activate() and deactivate()
74 */
75   bool isActive(int col) const;
76 
77   /*!
78 Return column index of column in layer axis (x for vertical timeline, y for
79 horizontal).
80 \sa colToLayerAxis()
81 */
82   int layerAxisToCol(int layerAxis) const;
83   /*!
84 Return layer coordinate (x for vertical timeline, y for horizontal)
85 of column identified by \b col.
86 \sa layerAxisToCol()
87 */
88   int colToLayerAxis(int col) const;
89 
90   void copyFoldedStateFrom(const ColumnFan &from);
91 
92   bool isEmpty() const;
93 
94   void saveData(TOStream &os);
95   void loadData(TIStream &is);
96 
97   void rollLeftFoldedState(int index, int count);
98   void rollRightFoldedState(int index, int count);
99 };
100 
101 #endif
102