2011-10-29 16:18:06 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2011-2012 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2015-2019 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2011-10-29 16:18:06 -04:00
|
|
|
|
|
|
|
#ifndef __ardour_visibility_group__
|
|
|
|
#define __ardour_visibility_group__
|
|
|
|
|
|
|
|
#include <gtkmm/liststore.h>
|
|
|
|
#include "pbd/signals.h"
|
|
|
|
|
|
|
|
class XMLNode;
|
|
|
|
class XMLProperty;
|
|
|
|
|
|
|
|
/** A class to manage a group of widgets where the visibility of each
|
|
|
|
* can be configured by the user. The class can generate a menu to
|
|
|
|
* set up visibility, and save and restore visibility state to XML.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class VisibilityGroup
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VisibilityGroup (std::string const &);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2011-11-02 21:44:17 -04:00
|
|
|
void add (
|
|
|
|
Gtk::Widget *,
|
|
|
|
std::string const &,
|
|
|
|
std::string const &,
|
2012-06-06 07:24:07 -04:00
|
|
|
bool visible = false,
|
2011-11-02 21:44:17 -04:00
|
|
|
boost::function<boost::optional<bool> ()> = 0
|
|
|
|
);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2011-10-29 16:18:06 -04:00
|
|
|
Gtk::Widget* list_view ();
|
|
|
|
bool button_press_event (GdkEventButton *);
|
|
|
|
void update ();
|
|
|
|
void set_state (XMLNode const &);
|
|
|
|
void set_state (std::string);
|
|
|
|
std::string get_state_name () const;
|
|
|
|
std::string get_state_value () const;
|
|
|
|
|
|
|
|
PBD::Signal0<void> VisibilityChanged;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2016-04-29 10:33:05 -04:00
|
|
|
static std::string remove_element (std::string const& from, std::string const& element);
|
|
|
|
static std::string add_element (std::string const& from, std::string const& element);
|
|
|
|
|
2011-10-29 16:18:06 -04:00
|
|
|
private:
|
|
|
|
|
|
|
|
struct Member {
|
|
|
|
Gtk::Widget* widget;
|
|
|
|
std::string id;
|
|
|
|
std::string name;
|
|
|
|
bool visible;
|
2011-11-02 21:44:17 -04:00
|
|
|
boost::function<boost::optional<bool> ()> override;
|
2011-10-29 16:18:06 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class ModelColumns : public Gtk::TreeModelColumnRecord {
|
|
|
|
public:
|
|
|
|
ModelColumns () {
|
|
|
|
add (_visible);
|
|
|
|
add (_name);
|
|
|
|
add (_iterator);
|
|
|
|
}
|
|
|
|
|
|
|
|
Gtk::TreeModelColumn<bool> _visible;
|
|
|
|
Gtk::TreeModelColumn<std::string> _name;
|
|
|
|
Gtk::TreeModelColumn<std::vector<Member>::iterator> _iterator;
|
|
|
|
};
|
|
|
|
|
|
|
|
void toggle (std::vector<Member>::iterator);
|
|
|
|
void list_view_visible_changed (std::string const &);
|
|
|
|
void update_list_view ();
|
2011-11-02 21:44:17 -04:00
|
|
|
bool should_actually_be_visible (Member const &) const;
|
2011-10-29 16:18:06 -04:00
|
|
|
|
|
|
|
std::vector<Member> _members;
|
|
|
|
std::string _xml_property_name;
|
|
|
|
ModelColumns _model_columns;
|
|
|
|
Glib::RefPtr<Gtk::ListStore> _model;
|
|
|
|
bool _ignore_list_view_change;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|