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