| #pragma once |
| |
| #ifndef ORIENTATION_INCLUDED |
| #define ORIENTATION_INCLUDED |
| |
| #undef DVAPI |
| #undef DVVAR |
| #ifdef TOONZLIB_EXPORTS |
| #define DVAPI DV_EXPORT_API |
| #define DVVAR DV_EXPORT_VAR |
| #else |
| #define DVAPI DV_IMPORT_API |
| #define DVVAR DV_IMPORT_VAR |
| #endif |
| |
| #include "tcommon.h" |
| #include "cellposition.h" |
| #include "toonz/cellpositionratio.h" |
| #include <QPoint> |
| #include <QLine> |
| #include <QRect> |
| #include <QPainterPath> |
| #include <map> |
| #include <vector> |
| |
| using std::vector; |
| using std::map; |
| |
| |
| |
| |
| |
| |
| |
| class DVAPI NumberRange { |
| int _from, _to; |
| |
| NumberRange() : _from(0), _to(0) {} |
| |
| public: |
| NumberRange(int from, int to) : _from(min(from, to)), _to(max(from, to)) {} |
| |
| int from() const { return _from; } |
| int to() const { return _to; } |
| |
| int length() const { return _to - _from; } |
| int middle() const { return (_to + _from) / 2; } |
| int weight(double toWeight) const; |
| double ratio(int at) const; |
| |
| NumberRange adjusted(int addFrom, int addTo) const; |
| }; |
| |
| class ColumnFan; |
| class QPixmap; |
| class QPainterPath; |
| |
| |
| |
| enum class PredefinedRect { |
| CELL, |
| DRAG_HANDLE_CORNER, |
| KEY_ICON, |
| CELL_NAME, |
| CELL_NAME_WITH_KEYFRAME, |
| END_EXTENDER, |
| BEGIN_EXTENDER, |
| KEYFRAME_AREA, |
| DRAG_AREA, |
| SOUND_TRACK, |
| PREVIEW_TRACK, |
| BEGIN_SOUND_EDIT, |
| END_SOUND_EDIT, |
| NOTE_AREA, |
| NOTE_ICON, |
| FRAME_LABEL, |
| FRAME_HEADER, |
| LAYER_HEADER, |
| FOLDED_LAYER_HEADER, |
| PLAY_RANGE, |
| ONION, |
| ONION_DOT, |
| ONION_DOT_FIXED, |
| ONION_AREA, |
| ONION_FIXED_DOT_AREA, |
| ONION_DOT_AREA, |
| PINNED_CENTER_KEY, |
| RENAME_COLUMN, |
| EYE_AREA, |
| EYE, |
| PREVIEW_LAYER_AREA, |
| |
| PREVIEW_LAYER, |
| LOCK_AREA, |
| LOCK, |
| DRAG_LAYER, |
| LAYER_NAME, |
| LAYER_NUMBER, |
| SOUND_ICON, |
| VOLUME_TRACK, |
| VOLUME_AREA, |
| LOOP_ICON, |
| LAYER_HEADER_PANEL, |
| |
| THUMBNAIL_AREA, |
| THUMBNAIL, |
| PEGBAR_NAME, |
| PARENT_HANDLE_NAME, |
| FILTER_COLOR, |
| CONFIG_AREA, |
| CONFIG, |
| FRAME_MARKER_AREA, |
| FRAME_INDICATOR, |
| ZOOM_SLIDER_AREA, |
| ZOOM_SLIDER, |
| ZOOM_IN_AREA, |
| ZOOM_IN, |
| ZOOM_OUT_AREA, |
| ZOOM_OUT, |
| LAYER_FOOTER_PANEL, |
| PREVIEW_FRAME_AREA, |
| SHIFTTRACE_DOT, |
| SHIFTTRACE_DOT_AREA, |
| PANEL_EYE, |
| PANEL_PREVIEW_LAYER, |
| PANEL_LOCK, |
| PANEL_LAYER_NAME |
| }; |
| enum class PredefinedLine { |
| LOCKED, |
| SEE_MARKER_THROUGH, |
| CONTINUE_LEVEL, |
| CONTINUE_LEVEL_WITH_NAME, |
| EXTENDER_LINE |
| }; |
| enum class PredefinedDimension { |
| LAYER, |
| FRAME, |
| INDEX, |
| SOUND_AMPLITUDE, |
| FRAME_LABEL_ALIGN, |
| ONION_TURN, |
| QBOXLAYOUT_DIRECTION, |
| CENTER_ALIGN, |
| }; |
| enum class PredefinedPath { |
| DRAG_HANDLE_CORNER, |
| BEGIN_EASE_TRIANGLE, |
| END_EASE_TRIANGLE, |
| BEGIN_PLAY_RANGE, |
| END_PLAY_RANGE, |
| VOLUME_SLIDER_TRACK, |
| VOLUME_SLIDER_HEAD, |
| TIME_INDICATOR_HEAD, |
| FRAME_MARKER_DIAMOND |
| }; |
| enum class PredefinedPoint { |
| KEY_HIDDEN, |
| EXTENDER_XY_RADIUS, |
| VOLUME_DIVISIONS_TOP_LEFT |
| }; |
| enum class PredefinedRange { |
| HEADER_FRAME, |
| HEADER_LAYER, |
| }; |
| enum class PredefinedFlag { |
| DRAG_LAYER_BORDER, |
| DRAG_LAYER_VISIBLE, |
| LAYER_NAME_BORDER, |
| LAYER_NAME_VISIBLE, |
| LAYER_NUMBER_BORDER, |
| LAYER_NUMBER_VISIBLE, |
| EYE_AREA_BORDER, |
| EYE_AREA_VISIBLE, |
| LOCK_AREA_BORDER, |
| LOCK_AREA_VISIBLE, |
| PREVIEW_LAYER_AREA_BORDER, |
| PREVIEW_LAYER_AREA_VISIBLE, |
| CONFIG_AREA_BORDER, |
| CONFIG_AREA_VISIBLE, |
| PEGBAR_NAME_BORDER, |
| PEGBAR_NAME_VISIBLE, |
| PARENT_HANDLE_NAME_BORDER, |
| PARENT_HANDLE_NAME_VISIBILE, |
| THUMBNAIL_AREA_BORDER, |
| THUMBNAIL_AREA_VISIBLE, |
| VOLUME_AREA_VERTICAL |
| }; |
| |
| |
| class DVAPI Orientation { |
| protected: |
| map<PredefinedRect, QRect> _rects; |
| map<PredefinedLine, QLine> _lines; |
| map<PredefinedDimension, int> _dimensions; |
| map<PredefinedPath, QPainterPath> _paths; |
| map<PredefinedPoint, QPoint> _points; |
| map<PredefinedRange, NumberRange> _ranges; |
| map<PredefinedFlag, bool> _flags; |
| |
| public: |
| virtual CellPosition xyToPosition(const QPoint &xy, |
| const ColumnFan *fan) const = 0; |
| virtual QPoint positionToXY(const CellPosition &position, |
| const ColumnFan *fan) const = 0; |
| virtual CellPositionRatio xyToPositionRatio(const QPoint &xy) const = 0; |
| virtual QPoint positionRatioToXY(const CellPositionRatio &ratio) const = 0; |
| |
| virtual int colToLayerAxis(int layer, const ColumnFan *fan) const = 0; |
| virtual int rowToFrameAxis(int frame) const = 0; |
| |
| virtual QPoint frameLayerToXY(int frameAxis, int layerAxis) const = 0; |
| QRect frameLayerRect(const NumberRange &frameAxis, |
| const NumberRange &layerAxis) const; |
| |
| virtual NumberRange layerSide(const QRect &area) const = 0; |
| virtual NumberRange frameSide(const QRect &area) const = 0; |
| virtual int layerAxis(const QPoint &xy) const = 0; |
| virtual int frameAxis(const QPoint &xy) const = 0; |
| |
| virtual QPoint topRightCorner(const QRect &area) const = 0; |
| QRect foldedRectangle(int layerAxis, const NumberRange &frameAxis, |
| int i) const; |
| QLine foldedRectangleLine(int layerAxis, const NumberRange &frameAxis, |
| int i) const; |
| |
| virtual CellPosition arrowShift(int direction) const = 0; |
| |
| |
| QLine verticalLine(int layerAxis, const NumberRange &frameAxis) const; |
| QLine horizontalLine(int frameAxis, const NumberRange &layerAxis) const; |
| |
| virtual bool isVerticalTimeline() const = 0; |
| virtual bool flipVolume() const = 0; |
| |
| virtual QString name() const = 0; |
| virtual QString caption() const = 0; |
| virtual const Orientation *next() const = 0; |
| |
| const QRect &rect(PredefinedRect which) const { return _rects.at(which); } |
| const QLine &line(PredefinedLine which) const { return _lines.at(which); } |
| int dimension(PredefinedDimension which) const { |
| return _dimensions.at(which); |
| } |
| const QPainterPath &path(PredefinedPath which) const { |
| return _paths.at(which); |
| } |
| const QPoint &point(PredefinedPoint which) const { return _points.at(which); } |
| const NumberRange &range(PredefinedRange which) const { |
| return _ranges.at(which); |
| } |
| const bool &flag(PredefinedFlag which) const { return _flags.at(which); } |
| |
| virtual int cellWidth() const = 0; |
| virtual int cellHeight() const = 0; |
| virtual int foldedCellSize() const = 0; |
| |
| protected: |
| void addRect(PredefinedRect which, const QRect &rect); |
| void addLine(PredefinedLine which, const QLine &line); |
| void addDimension(PredefinedDimension which, int dimension); |
| void addPath(PredefinedPath which, const QPainterPath &path); |
| void addPoint(PredefinedPoint which, const QPoint &point); |
| void addRange(PredefinedRange which, const NumberRange &range); |
| void addFlag(PredefinedFlag which, const bool &flag); |
| }; |
| |
| |
| class DVAPI Orientations { |
| const Orientation *_topToBottom, *_leftToRight; |
| vector<const Orientation *> _all; |
| |
| Orientations(); |
| |
| public: |
| ~Orientations(); |
| |
| static const Orientations &instance(); |
| |
| static const int COUNT = 2; |
| |
| static const Orientation *topToBottom(); |
| static const Orientation *leftToRight(); |
| |
| static const vector<const Orientation *> &all(); |
| |
| static const Orientation *byName(const QString &name); |
| }; |
| |
| #endif |