2005-09-25 14:42:24 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2005-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
|
|
|
|
* Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2014-2018 Robin Gareus <robin@gareus.org>
|
|
|
|
* Copyright (C) 2016 Tim Mayberry <mojofunk@gmail.com>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/error.h"
|
2012-04-12 07:45:40 -04:00
|
|
|
#include "pbd/convert.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm2ext/utils.h>
|
|
|
|
#include <gtkmm2ext/gtk_ui.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2017-05-05 07:31:49 -04:00
|
|
|
#include "ardour/selection.h"
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "public_editor.h"
|
2011-07-06 20:37:13 -04:00
|
|
|
#include "ardour_ui.h"
|
|
|
|
#include "gui_object.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "axis_view.h"
|
2020-12-07 17:41:55 -05:00
|
|
|
#include "ui_config.h"
|
2011-08-30 05:48:53 -04:00
|
|
|
#include "utils.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2018-09-21 13:05:57 -04:00
|
|
|
#include "pbd/i18n.h"
|
|
|
|
|
2009-05-12 13:03:42 -04:00
|
|
|
using namespace std;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace Gtk;
|
2005-09-25 16:33:00 -04:00
|
|
|
using namespace Gtkmm2ext;
|
2009-12-17 13:24:23 -05:00
|
|
|
using namespace ARDOUR;
|
2014-06-25 15:27:37 -04:00
|
|
|
using namespace ARDOUR_UI_UTILS;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-05 09:48:09 -04:00
|
|
|
list<Gdk::Color> AxisView::used_colors;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2016-06-05 15:47:39 -04:00
|
|
|
AxisView::AxisView ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
AxisView::~AxisView()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-10-05 09:48:09 -04:00
|
|
|
Gdk::Color
|
2005-09-25 14:42:24 -04:00
|
|
|
AxisView::unique_random_color()
|
|
|
|
{
|
2011-08-30 05:48:53 -04:00
|
|
|
return ::unique_random_color (used_colors);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2011-07-06 20:37:13 -04:00
|
|
|
|
|
|
|
string
|
|
|
|
AxisView::gui_property (const string& property_name) const
|
|
|
|
{
|
2014-06-28 15:45:52 -04:00
|
|
|
if (property_hashtable.count(property_name)) {
|
|
|
|
return property_hashtable[property_name];
|
|
|
|
} else {
|
2016-12-21 15:57:39 -05:00
|
|
|
string rv = gui_object_state().get_string (state_id(), property_name);
|
2014-06-28 15:45:52 -04:00
|
|
|
property_hashtable.erase(property_name);
|
|
|
|
property_hashtable.emplace(property_name, rv);
|
|
|
|
return rv;
|
|
|
|
}
|
2011-07-06 20:37:13 -04:00
|
|
|
}
|
|
|
|
|
2016-08-30 07:07:24 -04:00
|
|
|
bool
|
|
|
|
AxisView::get_gui_property (const std::string& property_name, std::string& value) const
|
|
|
|
{
|
|
|
|
std::string str = gui_property(property_name);
|
|
|
|
|
|
|
|
if (!str.empty()) {
|
|
|
|
value = str;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-02-06 16:39:30 -05:00
|
|
|
void
|
|
|
|
AxisView::remove_gui_property (const std::string& property_name)
|
|
|
|
{
|
|
|
|
property_hashtable.erase (property_name);
|
|
|
|
gui_object_state().remove_property (state_id(), property_name);
|
|
|
|
}
|
|
|
|
|
2016-08-30 07:07:24 -04:00
|
|
|
void
|
|
|
|
AxisView::set_gui_property (const std::string& property_name, const std::string& value)
|
|
|
|
{
|
|
|
|
property_hashtable.erase (property_name);
|
|
|
|
property_hashtable.emplace (property_name, value);
|
|
|
|
gui_object_state ().set_property (state_id (), property_name, value);
|
|
|
|
}
|
|
|
|
|
2011-07-06 20:37:13 -04:00
|
|
|
bool
|
|
|
|
AxisView::marked_for_display () const
|
|
|
|
{
|
2016-08-30 08:33:00 -04:00
|
|
|
bool visible;
|
|
|
|
if (!get_gui_property ("visible", visible)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return visible;
|
2011-07-06 20:37:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
AxisView::set_marked_for_display (bool yn)
|
|
|
|
{
|
2016-08-30 08:33:00 -04:00
|
|
|
bool visible;
|
|
|
|
if (get_gui_property ("visible", visible) && visible == yn) {
|
|
|
|
return false; // nothing changed
|
2011-07-06 20:37:13 -04:00
|
|
|
}
|
2016-08-30 08:33:00 -04:00
|
|
|
|
|
|
|
set_gui_property ("visible", yn);
|
|
|
|
return true; // things changed
|
2011-07-06 20:37:13 -04:00
|
|
|
}
|
|
|
|
|
2011-07-11 16:32:33 -04:00
|
|
|
GUIObjectState&
|
2015-10-04 14:51:05 -04:00
|
|
|
AxisView::gui_object_state()
|
2011-07-11 16:32:33 -04:00
|
|
|
{
|
|
|
|
return *ARDOUR_UI::instance()->gui_object_state;
|
|
|
|
}
|
2016-07-06 13:37:30 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
AxisView::set_selected (bool yn)
|
|
|
|
{
|
|
|
|
if (selected() == yn) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Selectable::set_selected (yn);
|
|
|
|
}
|
2020-12-07 17:41:55 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
AxisView::set_name_ellipsize_mode ()
|
|
|
|
{
|
|
|
|
switch (UIConfiguration::instance().get_time_axis_name_ellipsize_mode()) {
|
|
|
|
case -1:
|
|
|
|
name_label.set_ellipsize (Pango::ELLIPSIZE_START);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
name_label.set_ellipsize (Pango::ELLIPSIZE_END);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
name_label.set_ellipsize (Pango::ELLIPSIZE_MIDDLE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|