--- gigedit/trunk/src/gigedit/MacroEditor.cpp 2017/05/10 21:21:14 3170 +++ gigedit/trunk/src/gigedit/MacroEditor.cpp 2017/05/17 16:14:20 3187 @@ -23,16 +23,20 @@ set_default_size(800, 600); - //FIXME: Commented out since Gtk::Label is a disaster when it comes to multi line content. - /*m_labelIntro.set_text( + m_labelIntro.set_padding(10, 10); +#if GTKMM_MAJOR_VERSION >= 3 + m_labelIntro.set_line_wrap(); +#endif + m_labelIntro.set_text( _("A macro is a list of parameters and corresponding values which " "should be applied to the instrument editor when the macro is " - "triggered by the user. A macro is triggered either by selecting " - "the macro from the \"Macro\" menu, or by hitting the macro's " - "respective keyboard accelerator (F1 to F12).") + "triggered by the user. Only the parameters listed here will be " + "applied to the instrument editor when this macro is triggered, all " + "other ones remain untouched. So simply delete parameters here which " + "you don't want to be modified by this macro. Double click on a " + "value to change it.") ); - m_labelIntro.set_line_wrap(); - m_vbox.pack_start(m_labelIntro, Gtk::PACK_SHRINK);*/ + m_vbox.pack_start(m_labelIntro, Gtk::PACK_SHRINK); // create Macro treeview (including its data model) m_treeStoreMacro = MacroTreeStore::create(m_treeModelMacro); @@ -54,8 +58,8 @@ //column->set_renderer(m_valueCellRenderer, m_treeModelMacro.m_col_value); column->add_attribute(m_valueCellRenderer.property_text(), m_treeModelMacro.m_col_value); - //column->add_attribute(m_valueCellRenderer.property_has_entry(), - // m_treeModelMacro.m_col_allowTextEntry); + column->add_attribute(m_valueCellRenderer.property_has_entry(), + m_treeModelMacro.m_col_allowTextEntry); column->add_attribute(m_valueCellRenderer.property_editable(), m_treeModelMacro.m_col_editable); column->add_attribute(m_valueCellRenderer.property_model(), @@ -148,6 +152,9 @@ sigc::mem_fun(*this, &MacroEditor::onKeyReleased) ); + m_deleteButton.set_tooltip_text(_("Delete the selected parameters from this macro.")); + m_inverseDeleteButton.set_tooltip_text(_("Delete all parameters from this macro except the selected ones.")); + show_all_children(); updateStatus(); } @@ -189,6 +196,14 @@ return refOptions; } +inline static Serialization::String _boolToStr(bool b) { + // 'NO' intentional all uper case in contrast to 'Yes', simply because I + // find them easier distinguishable that way on quick readings + return b ? "Yes" : "NO"; +} + +static const char* _boolOptions[] = { "Yes", "NO", NULL }; + void MacroEditor::buildTreeView(const Gtk::TreeModel::Row& parentRow, const Serialization::Object& parentObject) { for (int iMember = 0; iMember < parentObject.members().size(); ++iMember) { const Serialization::Member& member = parentObject.members()[iMember]; @@ -198,7 +213,7 @@ row[m_treeModelMacro.m_col_name] = gig_to_utf8(member.name()); row[m_treeModelMacro.m_col_type] = gig_to_utf8(member.type().asLongDescr()); row[m_treeModelMacro.m_col_uid] = object.uid(); - row[m_treeModelMacro.m_col_allowTextEntry] = false; + row[m_treeModelMacro.m_col_allowTextEntry] = true; if (object.type().isClass()) { row[m_treeModelMacro.m_col_value] = "(class)"; @@ -215,6 +230,12 @@ Glib::RefPtr refOptions = createComboOptions(allKeys); row[m_treeModelMacro.m_col_options] = refOptions; } + } else if (object.type().isBool()) { + row[m_treeModelMacro.m_col_value] = _boolToStr( m_macro.valueAsBool(object) ); + row[m_treeModelMacro.m_col_editable] = true; + Glib::RefPtr refOptions = createComboOptions(_boolOptions); + row[m_treeModelMacro.m_col_options] = refOptions; + row[m_treeModelMacro.m_col_allowTextEntry] = false; } else { row[m_treeModelMacro.m_col_value] = m_macro.valueAsString(object); row[m_treeModelMacro.m_col_editable] = true; @@ -297,7 +318,6 @@ } void MacroEditor::onValueCellEdited(const Glib::ustring& sPath, const Glib::ustring& text) { - printf("asdf\n"); Gtk::TreePath path(sPath); Gtk::TreeModel::iterator iter = m_treeStoreMacro->get_iter(path); onMacroTreeViewRowValueChangedImpl(path, iter, text); @@ -332,6 +352,12 @@ // no auto correct here yet (due to numeric vs. textual values) if (row[m_treeModelMacro.m_col_value] != value) row[m_treeModelMacro.m_col_value] = value; + } else if (object.type().isBool()) { + m_macro.setAutoValue(object, gigvalue); + Serialization::String sBoolean = _boolToStr( m_macro.valueAsBool(object) ); + // potentially auto correct (i.e. when type is bool, user entered '5' -> yields 'Yes') + if (row[m_treeModelMacro.m_col_value] != sBoolean) + row[m_treeModelMacro.m_col_value] = sBoolean; } else { m_macro.setAutoValue(object, gigvalue); // potentially auto correct (i.e. when type is bool, user entered 5 -> yields 1)