From 77980ef024fd3363237e6934fd5bbf0f0adcc8ae Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 26 Sep 2018 16:55:42 +0200 Subject: [PATCH] TestControl: the first tangible UI feedback caused via UI-Bus (see #1099) wrap up the helpers and wire the connection to the UI-Bus. Then attempt a direct invocation, still within the GTK thread. While this might seem as just some silly experiment, in fact it is *** THE FUCKING FIRST TIME to transmit a visible action to a real widget *** this links together and integrates various efforts achieved during the last years --- src/gui/dialog/test-control.hpp | 87 ++++++++++++++++++++++------ src/gui/widget/error-log-display.hpp | 1 + wiki/thinkPad.ichthyo.mm | 14 ++++- 3 files changed, 81 insertions(+), 21 deletions(-) diff --git a/src/gui/dialog/test-control.hpp b/src/gui/dialog/test-control.hpp index ad99a4224..1e46a12c4 100644 --- a/src/gui/dialog/test-control.hpp +++ b/src/gui/dialog/test-control.hpp @@ -30,6 +30,8 @@ ** perform within the same environment as regular user interactions. ** ** @todo as of 9/2018, this is a first rough draft, relevant for #1099 ////////////////////////////TICKET #1074 gradually augment the self-diagnostics controls in the UI + ** @todo this header also features a design draft how to simplify building notebook widgets. + ** Which could be polished and moved into a separate utility header eventually. */ @@ -41,16 +43,35 @@ #include "gui/dialog/dialog.hpp" #include "gui/ctrl/bus-term.hpp" #include "lib/scoped-ptrvect.hpp" -//#include "lib/meta/function.hpp" +#include "lib/diff/gen-node.hpp" #include "lib/nocopy.hpp" #include +#if true /////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1099 : WIP-WIP-WIP +namespace proc { + namespace asset { + namespace meta { + class ErrorLog; + + extern lib::idi::EntryID theErrorLog_ID; +} } } +#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1099 : WIP-WIP-WIP namespace gui { namespace dialog { using std::forward; + using lib::diff::GenNode; + + /** + * Building block for a segment within a dialog page. + * This helper widget provides the typical sub section of a dialog + * with several child widgets stacked vertically and enclosed within + * a frame with a label. The frame serves as the parent widget, as far + * as the widget hierarchy is concerned. Both parts are publicly accessible + * as members, while providing a shortcut for publishing the box. + */ struct FrameVBox { Gtk::Frame frame; @@ -72,6 +93,7 @@ namespace dialog { } }; + /** explicitly named shortcut for the typical dialog page content holder */ class Page : public Gtk::Box , util::NonCopyable @@ -80,10 +102,29 @@ namespace dialog { Page() : Gtk::Box{Gtk::ORIENTATION_VERTICAL} { } - - virtual ~Page() { } }; + /** + * Helper widget to simplify construction and wiring of a [Notebook] widget. + * Gtk::Notebook is quite powerful container foundation to build complex dialog widgets with + * multiple pages on tabs. However, the construction, wiring an setup is notoriously tedious, + * due to the repetitiveness and the sheer amount of child widgets spread over various pages. + * + * This design draft is an attempt to mitigate the required boilerplate, without overly much + * obscuring the structure. The basic idea is to package each page into a locally defined child + * struct, which is actually heap allocated and managed automatically. This way, each child page + * gets its own namespace, and wiring to other components is made explicit by passing named ctor + * arguments -- while the overall structure of building and wiring of widgets stays close to the + * habits of [programming with GTKmm](https://developer.gnome.org/gtkmm-tutorial/stable/). + * - define the pages as custom widgets, typically just as locally known struct types + * - invoke #buildPage passing the type and tab label for each page + * - define the wiring of the components within a page in the page's ctor + * - possibly pass external dependencies for wiring into that ctor + * @note the page widgets are actually heap allocated and managed automatically + * @see gui::dialog::TestControl as a usage example + * + * [Notebook]: https://developer.gnome.org/gtkmm-tutorial/stable/sec-multi-item-containers.html.en#sec-notebook + */ class Notebook : public Gtk::Notebook , lib::ScopedPtrVect @@ -99,14 +140,30 @@ namespace dialog { } }; + + /** + * A complex, tabbed-notebook style non-modal dialog window, + * dedicated to development, diagnostics and experimentation. + * The TestControl can be launched from Lumiera's "Help" menu, + * offers an (passive, up-link) [UI-Bus connection](\ref ui-bus.hpp) + * and simplifies adding pages for occasional experiments and diagnostics. + */ class TestControl : public Gtk::Dialog - , ctrl::BusTerm { using Bus = ctrl::BusTerm&; - Bus busTerm() { return *this; } + + Bus uiBus_; + Notebook notebook_; + /** + * Ticket #1099 : perform a dummy round-trip to verify Proc-GUI integration. + * This routine invokes the command 'xxx' down in Proc-Layer, passing the settings + * from the radio buttons to select the flavour of feedback, and the text for feedback content. + * The expected behaviour is for the invoked command to send a feedback via UI-Bus towards + * the ErrorLogDisplay within the InfoboxPanel. + */ struct Page1 : Page { FrameVBox seg_1_{_("log notification")}, @@ -119,41 +176,35 @@ namespace dialog { trigger_1_.set_use_underline(); trigger_1_.set_tooltip_markup (_("Ticket #1099:\ntrigger Proc-GUI roundtrip")); trigger_1_.signal_clicked().connect( - mem_fun(*this, &Page1::demoGuiRoundtrip)); + [&]{ demoGuiRoundtrip(bus); }); seg_1_.pack_start (trigger_1_, Gtk::PACK_SHRINK); pack_start (seg_1_); pack_start (seg_2_); } - /** - * Ticket #1099 : perform a dummy round-trip to verify Proc-GUI integration. - * This routine invokes the command 'xxx' down in Proc-Layer, passing the settings - * from the radio buttons to select the flavour of feedback, and the text for feedback content. - * The expected behaviour is for the invoked command to send a feedback via UI-Bus towards - * the ErrorLogDisplay within the InfoboxPanel. - */ void - demoGuiRoundtrip() + demoGuiRoundtrip (Bus bus) { - UNIMPLEMENTED ("collect command arguments and then send the command message for #1099"); + TODO ("collect command arguments and then send the command message for #1099"); + ID errorLogID = proc::asset::meta::theErrorLog_ID; + bus.mark (errorLogID, GenNode{"Message", "Lalü"}); } }; - Notebook notebook_; public: TestControl (ctrl::BusTerm& upLink, Gtk::Window& parent) : Dialog(_("Test and Diagnostics"), parent, Gtk::DIALOG_DESTROY_WITH_PARENT) - , ctrl::BusTerm{lib::idi::EntryID{}, upLink} + , uiBus_{upLink} { // Setup the overall dialog layout set_border_width (BorderPadding); get_content_area()->pack_start (notebook_); // construct and wire the pages... - notebook_.buildPage (_("#1099"), busTerm()); + notebook_.buildPage (_("#1099"), uiBus_); show_all(); } diff --git a/src/gui/widget/error-log-display.hpp b/src/gui/widget/error-log-display.hpp index 51c83665f..aba28a069 100644 --- a/src/gui/widget/error-log-display.hpp +++ b/src/gui/widget/error-log-display.hpp @@ -212,6 +212,7 @@ namespace widget { buff->insert_with_tag(buff->end(), text, cuString{markupTagName}); else buff->insert (buff->end(), text); + buff->insert (buff->end(), "\n"); textLog_.scroll_to (cursor); return cursor; } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index c1ca05fbe..194005921 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -2771,8 +2771,8 @@ - - + + @@ -2786,6 +2786,13 @@ + + + + + + + @@ -4252,7 +4259,8 @@ - + +