1 | // Aseprite |
2 | // Copyright (C) 2019 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_TASK_WIDGET_H_INCLUDED |
8 | #define APP_UI_TASK_WIDGET_H_INCLUDED |
9 | #pragma once |
10 | |
11 | #include "app/task.h" |
12 | #include "obs/signal.h" |
13 | #include "ui/box.h" |
14 | #include "ui/button.h" |
15 | #include "ui/slider.h" |
16 | #include "ui/timer.h" |
17 | |
18 | namespace app { |
19 | |
20 | class TaskWidget : public ui::Box { |
21 | public: |
22 | enum Type { |
23 | kCanCancel = 1, |
24 | kWithProgress = 2, |
25 | kCannotCancel = kWithProgress, |
26 | kCancelAndProgress = 3, |
27 | }; |
28 | |
29 | TaskWidget(const Type type, |
30 | base::task::func_t&& func); |
31 | TaskWidget(base::task::func_t&& func) |
32 | : TaskWidget(kCancelAndProgress, std::move(func)) { } |
33 | |
34 | protected: |
35 | virtual void onComplete(); |
36 | |
37 | private: |
38 | ui::Timer m_monitorTimer; |
39 | ui::Button m_cancelButton; |
40 | ui::Slider m_progressBar; |
41 | Task m_task; |
42 | }; |
43 | |
44 | } // namespace app |
45 | |
46 | #endif |
47 | |