1// Aseprite
2// Copyright (C) 2018-2022 Igara Studio S.A.
3// Copyright (C) 2001-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_STATUS_BAR_H_INCLUDED
9#define APP_UI_STATUS_BAR_H_INCLUDED
10#pragma once
11
12#include "app/color.h"
13#include "app/context_observer.h"
14#include "app/tools/active_tool_observer.h"
15#include "app/ui/doc_observer_widget.h"
16#include "base/time.h"
17#include "doc/tile.h"
18#include "ui/base.h"
19#include "ui/box.h"
20
21#include <string>
22#include <vector>
23
24namespace ui {
25 class Box;
26 class Button;
27 class Entry;
28 class Label;
29 class TooltipManager;
30 class Window;
31}
32
33namespace render {
34 class Zoom;
35}
36
37namespace app {
38 class ButtonSet;
39 class Editor;
40 class ZoomEntry;
41
42 namespace tools {
43 class Tool;
44 }
45
46 class StatusBar : public DocObserverWidget<ui::HBox>
47 , public tools::ActiveToolObserver {
48 static StatusBar* m_instance;
49 public:
50 static StatusBar* instance() { return m_instance; }
51
52 enum BackupIcon { None, Normal, Small };
53
54 StatusBar(ui::TooltipManager* tooltipManager);
55 ~StatusBar();
56
57 void clearText();
58 void showDefaultText();
59 void showDefaultText(Doc* doc);
60 void showAbout();
61
62 bool setStatusText(int msecs, const std::string& text);
63 void showTip(int msecs, const std::string& msg);
64 void showColor(int msecs, const Color& color,
65 const std::string& text = std::string());
66 void showTile(int msecs, doc::tile_t tile,
67 const std::string& text = std::string());
68 void showTool(int msecs, tools::Tool* tool);
69 void showSnapToGridWarning(bool state);
70
71 // Used by AppEditor to update the zoom level in the status bar.
72 void updateFromEditor(Editor* editor);
73
74 void showBackupIcon(BackupIcon icon);
75
76 protected:
77 void onInitTheme(ui::InitThemeEvent& ev) override;
78 void onResize(ui::ResizeEvent& ev) override;
79
80 // ContextObserver impl
81 void onActiveSiteChange(const Site& site) override;
82
83 // DocObserver impl
84 void onPixelFormatChanged(DocEvent& ev) override;
85
86 // ActiveToolObserver impl
87 void onSelectedToolChange(tools::Tool* tool) override;
88
89 private:
90 void onCelOpacitySliderChange();
91 void newFrame();
92 void onChangeZoom(const render::Zoom& zoom);
93 void updateSnapToGridWindowPosition();
94 void showIndicators();
95
96 base::tick_t m_timeout;
97
98 // About text
99 class AboutStatusBar;
100 AboutStatusBar* m_about;
101
102 // Indicators
103 class Indicators;
104 class IndicatorsGeneration;
105 Indicators* m_indicators;
106
107 // Box of main commands
108 ui::Widget* m_docControls;
109 ui::Box* m_commandsBox;
110 ui::Label* m_frameLabel;
111 ui::Entry* m_currentFrame; // Current frame and go to frame entry
112 ui::Button* m_newFrame; // Button to create a new frame
113 ZoomEntry* m_zoomEntry;
114
115 // Tip window
116 class CustomizedTipWindow;
117 CustomizedTipWindow* m_tipwindow;
118
119 // Snap to grid window
120 class SnapToGridWindow;
121 SnapToGridWindow* m_snapToGridWindow;
122 };
123
124} // namespace app
125
126#endif
127