| 1 | // Aseprite |
| 2 | // Copyright (c) 2020 Igara Studio S.A. |
| 3 | // |
| 4 | // This program is distributed under the terms of |
| 5 | // the End-User License Agreement for Aseprite. |
| 6 | |
| 7 | #ifndef APP_UI_TILE_BUTTON_H_INCLUDED |
| 8 | #define APP_UI_TILE_BUTTON_H_INCLUDED |
| 9 | #pragma once |
| 10 | |
| 11 | #include "app/color.h" |
| 12 | #include "app/context_observer.h" |
| 13 | #include "app/ui/tile_source.h" |
| 14 | #include "doc/tile.h" |
| 15 | #include "ui/button.h" |
| 16 | |
| 17 | namespace app { |
| 18 | |
| 19 | class TileButton : public ui::ButtonBase, |
| 20 | public ContextObserver, |
| 21 | public ITileSource { |
| 22 | public: |
| 23 | TileButton(); |
| 24 | ~TileButton(); |
| 25 | |
| 26 | doc::tile_t getTile() const; |
| 27 | void setTile(doc::tile_t tile); |
| 28 | |
| 29 | // ITileSource |
| 30 | doc::tile_t getTileByPosition(const gfx::Point& pos) override; |
| 31 | |
| 32 | // Signals |
| 33 | obs::signal<void(doc::tile_t&)> BeforeChange; |
| 34 | obs::signal<void(doc::tile_t)> Change; |
| 35 | |
| 36 | protected: |
| 37 | // Events |
| 38 | void onInitTheme(ui::InitThemeEvent& ev) override; |
| 39 | bool onProcessMessage(ui::Message* msg) override; |
| 40 | void onSizeHint(ui::SizeHintEvent& ev) override; |
| 41 | void onPaint(ui::PaintEvent& ev) override; |
| 42 | |
| 43 | private: |
| 44 | // ContextObserver impl |
| 45 | void onActiveSiteChange(const Site& site) override; |
| 46 | |
| 47 | doc::tile_t m_tile = doc::notile; |
| 48 | }; |
| 49 | |
| 50 | } // namespace app |
| 51 | |
| 52 | #endif |
| 53 | |