1// Aseprite
2// Copyright (C) 2019 Igara Studio S.A.
3// Copyright (C) 2017 David Capello
4//
5// This program is distributed under the terms of
6// the End-User License Agreement for Aseprite.
7
8#ifndef APP_UI_EDITOR_MOVING_SLICE_STATE_H_INCLUDED
9#define APP_UI_EDITOR_MOVING_SLICE_STATE_H_INCLUDED
10#pragma once
11
12#include "app/ui/editor/editor_hit.h"
13#include "app/ui/editor/standby_state.h"
14#include "doc/frame.h"
15#include "doc/selected_objects.h"
16#include "doc/slice.h"
17
18namespace app {
19 class Editor;
20
21 class MovingSliceState : public StandbyState {
22 public:
23 MovingSliceState(Editor* editor,
24 ui::MouseMessage* msg,
25 const EditorHit& hit,
26 const doc::SelectedObjects& selectedSlices);
27
28 bool onMouseUp(Editor* editor, ui::MouseMessage* msg) override;
29 bool onMouseMove(Editor* editor, ui::MouseMessage* msg) override;
30 bool onSetCursor(Editor* editor, const gfx::Point& mouseScreenPos) override;
31
32 bool requireBrushPreview() override { return false; }
33
34 private:
35 struct Item {
36 doc::Slice* slice;
37 doc::SliceKey oldKey;
38 doc::SliceKey newKey;
39 };
40
41 Item getItemForSlice(doc::Slice* slice);
42 gfx::Rect selectedSlicesBounds() const;
43
44 doc::frame_t m_frame;
45 EditorHit m_hit;
46 gfx::Point m_mouseStart;
47 std::vector<Item> m_items;
48 };
49
50} // namespace app
51
52#endif
53