1 /* 2 * Copyright 2006, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 */ 8 9 #ifndef PATH_MANIPULATOR_H 10 #define PATH_MANIPULATOR_H 11 12 #include "Manipulator.h" 13 14 class AddPointCommand; 15 class ChangePointCommand; 16 class UndoStack; 17 class InsertPointCommand; 18 class Selection; 19 class StateView; 20 class VectorPath; 21 22 //class PathSelection { 23 // public: 24 // PathSelection(); 25 // virtual ~PathSelection(); 26 // 27 // virtual PathSelection* Clone() const; 28 // virtual bool SetTo(const PathSelection* other); 29 // 30 // virtual Command* Delete(); 31 //}; 32 33 class PathManipulator : public Manipulator { 34 public: 35 PathManipulator(VectorPath* path); 36 virtual ~PathManipulator(); 37 38 // Manipulator interface 39 virtual void Draw(BView* into, BRect updateRect); 40 41 virtual bool MouseDown(BPoint where); 42 virtual void MouseMoved(BPoint where); 43 virtual Command* MouseUp(); 44 virtual bool MouseOver(BPoint where); 45 virtual bool DoubleClicked(BPoint where); 46 47 virtual BRect Bounds(); 48 virtual BRect TrackingBounds(BView* withinView); 49 50 virtual bool MessageReceived(BMessage* message, 51 Command** _command); 52 53 virtual void ModifiersChanged(uint32 modifiers); 54 virtual bool HandleKeyDown(uint32 key, uint32 modifiers, 55 Command** _command); 56 virtual bool HandleKeyUp(uint32 key, uint32 modifiers, 57 Command** _command); 58 59 virtual void UpdateCursor(); 60 61 virtual void AttachedToView(BView* view); 62 virtual void DetachedFromView(BView* view); 63 64 // Observer interface (Manipulator) 65 virtual void ObjectChanged(const Observable* object); 66 67 // PathManipulator 68 uint32 ControlFlags() const; 69 70 // PathSelection* Selection() const; 71 // 72 // path manipulation 73 void ReversePath(); 74 75 private: 76 friend class PathCommand; 77 friend class PointSelection; 78 friend class EnterTransformPointsCommand; 79 friend class ExitTransformPointsCommand; 80 friend class TransformPointsCommand; 81 // friend class NewPathCommand; 82 friend class NudgePointsCommand; 83 // friend class RemovePathCommand; 84 friend class ReversePathCommand; 85 // friend class SelectPathCommand; 86 87 void _SetMode(uint32 mode); 88 89 // BEGIN functions that need to be undoable 90 void _AddPoint(BPoint where); 91 void _InsertPoint(BPoint where, int32 index); 92 void _SetInOutConnected(int32 index, bool connected); 93 void _SetSharp(int32 index); 94 95 void _RemoveSelection(); 96 void _RemovePoint(int32 index); 97 void _RemovePointIn(int32 index); 98 void _RemovePointOut(int32 index); 99 100 Command* _Delete(); 101 102 void _Select(BRect canvasRect); 103 void _Select(int32 index, bool extend = false); 104 void _Select(const int32* indices, int32 count, bool extend = false); 105 void _Deselect(int32 index); 106 void _ShiftSelection(int32 startIndex, int32 direction); 107 bool _IsSelected(int32 index) const; 108 // END functions that need to be undoable 109 110 void _InvalidateCanvas(BRect rect) const; 111 void _InvalidateHighlightPoints(int32 newIndex, uint32 newMode); 112 113 void _UpdateSelection() const; 114 115 BRect _ControlPointRect() const; 116 BRect _ControlPointRect(int32 index, uint32 mode) const; 117 void _GetChangableAreas(BRect* pathArea, 118 BRect* controlPointArea) const; 119 120 void _SetModeForMousePos(BPoint canvasWhere); 121 122 void _Nudge(BPoint direction); 123 void _FinishNudging(); 124 125 StateView* fCanvasView; 126 127 bool fCommandDown; 128 bool fOptionDown; 129 bool fShiftDown; 130 bool fAltDown; 131 132 bool fClickToClose; 133 134 uint32 fMode; 135 uint32 fFallBackMode; 136 137 bool fMouseDown; 138 BPoint fTrackingStart; 139 BPoint fLastCanvasPos; 140 141 VectorPath* fPath; 142 int32 fCurrentPathPoint; 143 BRect fPreviousBounds; 144 145 ChangePointCommand* fChangePointCommand; 146 InsertPointCommand* fInsertPointCommand; 147 AddPointCommand* fAddPointCommand; 148 149 Selection* fSelection; 150 Selection* fOldSelection; 151 152 // stuff needed for nudging 153 BPoint fNudgeOffset; 154 bigtime_t fLastNudgeTime; 155 // NudgePointsCommand* fNudgeCommand; 156 }; 157 158 #endif // SHAPE_STATE_H 159