gcsx_animgrouppaint.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /* GCSx
  2. ** ANIMGROUPPAINT.H
  3. **
  4. ** Animation group editing
  5. */
  6. /*****************************************************************************
  7. ** Copyright (C) 2003-2006 Janson
  8. **
  9. ** This program is free software; you can redistribute it and/or modify
  10. ** it under the terms of the GNU General Public License as published by
  11. ** the Free Software Foundation; either version 2 of the License, or
  12. ** (at your option) any later version.
  13. **
  14. ** This program is distributed in the hope that it will be useful,
  15. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ** GNU General Public License for more details.
  18. **
  19. ** You should have received a copy of the GNU General Public License
  20. ** along with this program; if not, write to the Free Software
  21. ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
  22. *****************************************************************************/
  23. #ifndef __GCSx_ANIMGROUPPAINT_H_
  24. #define __GCSx_ANIMGROUPPAINT_H_
  25. class AnimGroupPaintTools : public Dialog {
  26. private:
  27. class FrameWindow* myFrame;
  28. class ToolSelect* toolSelect;
  29. class ToolSelect* outlineSelect;
  30. class ImageSelect* imagebar;
  31. class AnimGroupPaint* paintArea;
  32. enum {
  33. // For tool popup selections
  34. TOOLSELECT_NUM_TOOLS = 3,
  35. // Outline options selection
  36. TOOLSELECT_NUM_OUTLINE = 3,
  37. };
  38. static const ToolSelect::ToolIconStruct toolIcons[TOOLSELECT_NUM_TOOLS];
  39. static const ToolSelect::ToolIconStruct outlineIcons[TOOLSELECT_NUM_OUTLINE];
  40. // Used to help resize preview area- this is
  41. // our height if preview is 0 pixels high
  42. int minHeight;
  43. public:
  44. enum {
  45. // Color select
  46. ID_COLOR = 1,
  47. // Individual buttons
  48. ID_TOOLL,
  49. ID_TOOLR,
  50. ID_COPY,
  51. ID_PASTE,
  52. ID_TOP,
  53. ID_UP,
  54. ID_DOWN,
  55. ID_BOTTOM,
  56. // Setting buttons
  57. ID_OUTLINE,
  58. // Animation name
  59. ID_NAMELABEL,
  60. ID_NAME,
  61. // Tileset
  62. ID_TILESETLABEL,
  63. ID_TILESET,
  64. // Preview
  65. ID_PREVIEW,
  66. };
  67. int* toolLPtr;
  68. int* toolRPtr;
  69. int* outlinePtr;
  70. std::string* animNamePtr;
  71. class TileSetEdit** tilesetPtr;
  72. int selectedTileset;
  73. class WListBox* tilesetList;
  74. AnimGroupPaintTools(class AnimGroupPaint* tPaintArea, class ImageSelect* mImagebar, int* toolL, int* toolR, int* outline, std::string* animName, class TileSetEdit** tileset);
  75. ~AnimGroupPaintTools();
  76. // Creates a FrameWindow and returns, does not add self to desktop (use ->show() to do that)
  77. class FrameWindow* createWindowed();
  78. int event(int hasFocus, const SDL_Event* event);
  79. void resize(int newWidth, int newHeight, int newViewWidth = -1, int newViewHeight = -1, int fromParent = 0);
  80. void childModified(Window* modified);
  81. void previewRedraw();
  82. int wantsToBeDeleted() const;
  83. WindowSort windowSort() const;
  84. };
  85. class AnimGroupPaint : public Window {
  86. private:
  87. class FrameWindow* myFrame;
  88. AnimGroupPaintTools* tools;
  89. ImageSelect* imagebar;
  90. class ColorSelect* colorbar;
  91. int hover;
  92. int lastMouseX;
  93. int lastMouseY;
  94. int toolL;
  95. int toolR;
  96. int outline;
  97. int enableGrid;
  98. AnimGroupEdit* animgroup;
  99. ColorStore colors;
  100. class TileSetEdit* tileset; // Can't be const
  101. // Storage for editing
  102. AnimSequence anim;
  103. // @TODO: separate ptr to current frame for speed?
  104. int seqId; // Which sequence and which frame of that seq we're editing
  105. int frameId;
  106. int frameCount; // Total # frames in current sequence
  107. int cursorComp; // Which component is the cursor on (<0 for no cursor)
  108. std::set<int> selected; // Which components are selected
  109. std::set<int> backupSelected;
  110. Rect selectRect;
  111. Rect backupSelectRect;
  112. int haveFocus;
  113. int partialFocus;
  114. int toolActive;
  115. int toolCtrl;
  116. int toolAlt;
  117. int toolStartX; // Starting coordinates for a component/selection rect drag
  118. int toolStartY;
  119. int toolLastX; // Last used coordinates during a drag
  120. int toolLastY;
  121. // (doesn't set any sort of dirty)
  122. void refreshData();
  123. void applyData();
  124. void refreshName();
  125. void applyName();
  126. void startTool(int x, int y, int button);
  127. void startToolSelectionDrag(int x, int y);
  128. void modifyTool(); // Call if CTRL/ALT changes
  129. void dragTool(int x, int y, int firstTime = 0, int lastTime = 0);
  130. void finishTool();
  131. void cancelTool();
  132. // Dirty range
  133. Rect dirtyRange;
  134. // Set partial dirty by area (pixel) specifically allows ranges outside maximums
  135. void setDirtyBox(int x1, int y1, int x2, int y2);
  136. void setDirtyRect(const Rect& rect);
  137. // Set partial dirty by component
  138. void setDirtyComp(int subid);
  139. // Undo wrappers
  140. void undoStore() throw_Undo; // Simply stores entire frame
  141. void undoStoreSelect() throw_Undo;
  142. // Selection tool- clips; coordinates in pixels
  143. void selectViaRect(int x1, int y1, int x2, int y2, int set);
  144. // Clear selection
  145. void clearSelection(int storeUndo = 1) throw_Undo;
  146. // Copy selection to clipboard
  147. void copySelection();
  148. // Paste clipboard as a new selection; Stores undo
  149. void pasteSelection() throw_Undo;
  150. // Delete selected items; Stores undo
  151. void deleteSelection() throw_Undo;
  152. // Returns true if a given pixel x/y is within a currently selected component
  153. int isInSelection(int x, int y) const;
  154. // Moves all selected items- doesn't store update or undo
  155. void moveSelection(int changeX, int changeY);
  156. void mousePointer();
  157. void mousePointer(int mouseX, int mouseY);
  158. void updateTitlebar();
  159. enum {
  160. // size of frame resize handle
  161. RESIZE_HANDLE_SIZE = 8,
  162. };
  163. public:
  164. // Opens the window (animid is 1-based)
  165. AnimGroupPaint(AnimGroupEdit* myAnimGroup, int animId) throw_File;
  166. ~AnimGroupPaint();
  167. // Called by tool panel to tell us to refresh view
  168. void refresh();
  169. CommandSupport supportsCommand(int code) const;
  170. int event(int hasFocus, const SDL_Event* event);
  171. void display(SDL_Surface* destSurface, Rect& toDisplay, const Rect& clipArea, int xOffset, int yOffset);
  172. WindowType windowType() const;
  173. void siblingModified(Window* modified);
  174. // @TODO: void undoNotify(int undoType, int undoItemId, int undoItemSubId, int uX, int uY, int uW, int uH);
  175. // (attempt to scroll to view an affected area)
  176. };
  177. #endif