13
0

continued work on use of Metadata in various Configuration objects (GUI edition)

This commit is contained in:
Paul Davis 2023-01-27 12:07:45 -07:00
parent 3c1c6e7b68
commit 26c09e6de3
5 changed files with 460 additions and 35 deletions

View File

@ -27,6 +27,8 @@
#include <ctype.h>
#include <algorithm>
#include <boost/tokenizer.hpp>
#include <gtkmm/box.h>
#include <gtkmm/alignment.h>
#include "gtkmm2ext/utils.h"
@ -39,7 +41,6 @@
#include "ardour/utils.h"
#include "pbd/configuration.h"
#include "pbd/match.h"
#include "pbd/replace_all.h"
#include "pbd/strsplit.h"
@ -133,26 +134,16 @@ OptionEditorComponent::end_highlight ()
}
}
std::string
PBD::Configuration::Metadata const *
OptionEditorComponent::get_metadata () const
{
if (!_metadata.empty()) {
return _metadata;
}
gchar* tt = gtk_widget_get_tooltip_text (const_cast<OptionEditorComponent*>(this)->tip_widget().gobj());
if (tt) {
return tt;
}
return string();
return _metadata;
}
void
OptionEditorComponent::set_metadata (std::string const & str)
OptionEditorComponent::set_metadata (PBD::Configuration::Metadata const & m)
{
_metadata = str;
_metadata = &m;
}
/*--------------------------*/
@ -902,6 +893,16 @@ OptionEditor::search ()
if (!search_results || search_for != last_search_string) {
boost::char_separator<char> sep (" ");
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
tokenizer t (search_for, sep);
for (tokenizer::iterator ti = t.begin (); ti != t.end (); ++ti) {
string word = *ti;
transform (word.begin (), word.end (), word.begin (), ::toupper);
search_targets.push_back (word);
}
/* (re)build search results */
delete search_results;
@ -909,12 +910,25 @@ OptionEditor::search ()
for (auto p : pages()) {
for (auto oc : p.second->components) {
string metadata (oc->get_metadata());
PBD::Configuration::Metadata const * metadata (oc->get_metadata());
transform (search_for.begin (), search_for.end (), search_for.begin (), ::toupper);
transform (metadata.begin (), metadata.end (), metadata.begin (), ::toupper);
if (!metadata) {
continue;
}
if (PBD::match_search_strings (metadata, search_for)) {
std::vector<SearchResult>::size_type found_cnt = 0;
for (auto const & s : search_targets) {
for (auto const & m : *metadata) {
std::cerr << "search for [" << s << "] in [" << m << "]\n";
if (m.find (s) != string::npos) {
found_cnt++;
break;
}
}
}
if (found_cnt == search_targets.size()) {
search_results->push_back (SearchResult (p.first, *oc));
}
}

View File

@ -37,6 +37,8 @@
#include <gtkmm/treeview.h>
#include <gtkmm/window.h>
#include "pbd/configuration.h"
#include "widgets/slider_controller.h"
#include "actions.h"
@ -60,10 +62,6 @@
* options dialog.
*/
namespace PBD {
class Configuration;
}
namespace ArdourWidgets {
class Frame;
}
@ -74,7 +72,7 @@ class OptionEditorPage;
class OptionEditorComponent
{
public:
OptionEditorComponent() : _frame (0) {}
OptionEditorComponent() : _frame (0), _metadata (0) {}
virtual ~OptionEditorComponent() {}
/** Called when a configuration parameter's value has changed.
@ -95,8 +93,8 @@ public:
virtual Gtk::Widget& tip_widget() = 0;
virtual std::string get_metadata() const;
void set_metadata (std::string const &);
virtual PBD::Configuration::Metadata const * get_metadata() const;
void set_metadata (PBD::Configuration::Metadata const &);
void highlight ();
void end_highlight ();
@ -106,7 +104,7 @@ protected:
std::string _note;
ArdourWidgets::Frame* _frame;
std::string _metadata;
PBD::Configuration::Metadata const * _metadata;
};
/** A component which provides a subheading within the dialog */
@ -758,6 +756,8 @@ protected:
};
typedef std::vector<SearchResult> SearchResults;
SearchResults* search_results;
typedef std::vector<std::string> SearchTargets;
SearchTargets search_targets;
SearchResults::iterator search_iterator;
OptionEditorComponent* search_current_highlight;
std::string last_search_string;

View File

@ -1133,7 +1133,6 @@ class FontScalingOptions : public HSliderOption
_hscale.add_mark(250, Gtk::POS_TOP, empty);
set_note (_("Adjusting the scale requires an application restart for fully accurate re-layout."));
set_metadata (_("fonts font size scaling readable readability"));
}
void changed ()
@ -4821,9 +4820,9 @@ These settings will only take effect after %1 is restarted.\n\
for (auto oc : p.second->components) {
Option* o = dynamic_cast<Option*> (oc);
if (o) {
Configuration::Metadata const * m = Config->get_metadata (o->id());
Configuration::Metadata const * m = Configuration::get_metadata (o->id());
if (m) {
// oc->set_metadata (m);
oc->set_metadata (*m);
}
}
}

View File

@ -94,6 +94,18 @@ UIConfiguration::UIConfiguration ()
modifiers_modified (false),
block_save (0)
{
/* build map */
#undef UI_CONFIG_VARIABLE
#define UI_CONFIG_VARIABLE(Type,var,name,value) _my_variables.insert (std::make_pair ((name), &(var)));
#define CANVAS_FONT_VARIABLE(var,name) /* no need for metadata for these */
#include "ui_config_vars.h"
#undef UI_CONFIG_VARIABLE
#undef CANVAS_FONT_VARIABLE
build_metadata ();
load_state();
/* Setup defaults */
@ -552,11 +564,11 @@ UIConfiguration::get_state () const
}
XMLNode&
UIConfiguration::get_variables (std::string which_node) const
UIConfiguration::get_variables (std::string const & node_name) const
{
XMLNode* node;
node = new XMLNode (which_node);
node = new XMLNode (node_name);
#undef UI_CONFIG_VARIABLE
#undef CANVAS_FONT_VARIABLE
@ -856,3 +868,397 @@ UIConfiguration::color_to_hex_string_no_alpha (Gtkmm2ext::Color c)
}
return buf;
}
void
UIConfiguration::build_metadata ()
{
using namespace PBD;
#define VAR_META(name,...) { char const * _x[] { __VA_ARGS__ }; Configuration::all_metadata.insert (std::make_pair<std::string,Metadata> ((name), internationalize_and_upcase (PACKAGE, _x))); }
VAR_META (X_("action-table-columns"),
NULL
);
VAR_META (X_("all-floating-windows-are-dialogs"),
NULL
);
VAR_META (X_("allow-non-quarter-pulse"),
NULL
);
VAR_META (X_("ask-before-closing-last-window"),
NULL
);
VAR_META (X_("automation-edit-cancels-auto-hide"),
NULL
);
VAR_META (X_("autoplay-clips"),
NULL
);
VAR_META (X_("autoplay-files"),
NULL
);
VAR_META (X_("autoscroll-editor"),
NULL
);
VAR_META (X_("blink-alert-indicators"),
NULL
);
VAR_META (X_("blink-rec-arm"),
NULL
);
VAR_META (X_("boxy-buttons"),
NULL
);
VAR_META (X_("buggy-gradients"),
NULL
);
VAR_META (X_("cairo-image-surface"),
NULL
);
VAR_META (X_("check-announcements,"),
NULL
);
VAR_META (X_("clock-display-limit"),
NULL
);
VAR_META (X_("color-file"),
NULL
);
VAR_META (X_("color-regions-using-track-color"),
NULL
);
VAR_META (X_("default-bindings"),
NULL
);
VAR_META (X_("default-lower-midi-note"),
NULL
);
VAR_META (X_("default-narrow_ms"),
NULL
);
VAR_META (X_("default-upper-midi-note"),
NULL
);
VAR_META (X_("draggable-playhead"),
NULL
);
VAR_META (X_("draggable-playhead-speed"),
NULL
);
VAR_META (X_("editor-stereo-only-meters"),
NULL
);
VAR_META (X_("extra-ui-extents-time"),
NULL
);
VAR_META (X_("flat-buttons"),
NULL
);
VAR_META (X_("floating-monitor-section"),
NULL
);
VAR_META (X_("follow-edits"),
NULL
);
VAR_META (X_("font-scale"),
N_("fonts"), N_("font"), N_("size"), N_("scaling"), N_("readable"), N_("readability"),
NULL
);
VAR_META (X_("freesound-dir"),
NULL
);
VAR_META (X_("grid-follows-internal"),
NULL
);
VAR_META (X_("hide-splash-screen"),
NULL
);
VAR_META (X_("highlight-auditioned-clips"),
NULL
);
VAR_META (X_("icon-set"),
NULL
);
VAR_META (X_("input-meter-layout"),
NULL
);
VAR_META (X_("input-meter-scopes"),
NULL
);
VAR_META (X_("insert-at-position"),
NULL
);
VAR_META (X_("keyboard-layout"),
NULL
);
VAR_META (X_("keyboard-layout-name"),
NULL
);
VAR_META (X_("link-region-and-track-selection"),
NULL
);
VAR_META (X_("lock-gui-after-seconds"),
NULL
);
VAR_META (X_("max-inline-controls"),
NULL
);
VAR_META (X_("max-plugin-chart"),
NULL
);
VAR_META (X_("max-plugin-recent"),
NULL
);
VAR_META (X_("meter-hold"),
NULL
);
VAR_META (X_("meter-line-up-din"),
NULL
);
VAR_META (X_("meter-line-up-level"),
NULL
);
VAR_META (X_("meter-peak"),
NULL
);
VAR_META (X_("meter-style-led"),
NULL
);
VAR_META (X_("meter-vu-standard"),
NULL
);
VAR_META (X_("mixer-element-visibility"),
NULL
);
VAR_META (X_("name-new-markers"),
NULL
);
VAR_META (X_("never-display-periodic-midi"),
NULL
);
VAR_META (X_("new-automation-points-on-lane"),
NULL
);
VAR_META (X_("no-new-session-dialog"),
NULL
);
VAR_META (X_("one-plugin-window-only"),
NULL
);
VAR_META (X_("only-copy-imported-files"),
NULL
);
VAR_META (X_("open-gui-after-adding-plugin"),
NULL
);
VAR_META (X_("plugin-gui-behavior"),
NULL
);
VAR_META (X_("prefer-inline-over-gui"),
NULL
);
VAR_META (X_("preview-video-frame-on-drag"),
NULL
);
VAR_META (X_("primary-clock-delta-mode"),
NULL
);
VAR_META (X_("recent-session-sort"),
NULL
);
VAR_META (X_("rubberbanding-snaps-to-grid"),
NULL
);
VAR_META (X_("ruler-granularity"),
NULL
);
VAR_META (X_("rulers-follow-grid"),
NULL
);
VAR_META (X_("save-export-analysis-image"),
NULL
);
VAR_META (X_("save-export-mixer-screenshot"),
NULL
);
VAR_META (X_("screen-saver-mode"),
NULL
);
VAR_META (X_("secondary-clock-delta-mode"),
NULL
);
VAR_META (X_("show-editor-meter"),
NULL
);
VAR_META (X_("show-grids-ruler"),
NULL
);
VAR_META (X_("show-inline-display-by-default"),
NULL
);
VAR_META (X_("show-manager-if-plugins-are-missing"),
NULL
);
VAR_META (X_("show-mini-timeline"),
NULL
);
VAR_META (X_("show-name-highlight"),
NULL
);
VAR_META (X_("show-on-cue-page"),
NULL
);
VAR_META (X_("show-plugin-scan-window"),
NULL
);
VAR_META (X_("show-region-cue-markers"),
NULL
);
VAR_META (X_("show-region-gain"),
NULL
);
VAR_META (X_("show-region-name"),
NULL
);
VAR_META (X_("show-region-xrun-markers"),
NULL
);
VAR_META (X_("show-secondary-clock"),
NULL
);
VAR_META (X_("show-snapped-cursor"),
NULL
);
VAR_META (X_("show-toolbar-cuectrl"),
NULL
);
VAR_META (X_("show-toolbar-latency"),
NULL
);
VAR_META (X_("show-toolbar-monitor-info"),
NULL
);
VAR_META (X_("show-toolbar-monitoring"),
NULL
);
VAR_META (X_("show-toolbar-recpunch"),
NULL
);
VAR_META (X_("show-toolbar-selclock"),
NULL
);
VAR_META (X_("show-track-meters"),
NULL
);
VAR_META (X_("show-triggers-inline"),
NULL
);
VAR_META (X_("show-waveform-clipping"),
NULL
);
VAR_META (X_("show-waveforms"),
NULL
);
VAR_META (X_("show-waveforms-while-recording"),
NULL
);
VAR_META (X_("show-zoom-tools"),
NULL
);
VAR_META (X_("snap-threshold"),
NULL
);
VAR_META (X_("snap-to-grid"),
NULL
);
VAR_META (X_("snap-to-marks"),
NULL
);
VAR_META (X_("snap-to-region-end"),
NULL
);
VAR_META (X_("snap-to-region-start"),
NULL
);
VAR_META (X_("snap-to-region-sync"),
NULL
);
VAR_META (X_("sound-midi-notes"),
NULL
);
VAR_META (X_("stripable-color-palette"),
NULL
);
VAR_META (X_("super-rapid-clock-update"),
NULL
);
VAR_META (X_("time-axis-name-ellipsize-mode"),
NULL
);
VAR_META (X_("timeline-item-gradient-depth"),
NULL
);
VAR_META (X_("transients-follow-front"),
NULL
);
VAR_META (X_("ui-font-family"),
NULL
);
VAR_META (X_("ui-rc-file"),
NULL
);
VAR_META (X_("update-editor-during-summary-drag"),
NULL
);
VAR_META (X_("use-double-click-to-zoom-to-selection"),
NULL
);
VAR_META (X_("use-mouse-position-as-zoom-focus-on-scroll"),
NULL
);
VAR_META (X_("use-note-bars-for-velocity"),
NULL
);
VAR_META (X_("use-note-color-for-velocity"),
NULL
);
VAR_META (X_("use-opengl-view"),
NULL
);
VAR_META (X_("use-route-color-widely"),
NULL
);
VAR_META (X_("use-time-rulers-to-zoom-with-vertical-drag"),
NULL
);
VAR_META (X_("use-tooltips"),
NULL
);
VAR_META (X_("use-wm-visibility"),
NULL
);
VAR_META (X_("vertical-region-gap"),
NULL
);
VAR_META (X_("vkeybd-layout"),
NULL
);
VAR_META (X_("waveform-cache-size"),
NULL
);
VAR_META (X_("waveform-clip-level"),
NULL
);
VAR_META (X_("waveform-gradient-depth"),
NULL
);
VAR_META (X_("waveform-scale"),
NULL
);
VAR_META (X_("waveform-shape"),
NULL
);
VAR_META (X_("widget-prelight"),
NULL
);
}

View File

@ -27,6 +27,7 @@
#include <sstream>
#include <ostream>
#include <iostream>
#include <map>
#include <boost/function.hpp>
#include <boost/bind.hpp>
@ -34,9 +35,10 @@
#include "ardour/types.h" // required for operators used in pbd/configuration_variable.h
#include "ardour/types_convert.h"
#include "pbd/configuration.h"
#include "pbd/configuration_variable.h"
#include "pbd/stateful.h"
#include "pbd/xml++.h"
#include "pbd/configuration_variable.h"
#include "gtkmm2ext/colors.h"
#include "widgets/ui_config.h"
@ -61,9 +63,10 @@ public:
int load_defaults ();
int load_color_theme (bool allow_own);
void map_parameters (boost::function<void (std::string)>&);
int set_state (const XMLNode&, int version);
XMLNode& get_state () const;
XMLNode& get_variables (std::string) const;
XMLNode& get_variables (std::string const &) const;
void set_variables (const XMLNode&);
std::string color_file_name (bool use_my, bool with_version) const;
@ -94,7 +97,6 @@ public:
float get_ui_scale ();
sigc::signal<void, std::string> ParameterChanged;
void map_parameters (boost::function<void (std::string)>&);
void parameter_changed (std::string);
@ -107,6 +109,8 @@ public:
/** called after the GUI toolkit has been initialized. */
UIConfiguration* post_gui_init ();
std::map<std::string,PBD::ConfigVariableBase*> _my_variables;
#undef UI_CONFIG_VARIABLE
#define UI_CONFIG_VARIABLE(Type,var,name,value) \
Type get_##var () const { return var.get(); } \
@ -147,6 +151,8 @@ private:
void colors_changed ();
uint32_t block_save;
void build_metadata ();
};
#endif /* __ardour_ui_configuration_h__ */