1// Aseprite
2// Copyright (C) 2019-2022 Igara Studio S.A.
3// Copyright (C) 2016-2018 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_LAYER_FRAME_COMBOBOXES_H_INCLUDED
9#define APP_UI_LAYER_FRAME_COMBOBOXES_H_INCLUDED
10#pragma once
11
12#include "doc/anidir.h"
13#include "ui/listitem.h"
14
15#include <string>
16
17namespace doc {
18 class Layer;
19 class SelectedFrames;
20 class SelectedLayers;
21 class Slice;
22 class Sprite;
23 class Tag;
24}
25
26namespace ui {
27 class ComboBox;
28}
29
30namespace app {
31 class RestoreVisibleLayers;
32 class Site;
33
34 extern const char* kWholeCanvas;
35 extern const char* kAllLayers;
36 extern const char* kAllFrames;
37 extern const char* kSelectedCanvas;
38 extern const char* kSelectedLayers;
39 extern const char* kSelectedFrames;
40
41 class SliceListItem : public ui::ListItem {
42 public:
43 SliceListItem(doc::Slice* slice);
44 doc::Slice* slice() const { return m_slice; }
45 private:
46 doc::Slice* m_slice;
47 };
48
49 constexpr const int kLayersComboboxExtraInitialItems = 2;
50
51 class LayerListItem : public ui::ListItem {
52 public:
53 LayerListItem(doc::Layer* layer);
54 doc::Layer* layer() const { return m_layer; }
55 private:
56 static std::string buildName(const doc::Layer* layer);
57 doc::Layer* m_layer;
58 };
59
60 class FrameListItem : public ui::ListItem {
61 public:
62 FrameListItem(doc::Tag* tag);
63 doc::Tag* tag() const { return m_tag; }
64 private:
65 doc::Tag* m_tag;
66 };
67
68 void fill_area_combobox(const doc::Sprite* sprite, ui::ComboBox* area, const std::string& defArea);
69 void fill_layers_combobox(const doc::Sprite* sprite, ui::ComboBox* layers, const std::string& defLayer, const int defLayerIndex);
70 void fill_frames_combobox(const doc::Sprite* sprite, ui::ComboBox* frames, const std::string& defFrame);
71 void fill_anidir_combobox(ui::ComboBox* anidir, doc::AniDir defAnidir);
72
73 void calculate_visible_layers(const Site& site,
74 const std::string& layersValue,
75 const int layersIndex,
76 RestoreVisibleLayers& layersVisibility);
77
78 doc::Tag* calculate_selected_frames(const Site& site,
79 const std::string& framesValue,
80 doc::SelectedFrames& selFrames);
81
82} // namespace app
83
84#endif
85