1 #ifndef TERMOX_WIDGET_WIDGET_SPINNER_HPP
2 #define TERMOX_WIDGET_WIDGET_SPINNER_HPP
7 #include <termox/painter/glyph_string.hpp>
8 #include <termox/widget/widget.hpp>
16 using Duration_t = std::chrono::milliseconds;
20 Duration_t period = Duration_t{100};
28 Duration_t period = Duration_t{100},
37 [[nodiscard]]
auto frames() const noexcept ->
Glyph_string const&;
39 void set_period(Duration_t period);
41 [[nodiscard]] auto period() const noexcept -> Duration_t;
43 void set_width(
int width);
45 [[nodiscard]] auto spinner_width() const noexcept ->
int;
47 void set_offset(
int offset);
60 bool started_ = false;
68 [[nodiscard]] auto spinner(
72 int offset = 0) -> std::unique_ptr<Spinner>;
75 [[nodiscard]]
auto spinner(Spinner::Parameters p) -> std::unique_ptr<Spinner>;
81 Duration_t period = Duration_t{100};
93 [[nodiscard]]
auto spinner_cycle(
94 Spinner::Duration_t period = Spinner::Duration_t{100},
96 int offset = 0) -> std::unique_ptr<Spinner_cycle>;
98 [[nodiscard]]
auto spinner_cycle(Spinner_cycle::Parameters p)
99 -> std::unique_ptr<Spinner_cycle>;
108 template <
typename... Args>
109 [[nodiscard]]
auto spinner_cycle_ccw(Args&&... args)
110 -> std::unique_ptr<Spinner_cycle_ccw>
112 return std::make_unique<Spinner_cycle_ccw>(std::forward<Args>(args)...);
122 template <
typename... Args>
123 [[nodiscard]]
auto spinner_fall(Args&&... args) -> std::unique_ptr<Spinner_fall>
125 return std::make_unique<Spinner_fall>(std::forward<Args>(args)...);
135 template <
typename... Args>
136 [[nodiscard]]
auto spinner_fall_two(Args&&... args)
137 -> std::unique_ptr<Spinner_fall_two>
139 return std::make_unique<Spinner_fall_two>(std::forward<Args>(args)...);
149 template <
typename... Args>
150 [[nodiscard]]
auto spinner_fall_three(Args&&... args)
151 -> std::unique_ptr<Spinner_fall_three>
153 return std::make_unique<Spinner_fall_three>(std::forward<Args>(args)...);
163 template <
typename... Args>
164 [[nodiscard]]
auto spinner_rise(Args&&... args) -> std::unique_ptr<Spinner_rise>
166 return std::make_unique<Spinner_rise>(std::forward<Args>(args)...);
176 template <
typename... Args>
177 [[nodiscard]]
auto spinner_rise_two(Args&&... args)
178 -> std::unique_ptr<Spinner_rise_two>
180 return std::make_unique<Spinner_rise_two>(std::forward<Args>(args)...);
190 template <
typename... Args>
191 [[nodiscard]]
auto spinner_rise_three(Args&&... args)
192 -> std::unique_ptr<Spinner_rise_three>
194 return std::make_unique<Spinner_rise_three>(std::forward<Args>(args)...);
204 template <
typename... Args>
205 [[nodiscard]]
auto spinner_fill(Args&&... args) -> std::unique_ptr<Spinner_fill>
207 return std::make_unique<Spinner_fill>(std::forward<Args>(args)...);
217 template <
typename... Args>
218 [[nodiscard]]
auto spinner_top_fill(Args&&... args)
219 -> std::unique_ptr<Spinner_top_fill>
221 return std::make_unique<Spinner_top_fill>(std::forward<Args>(args)...);
231 template <
typename... Args>
232 [[nodiscard]]
auto spinner_tail(Args&&... args) -> std::unique_ptr<Spinner_tail>
234 return std::make_unique<Spinner_tail>(std::forward<Args>(args)...);
244 template <
typename... Args>
245 auto spinner_switch(Args&&... args) -> std::unique_ptr<Spinner_switch>
247 return std::make_unique<Spinner_switch>(std::forward<Args>(args)...);
257 template <
typename... Args>
258 [[nodiscard]]
auto spinner_chase(Args&&... args)
259 -> std::unique_ptr<Spinner_chase>
261 return std::make_unique<Spinner_chase>(std::forward<Args>(args)...);
271 template <
typename... Args>
272 [[nodiscard]]
auto spinner_line(Args&&... args) -> std::unique_ptr<Spinner_line>
274 return std::make_unique<Spinner_line>(std::forward<Args>(args)...);
284 template <
typename... Args>
285 [[nodiscard]]
auto spinner_block_cycle(Args&&... args)
286 -> std::unique_ptr<Spinner_block_cycle>
288 return std::make_unique<Spinner_block_cycle>(std::forward<Args>(args)...);
298 template <
typename... Args>
299 [[nodiscard]]
auto spinner_fade(Args&&... args) -> std::unique_ptr<Spinner_fade>
301 return std::make_unique<Spinner_fade>(std::forward<Args>(args)...);
312 template <
typename... Args>
313 [[nodiscard]]
auto spinner_fade_trail(Args&&... args)
314 -> std::unique_ptr<Spinner_fade_trail>
316 return std::make_unique<Spinner_fade_trail>(std::forward<Args>(args)...);
326 template <
typename... Args>
327 [[nodiscard]]
auto spinner_quarter_circles(Args&&... args)
328 -> std::unique_ptr<Spinner_quarter_circles>
330 return std::make_unique<Spinner_quarter_circles>(
331 std::forward<Args>(args)...);
341 template <
typename... Args>
342 [[nodiscard]]
auto spinner_triangles(Args&&... args)
343 -> std::unique_ptr<Spinner_triangles>
345 return std::make_unique<Spinner_triangles>(std::forward<Args>(args)...);
355 template <
typename... Args>
356 [[nodiscard]]
auto spinner_empty_triangles(Args&&... args)
357 -> std::unique_ptr<Spinner_empty_triangles>
359 return std::make_unique<Spinner_empty_triangles>(
360 std::forward<Args>(args)...);
370 template <
typename... Args>
371 [[nodiscard]]
auto spinner_clock(Args&&... args)
372 -> std::unique_ptr<Spinner_clock>
374 return std::make_unique<Spinner_clock>(std::forward<Args>(args)...);
384 template <
typename... Args>
385 [[nodiscard]]
auto spinner_box(Args&&... args) -> std::unique_ptr<Spinner_box>
387 return std::make_unique<Spinner_box>(std::forward<Args>(args)...);
397 template <
typename... Args>
398 [[nodiscard]]
auto spinner_cross(Args&&... args)
399 -> std::unique_ptr<Spinner_cross>
401 return std::make_unique<Spinner_cross>(std::forward<Args>(args)...);
417 template <
typename... Args>
418 [[nodiscard]]
auto spinner_vertical_pass(Args&&... args)
419 -> std::unique_ptr<Spinner_vertical_pass>
421 return std::make_unique<Spinner_vertical_pass>(std::forward<Args>(args)...);
437 template <
typename... Args>
438 [[nodiscard]]
auto spinner_horizontal_pass(Args&&... args)
439 -> std::unique_ptr<Spinner_horizontal_pass>
441 return std::make_unique<Spinner_horizontal_pass>(
442 std::forward<Args>(args)...);
452 template <
typename... Args>
453 [[nodiscard]]
auto spinner_bump(Args&&... args) -> std::unique_ptr<Spinner_bump>
455 return std::make_unique<Spinner_bump>(std::forward<Args>(args)...);
Holds a collection of Glyphs with a similar interface to std::string.
Definition: glyph_string.hpp:19
Contains functions to paint Glyphs to a Widget's screen area.
Definition: painter.hpp:21
Single cell animated spinner.
Definition: spinner.hpp:14
auto paint_event(Painter &p) -> bool override
Handles Paint_event objects.
Definition: spinner.cpp:65
auto timer_event() -> bool override
Handles Timer_event objects.
Definition: spinner.cpp:74
Spinner(Glyph_string frames, Duration_t period=Duration_t{100}, int width=1, int offset=0)
Each glyph in frames is a frame, offset is starting index into frames.
Definition: spinner.cpp:13
Definition: spinner.hpp:18
Definition: spinner.hpp:277
Definition: spinner.hpp:377
Definition: spinner.hpp:445
Definition: spinner.hpp:250
Definition: spinner.hpp:363
Definition: spinner.hpp:390
Definition: spinner.hpp:80
Definition: spinner.hpp:101
Specific Spinners.
Definition: spinner.hpp:79
Definition: spinner.hpp:348
Best used with multiple spinners horizontally, each offset one from neighbor.
Definition: spinner.hpp:305
Definition: spinner.hpp:291
Definition: spinner.hpp:142
Definition: spinner.hpp:128
Definition: spinner.hpp:115
Definition: spinner.hpp:197
Definition: spinner.hpp:424
Definition: spinner.hpp:264
Definition: spinner.hpp:319
Definition: spinner.hpp:183
Definition: spinner.hpp:169
Definition: spinner.hpp:156
Definition: spinner.hpp:237
Definition: spinner.hpp:224
Definition: spinner.hpp:210
Definition: spinner.hpp:334
Definition: spinner.hpp:404