1 // Aseprite
2 // Copyright (C) 2001-2017  David Capello
3 //
4 // This program is distributed under the terms of
5 // the End-User License Agreement for Aseprite.
6 
7 #ifndef APP_UI_EDITOR_MOVING_CEL_STATE_H_INCLUDED
8 #define APP_UI_EDITOR_MOVING_CEL_STATE_H_INCLUDED
9 #pragma once
10 
11 #include "app/ui/editor/standby_state.h"
12 
13 #include "app/context_access.h"
14 #include "app/ui/editor/handle_type.h"
15 #include "doc/cel_list.h"
16 
17 #include <vector>
18 
19 namespace doc {
20   class Cel;
21 }
22 
23 namespace app {
24   class Editor;
25 
26   class MovingCelCollect {
27   public:
28     MovingCelCollect(Editor* editor, Layer* layer);
29 
empty()30     bool empty() const { return m_celList.empty(); }
31 
mainCel()32     Cel* mainCel() const { return m_mainCel; }
celList()33     const CelList& celList() const { return m_celList; }
34 
35   private:
36     Cel* m_mainCel;
37     CelList m_celList;
38   };
39 
40   class MovingCelState : public StandbyState {
41   public:
42     MovingCelState(Editor* editor,
43                    ui::MouseMessage* msg,
44                    const HandleType handle,
45                    const MovingCelCollect& collect);
46 
47     virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) override;
48     virtual bool onMouseMove(Editor* editor, ui::MouseMessage* msg) override;
49     virtual bool onKeyDown(Editor* editor, ui::KeyMessage* msg) override;
50     virtual bool onUpdateStatusBar(Editor* editor) override;
51 
requireBrushPreview()52     virtual bool requireBrushPreview() override { return false; }
53 
54   private:
55     gfx::Point intCelOffset() const;
56 
57     ContextReader m_reader;
58     Cel* m_cel;
59     CelList m_celList;
60     std::vector<gfx::RectF> m_celStarts;
61     gfx::PointF m_cursorStart;
62     gfx::PointF m_celOffset;
63     gfx::SizeF m_celMainSize;
64     gfx::SizeF m_celScale;
65     bool m_maskVisible;
66     bool m_hasReference;
67     bool m_scaled;
68     HandleType m_handle;
69   };
70 
71 } // namespace app
72 
73 #endif  // APP_UI_EDITOR_MOVING_CEL_STATE_H_INCLUDED
74