@ImageEditor.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /******************************************************************************/
  2. /******************************************************************************/
  3. class ImageEditor : PropWin
  4. {
  5. static void Render(); // we just want the skybox, so no need to draw anything else
  6. class GuiImage2 : ImageSkin
  7. {
  8. Camera cam;
  9. virtual GuiObj* test (C GuiPC &gpc, C Vec2 &pos, GuiObj* &mouse_wheel)override;
  10. virtual void update(C GuiPC &gpc)override;
  11. virtual void draw(C GuiPC &gpc)override;
  12. };
  13. class CubeFace : ImageSkin
  14. {
  15. Vec2 ofs;
  16. DIR_ENUM face;
  17. CubeFace& create(DIR_ENUM dir, int x, int y);
  18. virtual void draw(C GuiPC &gpc)override;
  19. public:
  20. CubeFace();
  21. };
  22. class Change : Edit::_Undo::Change
  23. {
  24. ElmImage data;
  25. virtual void create(ptr user)override;
  26. virtual void apply(ptr user)override;
  27. };
  28. UID elm_id;
  29. Elm *elm;
  30. bool changed, no_scale, source;
  31. int channels;
  32. Button undo, redo, locate;
  33. GuiImage2 gui_image;
  34. Image edit_image, image_2d;
  35. ImagePtr game_image;
  36. CubeFace cube_faces[6];
  37. Property *width, *height, *type, *mip_maps, *mem_size, *chn, *nos, *src;
  38. Edit::Undo<Change> undos; void undoVis();
  39. ElmImage* data()C;
  40. class ImageMode
  41. {
  42. IMAGE_MODE mode;
  43. cchar8 *name;
  44. cchar *desc;
  45. };
  46. static ImageMode ImageModes[]
  47. ;
  48. static cchar8 *Channels[]
  49. ;
  50. static int ChannelsElms;
  51. static void PreChanged(C Property &prop);
  52. static void Changed(C Property &prop);
  53. static void Type ( ImageEditor &ie, C Str &t);
  54. static Str Type (C ImageEditor &ie );
  55. static void Mode ( ImageEditor &ie, C Str &t);
  56. static Str Mode (C ImageEditor &ie );
  57. static void MipMaps ( ImageEditor &ie, C Str &t);
  58. static Str MipMaps (C ImageEditor &ie );
  59. static void Pow2 ( ImageEditor &ie, C Str &t);
  60. static Str Pow2 (C ImageEditor &ie );
  61. static void Width ( ImageEditor &ie, C Str &t);
  62. static Str Width (C ImageEditor &ie );
  63. static void Height ( ImageEditor &ie, C Str &t);
  64. static Str Height (C ImageEditor &ie );
  65. static void AlphaLum( ImageEditor &ie, C Str &t);
  66. static Str AlphaLum(C ImageEditor &ie );
  67. static void Undo (ImageEditor &editor);
  68. static void Redo (ImageEditor &editor);
  69. static void Locate(ImageEditor &editor);
  70. void setMipMap(bool on);
  71. void create();
  72. void make2D();
  73. void setInfo();
  74. virtual void update(C GuiPC &gpc)override;
  75. virtual ImageEditor& hide ( ) override;
  76. virtual Rect sizeLimit( )C override;
  77. virtual ImageEditor& rect (C Rect &rect) override;
  78. void flush();
  79. void setChanged();
  80. void set(Elm *elm);
  81. void activate(Elm *elm);
  82. void toggle (Elm *elm);
  83. void elmChanged(C UID &elm_id);
  84. class ImageName
  85. {
  86. Str name, file;
  87. void set(C Str &name, C Str &file);
  88. };
  89. int FaceToIndex(DIR_ENUM dir);
  90. void setImage(Memc<ImageName> &images, GuiObj *obj);
  91. void drop(Memc<Str> &names, GuiObj *obj, C Vec2 &screen_pos);
  92. void drag(Memc<UID> &elms, GuiObj *obj, C Vec2 &screen_pos);
  93. void erasing(C UID &elm_id);
  94. public:
  95. ImageEditor();
  96. };
  97. /******************************************************************************/
  98. /******************************************************************************/
  99. extern ImageEditor ImageEdit;
  100. /******************************************************************************/