1// Aseprite
2// Copyright (C) 2019-2020 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_SLICE_WINDOW_H_INCLUDED
9#define APP_UI_SLICE_WINDOW_H_INCLUDED
10#pragma once
11
12#include "app/ui/user_data_view.h"
13#include "doc/anidir.h"
14#include "doc/frame.h"
15#include "doc/selected_objects.h"
16#include "doc/user_data.h"
17
18#include "slice_properties.xml.h"
19
20namespace doc {
21 class Slice;
22 class Sprite;
23}
24
25namespace app {
26
27 class SliceWindow : protected app::gen::SliceProperties {
28 public:
29 enum Mods {
30 kNone = 0x0000,
31 kName = 0x0001,
32 kBoundsX = 0x0002,
33 kBoundsY = 0x0004,
34 kBoundsW = 0x0008,
35 kBoundsH = 0x0010,
36 kCenterX = 0x0020,
37 kCenterY = 0x0040,
38 kCenterW = 0x0080,
39 kCenterH = 0x0100,
40 kPivotX = 0x0200,
41 kPivotY = 0x0400,
42 kUserData = 0x0800,
43 kAll = 0xffff,
44 };
45
46 SliceWindow(const doc::Sprite* sprite,
47 const doc::SelectedObjects& slices,
48 const doc::frame_t frame);
49
50 bool show();
51
52 std::string nameValue() const;
53 gfx::Rect boundsValue() const;
54 gfx::Rect centerValue() const;
55 gfx::Point pivotValue() const;
56 const doc::UserData& userDataValue() const { return m_userDataView.userData(); }
57
58 Mods modifiedFields() const { return m_mods; }
59
60 private:
61 void onCenterChange();
62 void onPivotChange();
63 void onToggleUserData();
64 void onModifyField(ui::Entry* entry, const Mods mods);
65 void onPossibleColorChange();
66
67 // Flags used to know what specific entry/checkbox was modified
68 // when we edit multiple-slices in the same property dialog. In
69 // this way we know what field modify of each slice in
70 // SlicePropertiesCommand::onExecute().
71 Mods m_mods;
72 UserDataView m_userDataView;
73 };
74
75}
76
77#endif
78