1 #ifndef TERMOX_WIDGET_PIPE_HPP
2 #define TERMOX_WIDGET_PIPE_HPP
11 #include <termox/common/filter_iterator.hpp>
12 #include <termox/common/overload.hpp>
13 #include <termox/common/range.hpp>
14 #include <termox/common/transform_iterator.hpp>
15 #include <termox/painter/glyph_string.hpp>
16 #include <termox/system/system.hpp>
17 #include <termox/widget/align.hpp>
18 #include <termox/widget/bordered.hpp>
19 #include <termox/widget/detail/pipe_utility.hpp>
20 #include <termox/widget/focus_policy.hpp>
21 #include <termox/widget/growth.hpp>
22 #include <termox/widget/point.hpp>
23 #include <termox/widget/widget.hpp>
24 #include <termox/widget/wrap.hpp>
25 #include "termox/widget/size_policy.hpp"
31 [[nodiscard]]
inline auto children()
34 auto c = get(w).get_children();
35 return Range{c.begin(), c.end()};
40 [[nodiscard]]
inline auto descendants()
42 return [](
auto&& w) {
return get(w).get_descendants(); };
47 [[nodiscard]]
auto for_each(F&& f)
49 return [&](
auto&& w) -> decltype(
auto) {
50 std::forward<F>(f)(get(w));
51 return std::forward<decltype(w)>(w);
57 [[nodiscard]]
auto filter(F&& predicate)
59 return pipe::detail::Filter_predicate{predicate};
63 [[nodiscard]]
inline auto find(std::string
const& name)
65 return pipe::detail::Filter_predicate{
66 [=](
auto const& w) {
return w.name() == name; }};
70 template <
typename W
idget_t>
71 [[nodiscard]]
auto filter()
73 return pipe::detail::Dynamic_filter_predicate<Widget_t>{};
77 [[nodiscard]]
inline auto name(std::string
const& name)
79 return [=](
auto&& w) -> decltype(
auto) {
80 get(w).set_name(std::move(name));
81 return std::forward<decltype(w)>(w);
85 [[nodiscard]]
inline auto install_filter(Widget& filter)
87 return [&](
auto&& w) -> decltype(
auto) {
88 get(w).install_event_filter(filter);
89 return std::forward<decltype(w)>(w);
93 [[nodiscard]]
inline auto remove_filter(Widget& filter)
95 return [&](
auto&& w) -> decltype(
auto) {
96 get(w).remove_event_filter(filter);
97 return std::forward<decltype(w)>(w);
101 [[nodiscard]]
inline auto animate(std::chrono::milliseconds interval)
103 return [=](
auto&& w) -> decltype(
auto) {
104 get(w).enable_animation(interval);
105 return std::forward<decltype(w)>(w);
109 [[nodiscard]]
inline auto animate(FPS fps)
111 return [=](
auto&& w) -> decltype(
auto) {
112 get(w).enable_animation(fps);
113 return std::forward<decltype(w)>(w);
117 [[nodiscard]]
inline auto disanimate()
119 return [](
auto&& w) -> decltype(
auto) {
120 get(w).disable_animation();
121 return std::forward<decltype(w)>(w);
126 [[nodiscard]]
inline auto wallpaper(Glyph g)
128 return [=](
auto&& w) -> decltype(
auto) {
129 get(w).set_wallpaper(g);
130 return std::forward<decltype(w)>(w);
134 [[nodiscard]]
inline auto wallpaper_with_brush()
136 return [](
auto&& w) -> decltype(
auto) {
137 get(w).paint_wallpaper_with_brush(
true);
138 return std::forward<decltype(w)>(w);
142 [[nodiscard]]
inline auto wallpaper_without_brush()
144 return [](
auto&& w) -> decltype(
auto) {
145 get(w).paint_wallpaper_with_brush(
false);
146 return std::forward<decltype(w)>(w);
157 template <
typename Widget_t,
158 typename std::enable_if_t<pipe::detail::is_widget_or_wptr<Widget_t>,
160 auto operator|(Widget_t&& w, Background_color bg) -> decltype(
auto)
162 get(w).brush.background = Color{bg.value};
164 return std::forward<Widget_t>(w);
168 template <
typename Widget_t,
169 typename std::enable_if_t<pipe::detail::is_widget_or_wptr<Widget_t>,
171 auto operator|(Widget_t&& w, Foreground_color fg) -> decltype(
auto)
173 get(w).brush.foreground = Color{fg.value};
175 return std::forward<Widget_t>(w);
179 template <
typename Widget_t,
180 typename std::enable_if_t<pipe::detail::is_widget_or_wptr<Widget_t>,
182 auto operator|(Widget_t&& w, Trait t) -> decltype(
auto)
184 get(w).brush.traits.insert(t);
186 return std::forward<Widget_t>(w);
193 typename std::enable_if_t<pipe::detail::is_widget_v<Widget_t>,
int> = 0>
194 auto operator|(Bordered<Widget_t>& w,
ox::Border const& b)
195 -> Bordered<Widget_t>&
203 typename std::enable_if_t<pipe::detail::is_widget_v<Widget_t>,
int> = 0>
204 auto operator|(std::unique_ptr<Bordered<Widget_t>> w_ptr,
ox::Border const& b)
205 -> std::unique_ptr<Bordered<Widget_t>>
207 w_ptr->set_border(b);
213 typename std::enable_if_t<pipe::detail::is_widget_v<Widget_t>,
int> = 0>
214 auto operator|(Bordered<Widget_t>& w, Background_color bg)
215 -> Bordered<Widget_t>&
217 w.set_border(w.Bordered<Widget_t>::border() | bg);
223 typename std::enable_if_t<pipe::detail::is_widget_v<Widget_t>,
int> = 0>
224 auto operator|(std::unique_ptr<Bordered<Widget_t>> w_ptr, Background_color bg)
225 -> std::unique_ptr<Bordered<Widget_t>>
227 w_ptr->set_border(w_ptr->Bordered<Widget_t>::border() | bg);
233 typename std::enable_if_t<pipe::detail::is_widget_v<Widget_t>,
int> = 0>
234 auto operator|(Bordered<Widget_t>& w, Foreground_color fg)
235 -> Bordered<Widget_t>&
237 w.set_border(w.Bordered<Widget_t>::border() | fg);
243 typename std::enable_if_t<pipe::detail::is_widget_v<Widget_t>,
int> = 0>
244 auto operator|(std::unique_ptr<Bordered<Widget_t>> w_ptr, Foreground_color fg)
245 -> std::unique_ptr<Bordered<Widget_t>>
247 w_ptr->set_border(w_ptr->Bordered<Widget_t>::border() | fg);
248 return std::move(w_ptr);
255 [[nodiscard]]
inline auto drop_north()
257 return [](
auto&& w) -> decltype(
auto) {
258 get(w).set_border(ox::drop_north(get(w).border()));
259 return std::forward<decltype(w)>(w);
263 [[nodiscard]]
inline auto drop_south()
265 return [](
auto&& w) -> decltype(
auto) {
266 get(w).set_border(ox::drop_south(get(w).border()));
267 return std::forward<decltype(w)>(w);
271 [[nodiscard]]
inline auto drop_east()
273 return [](
auto&& w) -> decltype(
auto) {
274 get(w).set_border(ox::drop_east(get(w).border()));
275 return std::forward<decltype(w)>(w);
279 [[nodiscard]]
inline auto drop_west()
281 return [](
auto&& w) -> decltype(
auto) {
282 get(w).set_border(ox::drop_west(get(w).border()));
283 return std::forward<decltype(w)>(w);
287 [[nodiscard]]
inline auto take_north()
289 return [](
auto&& w) -> decltype(
auto) {
290 get(w).set_border(ox::take_north(get(w).border()));
291 return std::forward<decltype(w)>(w);
295 [[nodiscard]]
inline auto take_south()
297 return [](
auto&& w) -> decltype(
auto) {
298 get(w).set_border(ox::take_south(get(w).border()));
299 return std::forward<decltype(w)>(w);
303 [[nodiscard]]
inline auto take_east()
305 return [](
auto&& w) -> decltype(
auto) {
306 get(w).set_border(ox::take_east(get(w).border()));
307 return std::forward<decltype(w)>(w);
311 [[nodiscard]]
inline auto take_west()
313 return [](
auto&& w) -> decltype(
auto) {
314 get(w).set_border(ox::take_west(get(w).border()));
315 return std::forward<decltype(w)>(w);
320 [[nodiscard]]
inline auto discard(Traits ts)
322 return Overload{[ts](Brush& b) -> Brush& {
326 [ts](Brush
const& b) -> Brush {
328 copy.traits.remove(ts);
331 [ts](Brush&& b) -> Brush {
335 [ts](Glyph& g) -> Glyph& {
336 g.brush.traits.remove(ts);
339 [ts](Glyph
const& g) -> Glyph {
341 copy.brush.traits.remove(ts);
344 [ts](Glyph&& g) -> Glyph {
345 g.brush.traits.remove(ts);
348 [ts](Glyph_string& gs) -> Glyph_string& {
349 gs.remove_traits(ts);
352 [ts](Glyph_string
const& gs) -> Glyph_string {
354 copy.remove_traits(ts);
357 [ts](Glyph_string&& gs) -> Glyph_string {
358 gs.remove_traits(ts);
359 return std::move(gs);
361 [ts](
auto&& w) -> decltype(
auto) {
362 get(w).brush.traits.remove(ts);
364 return std::forward<decltype(w)>(w);
368 [[nodiscard]]
inline auto clear_traits()
370 return Overload{[](Brush& b) -> Brush& {
371 b.traits = Trait::None;
374 [](Brush b) -> Brush {
375 b.traits = Trait::None;
378 [](Glyph& g) -> Glyph& {
379 g.brush.traits = Trait::None;
382 [](Glyph
const& g) -> Glyph {
384 copy.brush.traits = Trait::None;
387 [](Glyph&& g) -> Glyph {
388 g.brush.traits = Trait::None;
391 [](Glyph_string& gs) -> Glyph_string& {
395 [](Glyph_string
const& gs) -> Glyph_string {
400 [](Glyph_string&& gs) -> Glyph_string {
402 return std::move(gs);
404 [](
auto&& w) -> decltype(
auto) {
405 get(w).brush.traits = Trait::None;
407 return std::forward<decltype(w)>(w);
412 [[nodiscard]]
inline auto show_cursor()
414 return [](
auto&& w) -> decltype(
auto) {
415 get(w).cursor.enable();
416 return std::forward<decltype(w)>(w);
420 [[nodiscard]]
inline auto hide_cursor()
422 return [](
auto&& w) -> decltype(
auto) {
423 get(w).cursor.disable();
424 return std::forward<decltype(w)>(w);
428 [[nodiscard]]
inline auto put_cursor(Point p)
430 return [=](
auto&& w) -> decltype(
auto) {
431 get(w).cursor.set_position(p);
432 return std::forward<decltype(w)>(w);
437 [[nodiscard]]
inline auto focus(Focus_policy p)
439 return [=](
auto&& w) -> decltype(
auto) {
440 get(w).focus_policy = p;
441 return std::forward<decltype(w)>(w);
445 [[nodiscard]]
inline auto no_focus() {
return focus(Focus_policy::None); }
447 [[nodiscard]]
inline auto tab_focus() {
return focus(Focus_policy::Tab); }
449 [[nodiscard]]
inline auto click_focus() {
return focus(Focus_policy::Click); }
451 [[nodiscard]]
inline auto strong_focus() {
return focus(Focus_policy::Strong); }
453 [[nodiscard]]
inline auto direct_focus() {
return focus(Focus_policy::Direct); }
456 [[nodiscard]]
inline auto forward_focus(Widget& receiver)
458 return [&](
auto&& w) -> decltype(
auto) {
460 return std::forward<decltype(w)>(w);
466 [[nodiscard]]
inline auto fixed_width(
int hint)
468 return [=](
auto&& w) -> decltype(
auto) {
470 return std::forward<decltype(w)>(w);
474 [[nodiscard]]
inline auto minimum_width(
int hint)
476 return [=](
auto&& w) -> decltype(
auto) {
478 return std::forward<decltype(w)>(w);
482 [[nodiscard]]
inline auto maximum_width(
int hint)
484 return [=](
auto&& w) -> decltype(
auto) {
486 return std::forward<decltype(w)>(w);
490 [[nodiscard]]
inline auto preferred_width(
int hint)
492 return [=](
auto&& w) -> decltype(
auto) {
494 return std::forward<decltype(w)>(w);
498 [[nodiscard]]
inline auto expanding_width(
int hint)
500 return [=](
auto&& w) -> decltype(
auto) {
502 return std::forward<decltype(w)>(w);
506 [[nodiscard]]
inline auto minimum_expanding_width(
int hint)
508 return [=](
auto&& w) -> decltype(
auto) {
510 return std::forward<decltype(w)>(w);
514 [[nodiscard]]
inline auto ignored_width()
516 return [](
auto&& w) -> decltype(
auto) {
518 return std::forward<decltype(w)>(w);
522 [[nodiscard]]
inline auto width_hint(
int hint)
524 return [=](
auto&& w) -> decltype(
auto) {
525 get(w).width_policy.hint(hint);
526 return std::forward<decltype(w)>(w);
530 [[nodiscard]]
inline auto width_min(
int min)
532 return [=](
auto&& w) -> decltype(
auto) {
533 get(w).width_policy.min(min);
534 return std::forward<decltype(w)>(w);
538 [[nodiscard]]
inline auto width_max(
int max)
540 return [=](
auto&& w) -> decltype(
auto) {
541 get(w).width_policy.max(max);
542 return std::forward<decltype(w)>(w);
546 [[nodiscard]]
inline auto width_stretch(
double stretch)
548 return [=](
auto&& w) -> decltype(
auto) {
549 get(w).width_policy.stretch(stretch);
550 return std::forward<decltype(w)>(w);
554 [[nodiscard]]
inline auto can_ignore_width_min()
556 return [](
auto&& w) -> decltype(
auto) {
557 get(w).width_policy.can_ignore_min(
true);
558 return std::forward<decltype(w)>(w);
562 [[nodiscard]]
inline auto cannot_ignore_width_min()
564 return [](
auto&& w) -> decltype(
auto) {
565 get(w).width_policy.can_ignore_min(
false);
566 return std::forward<decltype(w)>(w);
572 [[nodiscard]]
inline auto fixed_height(
int hint)
574 return [=](
auto&& w) -> decltype(
auto) {
576 return std::forward<decltype(w)>(w);
580 [[nodiscard]]
inline auto minimum_height(
int hint)
582 return [=](
auto&& w) -> decltype(
auto) {
584 return std::forward<decltype(w)>(w);
588 [[nodiscard]]
inline auto maximum_height(
int hint)
590 return [=](
auto&& w) -> decltype(
auto) {
592 return std::forward<decltype(w)>(w);
596 [[nodiscard]]
inline auto preferred_height(
int hint)
598 return [=](
auto&& w) -> decltype(
auto) {
600 return std::forward<decltype(w)>(w);
604 [[nodiscard]]
inline auto expanding_height(
int hint)
606 return [=](
auto&& w) -> decltype(
auto) {
608 return std::forward<decltype(w)>(w);
612 [[nodiscard]]
inline auto minimum_expanding_height(
int hint)
614 return [=](
auto&& w) -> decltype(
auto) {
616 return std::forward<decltype(w)>(w);
620 [[nodiscard]]
inline auto ignored_height()
622 return [](
auto&& w) -> decltype(
auto) {
624 return std::forward<decltype(w)>(w);
628 [[nodiscard]]
inline auto height_hint(
int hint)
630 return [=](
auto&& w) -> decltype(
auto) {
631 get(w).height_policy.hint(hint);
632 return std::forward<decltype(w)>(w);
636 [[nodiscard]]
inline auto height_min(
int min)
638 return [=](
auto&& w) -> decltype(
auto) {
639 get(w).height_policy.min(min);
640 return std::forward<decltype(w)>(w);
644 [[nodiscard]]
inline auto height_max(
int max)
646 return [=](
auto&& w) -> decltype(
auto) {
647 get(w).height_policy.max(max);
648 return std::forward<decltype(w)>(w);
652 [[nodiscard]]
inline auto height_stretch(
double stretch)
654 return [=](
auto&& w) -> decltype(
auto) {
655 get(w).height_policy.stretch(stretch);
656 return std::forward<decltype(w)>(w);
660 [[nodiscard]]
inline auto can_ignore_height_min()
662 return [](
auto&& w) -> decltype(
auto) {
663 get(w).height_policy.can_ignore_min(
true);
664 return std::forward<decltype(w)>(w);
668 [[nodiscard]]
inline auto cannot_ignore_height_min()
670 return [](
auto&& w) -> decltype(
auto) {
671 get(w).height_policy.can_ignore_min(
false);
672 return std::forward<decltype(w)>(w);
677 template <
typename Handler>
678 [[nodiscard]]
inline auto on_enable(Handler&& op)
680 return [&](
auto&& w) -> decltype(
auto) {
681 get(w).enabled.connect(std::forward<Handler>(op));
682 return std::forward<decltype(w)>(w);
686 template <
typename Handler>
687 [[nodiscard]]
inline auto on_disable(Handler&& op)
689 return [&](
auto&& w) -> decltype(
auto) {
690 get(w).disabled.connect(std::forward<Handler>(op));
691 return std::forward<decltype(w)>(w);
695 template <
typename Handler>
696 [[nodiscard]]
inline auto on_child_added(Handler&& op)
698 return [&](
auto&& w) -> decltype(
auto) {
699 get(w).child_added.connect(std::forward<Handler>(op));
700 return std::forward<decltype(w)>(w);
704 template <
typename Handler>
705 [[nodiscard]]
inline auto on_child_removed(Handler&& op)
707 return [&](
auto&& w) -> decltype(
auto) {
708 get(w).child_removed.connect(std::forward<Handler>(op));
709 return std::forward<decltype(w)>(w);
713 template <
typename Handler>
714 [[nodiscard]]
inline auto on_child_polished(Handler&& op)
716 return [&](
auto&& w) -> decltype(
auto) {
717 get(w).child_polished.connect(std::forward<Handler>(op));
718 return std::forward<decltype(w)>(w);
722 template <
typename Handler>
723 [[nodiscard]]
inline auto on_move(Handler&& op)
725 return [&](
auto&& w) -> decltype(
auto) {
726 get(w).moved.connect(std::forward<Handler>(op));
727 return std::forward<decltype(w)>(w);
731 template <
typename Handler>
732 [[nodiscard]]
inline auto on_resize(Handler&& op)
734 return [&](
auto&& w) -> decltype(
auto) {
735 get(w).resized.connect(std::forward<Handler>(op));
736 return std::forward<decltype(w)>(w);
740 template <
typename Handler>
741 [[nodiscard]]
inline auto on_mouse_press(Handler&& op)
743 return [&](
auto&& w) -> decltype(
auto) {
744 get(w).mouse_pressed.connect(std::forward<Handler>(op));
745 return std::forward<decltype(w)>(w);
749 template <
typename Handler>
750 [[nodiscard]]
inline auto on_left_click(Handler&& op)
752 return [=](
auto&& w) -> decltype(
auto) {
753 get(w).mouse_pressed.connect([op](
auto const& m) {
754 if (m.button == Mouse::Button::Left)
757 return std::forward<decltype(w)>(w);
761 template <
typename Handler>
762 [[nodiscard]]
inline auto on_middle_click(Handler&& op)
764 return [=](
auto&& w) -> decltype(
auto) {
765 get(w).mouse_pressed.connect([op](
auto const& m) {
766 if (m.button == Mouse::Button::Middle)
769 return std::forward<decltype(w)>(w);
773 template <
typename Handler>
774 [[nodiscard]]
inline auto on_right_click(Handler&& op)
776 return [=](
auto&& w) -> decltype(
auto) {
777 get(w).mouse_pressed.connect([op](
auto const& m) {
778 if (m.button == Mouse::Button::Right)
781 return std::forward<decltype(w)>(w);
785 template <
typename Handler>
786 [[nodiscard]]
inline auto on_mouse_release(Handler&& op)
788 return [&](
auto&& w) -> decltype(
auto) {
789 get(w).mouse_released.connect(std::forward<Handler>(op));
790 return std::forward<decltype(w)>(w);
794 template <
typename Handler>
795 [[nodiscard]]
inline auto on_mouse_double_click(Handler&& op)
797 return [&](
auto&& w) -> decltype(
auto) {
798 get(w).mouse_double_clicked.connect(std::forward<Handler>(op));
799 return std::forward<decltype(w)>(w);
803 template <
typename Handler>
804 [[nodiscard]]
inline auto on_mouse_move(Handler&& op)
806 return [&](
auto&& w) -> decltype(
auto) {
807 get(w).mouse_moved.connect(std::forward<Handler>(op));
808 return std::forward<decltype(w)>(w);
812 template <
typename Handler>
813 [[nodiscard]]
inline auto on_key_press(Handler&& op)
815 return [&](
auto&& w) -> decltype(
auto) {
816 get(w).key_pressed.connect(std::forward<Handler>(op));
817 return std::forward<decltype(w)>(w);
821 template <
typename Handler>
822 [[nodiscard]]
inline auto bind_key(Key k, Handler&& op)
824 return [op = std::forward<Handler>(op), k](
auto&& w) -> decltype(
auto) {
825 get(w).key_pressed.connect([&w, &op, k](
auto pressed) {
829 return std::forward<decltype(w)>(w);
833 template <
typename Handler>
834 [[nodiscard]]
inline auto on_focus_in(Handler&& op)
836 return [&](
auto&& w) -> decltype(
auto) {
837 get(w).focused_in.connect(std::forward<Handler>(op));
838 return std::forward<decltype(w)>(w);
842 template <
typename Handler>
843 [[nodiscard]]
inline auto on_focus_out(Handler&& op)
845 return [&](
auto&& w) -> decltype(
auto) {
846 get(w).focused_out.connect(std::forward<Handler>(op));
847 return std::forward<decltype(w)>(w);
851 template <
typename Handler>
852 [[nodiscard]]
inline auto on_paint(Handler&& op)
854 return [&](
auto&& w) -> decltype(
auto) {
855 get(w).painted.connect(std::forward<Handler>(op));
856 return std::forward<decltype(w)>(w);
860 template <
typename Handler>
861 [[nodiscard]]
inline auto on_timer(Handler&& op)
863 return [&](
auto&& w) -> decltype(
auto) {
864 get(w).timer.connect(std::forward<Handler>(op));
865 return std::forward<decltype(w)>(w);
869 template <
typename Handler>
870 [[nodiscard]]
inline auto on_deleted(Handler&& op)
872 return [&](
auto&& w) -> decltype(
auto) {
873 get(w).deleted.connect(std::forward<Handler>(op));
874 return std::forward<decltype(w)>(w);
879 template <
typename Handler>
880 [[nodiscard]]
inline auto on_color_selected(Handler&& op)
882 return [&](
auto&& w) -> decltype(
auto) {
883 get(w).color_selected.connect(std::forward<Handler>(op));
884 return std::forward<decltype(w)>(w);
888 template <
typename Handler>
889 [[nodiscard]]
inline auto on_press(Handler&& op)
891 return [&](
auto&& w) -> decltype(
auto) {
892 get(w).pressed.connect(std::forward<Handler>(op));
893 return std::forward<decltype(w)>(w);
897 template <
typename Handler>
898 [[nodiscard]]
inline auto on_check(Handler&& op)
900 return [&](
auto&& w) -> decltype(
auto) {
901 get(w).checked.connect(std::forward<Handler>(op));
902 return std::forward<decltype(w)>(w);
906 template <
typename Handler>
907 [[nodiscard]]
inline auto on_uncheck(Handler&& op)
909 return [&](
auto&& w) -> decltype(
auto) {
910 get(w).unchecked.connect(std::forward<Handler>(op));
911 return std::forward<decltype(w)>(w);
915 template <
typename Handler>
916 [[nodiscard]]
inline auto on_toggle(Handler&& op)
918 return [&](
auto&& w) -> decltype(
auto) {
919 get(w).toggled.connect(std::forward<Handler>(op));
920 return std::forward<decltype(w)>(w);
925 [[nodiscard]]
inline auto active_page(std::size_t p)
927 return [=](
auto&& w) -> decltype(
auto) {
928 get(w).set_active_page(p);
929 return std::forward<decltype(w)>(w);
933 [[nodiscard]]
inline auto label(Glyph_string
const& x)
935 return [=](
auto&& w) -> decltype(
auto) {
937 return std::forward<decltype(w)>(w);
941 [[nodiscard]]
inline auto wrapped()
943 return [](
auto&& w) ->
auto& {
return get(w).wrapped; };
947 [[nodiscard]]
inline auto divider(Glyph x)
949 return [=](
auto&& w) -> decltype(
auto) {
950 get(w).set_divider(x);
951 return std::forward<decltype(w)>(w);
955 [[nodiscard]]
inline auto any_wrap()
957 return [=](
auto&& w) -> decltype(
auto) {
958 get(w).set_wrap(Wrap::Any);
959 return std::forward<decltype(w)>(w);
963 [[nodiscard]]
inline auto word_wrap()
965 return [=](
auto&& w) -> decltype(
auto) {
966 get(w).set_wrap(Wrap::Word);
967 return std::forward<decltype(w)>(w);
971 [[nodiscard]]
inline auto text(Glyph_string x)
973 return [=](
auto&& w) -> decltype(
auto) {
975 return std::forward<decltype(w)>(w);
979 template <
typename Number_t>
980 [[nodiscard]]
inline auto value(Number_t x)
982 return [=](
auto&& w) -> decltype(
auto) {
984 return std::forward<decltype(w)>(w);
988 [[nodiscard]]
inline auto align_left()
990 return [=](
auto&& w) -> decltype(
auto) {
991 get(w).set_alignment(Align::Left);
992 return std::forward<decltype(w)>(w);
996 [[nodiscard]]
inline auto align_center()
998 return [=](
auto&& w) -> decltype(
auto) {
999 get(w).set_alignment(Align::Center);
1000 return std::forward<decltype(w)>(w);
1004 [[nodiscard]]
inline auto align_right()
1006 return [=](
auto&& w) -> decltype(
auto) {
1007 get(w).set_alignment(Align::Right);
1008 return std::forward<decltype(w)>(w);
1013 [[nodiscard]]
inline auto dynamic_growth()
1015 return [=](
auto&& w) -> decltype(
auto) {
1016 get(w).set_growth_strategy(Growth::Dynamic);
1017 return std::forward<decltype(w)>(w);
1021 [[nodiscard]]
inline auto no_growth()
1023 return [=](
auto&& w) -> decltype(
auto) {
1024 get(w).set_growth_strategy(Growth::Static);
1025 return std::forward<decltype(w)>(w);
1037 typename = std::enable_if_t<pipe::detail::is_widget_or_wptr<Widget_t>,
int>>
1038 auto operator|(Widget_t&& w, F&& op) -> std::invoke_result_t<F, Widget_t&&>
1040 return std::forward<F>(op)(std::forward<Widget_t>(w));
1044 template <
typename Iter_1,
typename Iter_2,
typename F>
1045 auto operator|(Range<Iter_1, Iter_2> children, F&& op) -> Range<Iter_1, Iter_2>
1047 for (
auto& child : children)
1053 template <
typename Iter_1,
typename Iter_2,
typename F>
1054 auto operator|(Range<Iter_1, Iter_2> children,
1055 pipe::detail::Filter_predicate<F>&& p)
1057 return Range{Filter_iterator{children.begin(), children.end(),
1058 std::forward<F>(p.predicate)},
1063 template <
typename Iter_1,
typename Iter_2,
typename W
idget_t>
1064 auto operator|(Range<Iter_1, Iter_2> children,
1065 pipe::detail::Dynamic_filter_predicate<Widget_t>)
1071 Filter_iterator{ children.begin(), children.end(),
1072 [](
auto& w) {
return dynamic_cast<Widget_t*
>(&w) !=
nullptr; }},
1073 [](
auto& w) ->
auto& {
return static_cast<Widget_t&
>(w); }
1079 template <
typename F>
1080 auto operator|(std::vector<Widget*>
const& descendants, F&& op)
1081 -> std::vector<Widget*>
const&
1083 for (
auto* d : descendants)
1089 template <
typename F>
1090 auto operator|(Glyph_string& gs, F&& op)
1091 -> std::invoke_result_t<F, Glyph_string&>
1093 return std::forward<F>(op)(gs);
1097 template <
typename F>
1098 auto operator|(Glyph_string
const& gs, F&& op)
1099 -> std::invoke_result_t<F, Glyph_string const&>
1101 return std::forward<F>(op)(gs);
1105 template <
typename F>
1106 auto operator|(Glyph_string&& gs, F&& op)
1107 -> std::invoke_result_t<F, Glyph_string&&>
1109 return std::forward<F>(op)(std::move(gs));
1113 template <
typename F>
1114 auto operator|(Glyph& g, F&& op) -> std::invoke_result_t<F, Glyph&>
1116 return std::forward<F>(op)(g);
1120 template <
typename F>
1121 auto operator|(Glyph
const& g, F&& op) -> std::invoke_result_t<F, Glyph const&>
1123 return std::forward<F>(op)(g);
1127 template <
typename F>
1128 auto operator|(Glyph&& g, F&& op) -> std::invoke_result_t<F, Glyph&&>
1130 return std::forward<F>(op)(std::move(g));
1134 template <
typename F>
1135 auto operator|(Brush& b, F&& op) -> std::invoke_result_t<F, Brush&>
1137 return std::forward<F>(op)(b);
1141 template <
typename F>
1142 auto operator|(Brush
const& b, F&& op) -> std::invoke_result_t<F, Brush const&>
1144 return std::forward<F>(op)(b);
1148 template <
typename F>
1149 auto operator|(Brush&& b, F&& op) -> std::invoke_result_t<F, Brush&&>
1151 return std::forward<F>(op)(std::move(b));
static auto ignored() -> Size_policy
Ignored: Stretch is the only consideration.
Definition: size_policy.cpp:91
static auto fixed(int hint) -> Size_policy
Fixed: hint is the only acceptable size.
Definition: size_policy.cpp:55
static auto minimum(int hint) -> Size_policy
Minimum: hint is the minimum acceptable size, may be larger.
Definition: size_policy.cpp:61
static auto minimum_expanding(int hint) -> Size_policy
Minimum Expanding: hint is minimum, it will expand into unused space.
Definition: size_policy.cpp:85
static auto maximum(int hint) -> Size_policy
Maximum: hint is the maximum acceptable size, may be smaller.
Definition: size_policy.cpp:67
static auto preferred(int hint) -> Size_policy
Preferred: hint is preferred, though it can be any size.
Definition: size_policy.cpp:73
static auto expanding(int hint) -> Size_policy
Expanding: hint is preferred, but it will expand to use extra space.
Definition: size_policy.cpp:79
static void set_focus(Widget &w)
Give program focus to w.
Definition: system.cpp:39
Defines which border walls are enabled and how they are displayed.
Definition: bordered.hpp:21