Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
view-hook.hpp
Go to the documentation of this file.
1/*
2 VIEW-HOOK.hpp - abstracted attachment to a canvas or display facility
3
4 Copyright (C)
5 2019, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
14
50#ifndef STAGE_MODEL_VIEW_HOOK_H
51#define STAGE_MODEL_VIEW_HOOK_H
52
53#include "lib/nocopy.hpp"
54#include "lib/util.hpp"
55
56#include <utility>
57
58
59namespace stage {
60namespace model {
61
62
74 template<class WID>
76 {
77 public:
78 virtual ~ViewHook() { }
79
80 virtual void hook (WID& widget) =0;
81 virtual void remove (WID& widget) =0;
82 virtual void rehook (WID& widget) noexcept =0;
83
84 template<class IT>
85 void reOrder (IT newOrder);
86 };
87
88
89
113 template<class WID, class BASE =WID>
115 : public WID
117 {
120
121 public:
122 template<typename...ARGS>
123 ViewHooked (View& view, ARGS&& ...args)
124 : WID{std::forward<ARGS>(args)...}
125 , view_{&view}
126 {
127 view_->hook (*this);
128 }
129
130 ~ViewHooked() noexcept
131 {
132 try {
133 if (view_)
134 view_->remove (*this);
135 }
136 ERROR_LOG_AND_IGNORE (progress, "Detaching of ViewHooked widgets from the presentation")
137 }
138 };
139
140
141
155 template<class WID>
156 template<class IT>
157 void
159 {
160 for (WID& existingHook : newOrder)
161 this->rehook (existingHook);
162 }
163
164
165
166}}// namespace stage::model
167#endif /*STAGE_MODEL_VIEW_HOOK_H*/
Interface to represent _"some presentation layout entity",_ with the ability to attach widgets (manag...
Definition view-hook.hpp:76
virtual void hook(WID &widget)=0
virtual ~ViewHook()
this is an interface
Definition view-hook.hpp:78
void reOrder(IT newOrder)
re-attach elements in a given, new order.
virtual void remove(WID &widget)=0
virtual void rehook(WID &widget) noexcept=0
A widget attached onto a display canvas or similar central presentation context.
ViewHook< BASE > View
ViewHooked(View &view, ARGS &&...args)
Any copy and copy construction prohibited.
Definition nocopy.hpp:38
#define ERROR_LOG_AND_IGNORE(_FLAG_, _OP_DESCR_)
convenience shortcut for a sequence of catch blocks just logging and consuming an error.
Definition error.hpp:267
Lumiera GTK UI implementation root.
Definition guifacade.cpp:37
STL namespace.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...