From fb4d9be2b405d3a4fda9b16bbd90475984ac175d Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Thu, 4 Oct 2018 04:06:30 +0200 Subject: [PATCH] draft generic decorator to make a widget flash not finished, having problems with Lumiera's stylesheet --- src/gui/model/expander-revealer.hpp | 2 +- src/gui/model/flash-deco.hpp | 93 +++++++++++++ src/gui/style-scheme.cpp | 44 ++++++ src/gui/style-scheme.hpp | 58 ++++++++ src/gui/widget/error-log-display.hpp | 5 +- wiki/thinkPad.ichthyo.mm | 195 ++++++++++++++++++++++++--- 6 files changed, 371 insertions(+), 26 deletions(-) create mode 100644 src/gui/model/flash-deco.hpp create mode 100644 src/gui/style-scheme.cpp create mode 100644 src/gui/style-scheme.hpp diff --git a/src/gui/model/expander-revealer.hpp b/src/gui/model/expander-revealer.hpp index bdf91bba0..41c5db905 100644 --- a/src/gui/model/expander-revealer.hpp +++ b/src/gui/model/expander-revealer.hpp @@ -35,7 +35,7 @@ ** ## Usage in the default implementation ** ** The base class of all [tangible UI elements](\ref Tangible) provides a default implementation - ** for these generic interaction mechanism: It offers slots to connect UI signals against, and + ** for these generic interaction mechanisms: It offers slots to connect UI signals against, and ** it understands the \em `mark` messages `"expand"` and `"revealYourself"`. These are implemented ** by delegating to the \ref Expander and \ref Revealer functors respectively. Moreover, this ** default implementation automatically detects a resulting state change and emits an appropriate diff --git a/src/gui/model/flash-deco.hpp b/src/gui/model/flash-deco.hpp new file mode 100644 index 000000000..fd86071d5 --- /dev/null +++ b/src/gui/model/flash-deco.hpp @@ -0,0 +1,93 @@ +/* + FLASH-DECO.hpp - widget decorator to add a visual flash action + + Copyright (C) Lumiera.org + 2018, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + + +/** @file flash-deco.hpp + ** Decorator to add the ability to display a visual flash action to a GTK widget. + ** The protocol for operating UI elements connected to the [UI-Bus](\ref ui-bus.hpp) includes + ** a message to make the receiving widget flash for a short time, to mandate the users attention. + ** The visual change itself is effected by adding a CSS class, while adding a timeout callback + ** to revert to normal display after a short timespan. In itself, this modification sequence + ** is entirely generic, and can thus be added by decorating the widget to affect; moreover, + ** adding such a callback need to be done properly, to avoid a crash in case the widget + ** is destroyed during the timeout period. + ** + ** @see [UI-Element protocol](\ref tangible.hpp) + ** @see [usage example](\ref error-log-display.hpp) + ** + */ + + +#ifndef GUI_MODEL_FLASH_DECO_H +#define GUI_MODEL_FLASH_DECO_H + + +#include "gui/gtk-base.hpp" +#include "gui/style-scheme.hpp" + +//#include + + +namespace gui { +namespace model { + +// using std::move; + + + /** + * Decorator for a Gtk::Widget to add a visual flash action. + * @tparam WIT type of the target widget to decorate. All ctors are passed through. + * @remark invoke the #flash function to trigger + */ + template + class FlashDeco + { + static_assert (std::is_base_of() + ,"wrapped target type required to be a Gtk::Widget"); + public: + using WIT::WIT; + + void + flash() + { + auto styleContext = this->get_style_context(); + styleContext->add_class (CSS_CLASS_FLASH); + + Glib::signal_timeout() + .connect_once (sigc::mem_fun(*this, &FlashDeco::flashback) + ,STYLE_FLASH_DURATION_in_ms + ,Glib::PRIORITY_LOW); // after all pending drawing tasks + } + + private: + void + flashback() + { + auto styleContext = this->get_style_context(); + styleContext->remove_class (CSS_CLASS_FLASH); + } + }; + + + +}} // namespace gui::model +#endif /*GUI_MODEL_FLASH_DECO_H*/ diff --git a/src/gui/style-scheme.cpp b/src/gui/style-scheme.cpp new file mode 100644 index 000000000..3809ab0cd --- /dev/null +++ b/src/gui/style-scheme.cpp @@ -0,0 +1,44 @@ +/* + StyleScheme - magic keys to access uniform styling scheme + + Copyright (C) Lumiera.org + 2018, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +* *****************************************************/ + + +/** @file style-scheme.hpp + ** Definition of access keys for uniform UI styling. + ** + ** @see gui::workspace::UiStyle + ** + */ + +#include "gui/gtk-base.hpp" +#include "gui/style-scheme.hpp" + +namespace gui { + + const Literal TAG_ERROR{"ERROR"}; ////////////////////////////////////////////////////////////TICKET #1168 : find a way to manage style of custom extended UI elements + const Literal TAG_WARN{"WARN"}; + + cuString CSS_CLASS_FLASH{"indication_flash"}; + const uint STYLE_FLASH_DURATION_in_ms = 1100; + + + +}// namespace gui diff --git a/src/gui/style-scheme.hpp b/src/gui/style-scheme.hpp new file mode 100644 index 000000000..383ae8987 --- /dev/null +++ b/src/gui/style-scheme.hpp @@ -0,0 +1,58 @@ +/* + STYLE_SCHEME.hpp - magic keys to access uniform styling scheme + + Copyright (C) Lumiera.org + 2018, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + + +/** @file style-scheme.hpp + ** Hard wired key constants to access a global uniform styling scheme. + ** + ** @todo as or 10/2018 this is mere placeholder code. The StyleManager needs rework + ** + ** @see ui-style.hpp + ** + */ + +#ifndef GUI_STYLE_SCHEME_H +#define GUI_STYLE_SCHEME_H + + +#include "lib/symbol.hpp" + + +namespace Glib { + class ustring; +} +namespace gui { + + using lib::Literal; + using cuString = const Glib::ustring; + + + extern const Literal TAG_ERROR; ////////////////////////////////////////////////////////TICKET #1168 : find a way to manage style of custom extended UI elements + extern const Literal TAG_WARN; + + extern cuString CSS_CLASS_FLASH; + extern const uint STYLE_FLASH_DURATION_in_ms; + + + +}// namespace gui +#endif /*GUI_STYLE_SCHEME_H*/ diff --git a/src/gui/widget/error-log-display.hpp b/src/gui/widget/error-log-display.hpp index 3f5d316b1..44e75ed23 100644 --- a/src/gui/widget/error-log-display.hpp +++ b/src/gui/widget/error-log-display.hpp @@ -60,6 +60,7 @@ #define GUI_WIDGET_ERROR_LOG_DISPLAY_H #include "gui/gtk-base.hpp" +#include "gui/style-scheme.hpp" #include "gui/model/expander-revealer.hpp" #include "include/gui-notification-facade.h" #include "lib/format-string.hpp" @@ -83,10 +84,6 @@ namespace widget { namespace { - const Literal TAG_ERROR{"ERROR"}; /////////////////////////////////////////////////////////////TICKET #1168 : find a way to manage style of custom extended UI elements - const Literal TAG_WARN{"WARN"}; - - using Tag = Glib::RefPtr; /** diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index f582a7386..ea598d09e 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -2095,12 +2095,21 @@ - + + + + + + + + + + @@ -2257,13 +2266,105 @@ - + + + + + + + + + +

+ ca 2014 finde ich einige Blog-Einträge, daß jetzt keine Theming-Engine mehr notwendig ist, +

+

+ weil man alles per CSS machen kann. Seit Jessie findet GTK die Engine nicht mehr, +

+

+ obwohl das Standard-Theme-Paket installiert ist. +

+

+ +

+

+ Dummerweise funktioniert nun aber auch das Übersteuern mit unseren Farben nicht mehr +

+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ denn dieses Design gibt die beste Balance zwischen den Belangen +

+
    +
  • + kein zusätzlicher Speicherbedarf +
  • +
  • + Callback ist automatisch abgesichert (sigc::mem_fun auf Trackable) +
  • +
  • + kann direkt auf das Styling des Parent zugreifen +
  • +
+

+ Einziger Nachteil ist die etwas verwirrende Schreibweise des dekorierten Typs +

+ + +
+
+ +
@@ -5189,6 +5290,9 @@ + + +
@@ -5338,6 +5442,40 @@ + + + + + + +

+ wenn die GTK-Loop angehalten wird, +

+

+ dann koppelt sich GTK anscheinend auch +

+

+ automatisch vom Window-Manager ab. +

+

+ +

+

+ Jedenfalls habe ich nun schon mehrfach den Shutdown "von unten" getriggert, +

+

+ und es wurden alle Fenster geschlossen. +

+

+ +

+

+ Allerdings habe ich an der Stelle immer noch GTK-Assertions +

+ + +
+
@@ -6366,7 +6504,7 @@ - + @@ -18612,7 +18750,7 @@ - + @@ -18829,7 +18967,7 @@ - + @@ -19004,7 +19142,7 @@ - + @@ -19019,7 +19157,7 @@ - + @@ -19051,7 +19189,7 @@ - + @@ -19104,7 +19242,7 @@ - + @@ -19119,7 +19257,7 @@ - + @@ -26017,7 +26155,7 @@ - + @@ -38031,13 +38169,28 @@ - - - - + + + + + + +

+ Glib::RefPtr<StyleContext> context = widget->get_style_context(); +

+

+ context->add_class("ohMy"); +

+ + +
+ + + - - + + + @@ -38071,8 +38224,8 @@ - - + +
@@ -38185,7 +38338,7 @@ - + @@ -38204,7 +38357,7 @@ - +