Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Locked.h
Go to the documentation of this file.
1 /* Copyright (c) 2014-2016 "Omnidome" by cr8tr
2  * Dome Mapping Projection Software (http://omnido.me).
3  * Omnidome was created by Michael Winkelmann aka Wilston Oreo (@WilstonOreo)
4  *
5  * This file is part of Omnidome.
6  *
7  * Omnidome is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Affero General Public License for more details.
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef OMNI_UI_MIXIN_LOCKED_H_
20 #define OMNI_UI_MIXIN_LOCKED_H_
21 
22 namespace omni {
23  namespace ui {
24  namespace mixin {
25  /// Mixin with a function to lock the widget temporarily
26  class Locked {
27  public:
28  /// Lock widget and execute given functor
29  template<typename F>
30  inline void locked(F f)
31  {
32  bool _oldLocked = locked_;
33 
34  locked_ = true;
35  f();
36  locked_ = _oldLocked;
37  }
38 
39  /// Return true if widget is locked
40  inline bool isLocked() const
41  {
42  return locked_;
43  }
44 
45  private:
46  /// Flag which sets if widgets are currently locked
47  bool locked_ = false;
48  };
49  }
50  }
51 }
52 
53 #endif /* OMNI_UI_MIXIN_LOCKED_H_ */
Mixin with a function to lock the widget temporarily.
Definition: Locked.h:26
void locked(F f)
Lock widget and execute given functor.
Definition: Locked.h:30
bool locked_
Flag which sets if widgets are currently locked.
Definition: Locked.h:47
bool isLocked() const
Return true if widget is locked.
Definition: Locked.h:40