Lumiera  0.pre.03
»edit your freedom«
flash-deco.hpp
Go to the documentation of this file.
1 /*
2  FLASH-DECO.hpp - widget decorator to add a visual flash action
3 
4  Copyright (C) Lumiera.org
5  2018, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the 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 General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
23 
40 #ifndef STAGE_MODEL_FLASH_DECO_H
41 #define STAGE_MODEL_FLASH_DECO_H
42 
43 
44 #include "stage/gtk-base.hpp"
45 #include "stage/style-scheme.hpp"
46 
47 
48 namespace stage {
49 namespace model {
50 
51 
58  template<class WIT>
59  class FlashDeco
60  : public WIT
61  {
62  static_assert (std::is_base_of<Gtk::Widget, WIT>()
63  ,"wrapped target type required to be a Gtk::Widget");
64  public:
65  using WIT::WIT;
66 
67  void
68  flash()
69  {
70  auto styleContext = this->get_style_context();
71  styleContext->add_class (CLASS_indication_flash);
72 
73  Glib::signal_timeout()
74  .connect_once (sigc::mem_fun(*this, &FlashDeco::flashback)
75  ,STYLE_FLASH_DURATION_in_ms
76  ,Glib::PRIORITY_LOW); // after all pending drawing tasks
77  }
78 
79  private:
80  void
81  flashback()
82  {
83  auto styleContext = this->get_style_context();
84  styleContext->remove_class (CLASS_indication_flash);
85  }
86  };
87 
88 
89 }} // namespace stage::model
90 #endif /*STAGE_MODEL_FLASH_DECO_H*/
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:46
cuString CLASS_indication_flash
CSS class added temporarily to make a widget "flash" in response to the corresponding UI-Bus message...
Definition of access keys for uniform UI styling.
A set of basic GTK includes for the UI.
Decorator for a Gtk::Widget to add a visual flash action.
Definition: flash-deco.hpp:59