FINAL CUT
fbusyindicator.h
1 /***********************************************************************
2 * fbusyindicator.h - Shows background activity *
3 * *
4 * This file is part of the FINAL CUT widget toolkit *
5 * *
6 * Copyright 2020-2023 Markus Gans *
7 * *
8 * FINAL CUT is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as *
10 * published by the Free Software Foundation; either version 3 of *
11 * the License, or (at your option) any later version. *
12 * *
13 * FINAL CUT is distributed in the hope that it will be useful, but *
14 * WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this program. If not, see *
20 * <http://www.gnu.org/licenses/>. *
21 ***********************************************************************/
22 
23 /* Inheritance diagram
24  * ═══════════════════
25  *
26  * ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
27  * ▕ FVTerm ▏ ▕ FObject ▏
28  * ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
29  * ▲ ▲
30  * │ │
31  * └─────┬─────┘
32  * │
33  * ▕▔▔▔▔▔▔▔▔▔▏
34  * ▕ FWidget ▏
35  * ▕▁▁▁▁▁▁▁▁▁▏
36  * ▲
37  * │
38  * ▕▔▔▔▔▔▔▔▔▔▏
39  * ▕ FWindow ▏
40  * ▕▁▁▁▁▁▁▁▁▁▏
41  * ▲
42  * │
43  * ▕▔▔▔▔▔▔▔▔▔▔▏
44  * ▕ FToolTip ▏
45  * ▕▁▁▁▁▁▁▁▁▁▁▏
46  * ▲
47  * │
48  * ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
49  * ▕ FBusyIndicator ▏
50  * ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
51  */
52 
53 #ifndef FBUSYINDICATOR_H
54 #define FBUSYINDICATOR_H
55 
56 #if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
57  #error "Only <final/final.h> can be included directly."
58 #endif
59 
60 #include <string>
61 
62 #include "final/widget/ftooltip.h"
63 
64 namespace finalcut
65 {
66 
67 //----------------------------------------------------------------------
68 // class FBusyIndicator
69 //----------------------------------------------------------------------
70 
71 class FBusyIndicator : public FToolTip
72 {
73  public:
74  // Constructor
75  explicit FBusyIndicator (FWidget* = nullptr);
76 
77  // Destructor
78  ~FBusyIndicator() noexcept override;
79 
80  // Accessors
81  auto getClassName() const -> FString override;
82 
83  // Inquiries
84  auto isRunning() const noexcept -> bool;
85 
86  // Methods
87  void start();
88  void stop();
89 
90  private:
91  // Constants
92  static constexpr std::size_t TIMER = 200;
93 
94  // Methods
95  void init();
96  void createIndicatorText();
97 
98  // Event handler
99  void onTimer (finalcut::FTimerEvent*) override;
100 
101  // Callback methods
102 
103  // Data members
104  std::wstring uni_pattern{L' ', L' ', L'·', L'·', L'•', L'•', L'●', L'●'};
105  std::string pattern{L' ', L' ', L'.', L'.', L'+', L'+', L'#', L'#'};
106  bool running{false};
107 };
108 
109 
110 // FBusyIndicator inline functions
111 //----------------------------------------------------------------------
112 inline auto FBusyIndicator::getClassName() const -> FString
113 { return "FBusyIndicator"; }
114 
115 //----------------------------------------------------------------------
116 inline auto FBusyIndicator::isRunning() const noexcept -> bool
117 {
118  return running;
119 }
120 
121 } // namespace finalcut
122 
123 #endif // FBUSYINDICATOR_H
124 
125 
Definition: fevent.h:300
Definition: fbusyindicator.h:71
Definition: class_template.cpp:25
Definition: ftooltip.h:66
Definition: fstring.h:79
Definition: fwidget.h:129