13
0
livetrax/gtk2_ardour/theme_manager.cc

233 lines
8.4 KiB
C++
Raw Normal View History

/*
Copyright (C) 2000-2007 Paul Davis
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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <cmath>
#include <errno.h>
#include "fix_carbon.h"
#include "pbd/gstdio_compat.h"
#include <gtkmm/settings.h>
#include "gtkmm2ext/gtk_ui.h"
2014-06-10 14:23:14 -04:00
#include "gtkmm2ext/utils.h"
#include "pbd/compose.h"
#include "ardour/profile.h"
#include "canvas/wave_view.h"
#include "ardour_button.h"
2014-12-07 13:12:36 -05:00
#include "ardour_dialog.h"
#include "theme_manager.h"
#include "ui_config.h"
2014-06-10 14:23:14 -04:00
#include "utils.h"
#include "pbd/i18n.h"
using namespace std;
using namespace Gtk;
Large nasty commit in the form of a 5000 line patch chock-full of completely unecessary changes. (Sorry, doing a "sprint" based thing, this is the end of the first one) Achieved MIDI track and bus creation, associated Jack port and diskstream creation, and minimal GUI stuff for creating them. Should be set to start work on actually recording and playing midi to/from disk now. Relevant (significant) changes: - Creation of a Buffer class. Base class is type agnostic so things can point to a buffer but not care what kind it is (otherwise it'd be a template). Derived into AudioBuffer and MidiBuffer, with a type tag because checking type is necessary in parts of the code where dynamic_cast wouldn't be wise. Originally I considered this a hack, but passing around a type proved to be a very good solution to all the other problems (below). There is a 1:1 mapping between jack port data types and ardour Buffer types (with a conversion function), but that's easily removed if it ever becomes necessary. Having the type scoped in the Buffer class is maybe not the best spot for it, but whatever (this is proof of concept kinda stuff right now...) - IO now has a "default" port type (passed to the constructor and stored as a member), used by ensure_io (and similar) to create n ports. IO::register_***_port has a type argument that defaults to the default type if not passed. Rationale: previous IO API is identical, no changes needed to existing code, but path is paved for multiple port types in one IO, which we will need for eg synth plugin inserts, among other things. This is not quite ideal (best would be to only have the two port register functions and have them take a type), but the alternative is a lot of work (namely destroying the 'ensure' functions and everything that uses them) for very little gain. (I am convinced after quite a few tries at the whiteboard that subclassing IO in any way is not a feasible option, look at it's inheritance diagram in Doxygen and you can see why) - AudioEngine::register_audio_input_port is now register_input_port and takes a type argument. Ditto for output. - (Most significant change) AudioDiskstream abstracted into Distream, and sibling MidiDiskstream created. Very much still a work in progress, but Diskstream is there to switch references over to (most already are), which is the important part. It is still unclear what the MIDI diskstream's relation to channels is, but I'm pretty sure they will be single channel only (so SMF Type 0) since noone can come up with a reason otherwise. - MidiTrack creation. Same thing as AudioTrack but with a different default type basically. No big deal here. - Random cleanups and variable renamings etc. because I have OCD and can't help myself. :) Known broken: Loading of sessions containing MIDI tracks. git-svn-id: svn://localhost/ardour2/branches/midi@641 d708f5d6-7413-0410-9779-e7cbd77b26cf
2006-06-26 12:01:34 -04:00
using namespace PBD;
using namespace ARDOUR;
using namespace ARDOUR_UI_UTILS;
ThemeManager::ThemeManager()
: flat_buttons (_("Draw \"flat\" buttons"))
2014-08-27 15:41:49 -04:00
, blink_rec_button (_("Blink Rec-Arm buttons"))
, region_color_button (_("Color regions using their track's color"))
, show_clipping_button (_("Show waveform clipping"))
, waveform_gradient_depth (0, 1.0, 0.05)
, waveform_gradient_depth_label (_("Waveforms color gradient depth"))
, timeline_item_gradient_depth (0, 1.0, 0.05)
, timeline_item_gradient_depth_label (_("Timeline item gradient depth"))
, all_dialogs (_("All floating windows are dialogs"))
, transients_follow_front (_("Transient windows follow front window."))
, floating_monitor_section (_("Float detached monitor-section window"))
2014-06-10 14:23:14 -04:00
, icon_set_label (_("Icon Set"))
{
Gtk::HBox* hbox;
/* various buttons */
2015-10-05 10:17:49 -04:00
set_homogeneous (false);
#ifndef __APPLE__
pack_start (all_dialogs, PACK_SHRINK);
pack_start (transients_follow_front, PACK_SHRINK);
#endif
if (!Profile->get_mixbus()) {
pack_start (floating_monitor_section, PACK_SHRINK);
}
pack_start (flat_buttons, PACK_SHRINK);
pack_start (blink_rec_button, PACK_SHRINK);
pack_start (region_color_button, PACK_SHRINK);
pack_start (show_clipping_button, PACK_SHRINK);
2014-06-10 14:23:14 -04:00
vector<string> icon_sets = ::get_icon_sets ();
if (icon_sets.size() > 1) {
Gtkmm2ext::set_popdown_strings (icon_set_dropdown, icon_sets);
icon_set_dropdown.set_active_text (UIConfiguration::instance().get_icon_set());
2014-06-10 14:23:14 -04:00
hbox = Gtk::manage (new Gtk::HBox());
hbox->set_spacing (6);
2016-05-29 12:15:07 -04:00
Gtk::Alignment* align = Gtk::manage (new Gtk::Alignment);
align->set (0, 0.5);
align->add (icon_set_dropdown);
2014-06-10 14:23:14 -04:00
hbox->pack_start (icon_set_label, false, false);
2016-05-29 12:15:07 -04:00
hbox->pack_start (*align, true, true);
pack_start (*hbox, PACK_SHRINK);
2014-06-10 14:23:14 -04:00
}
hbox = Gtk::manage (new Gtk::HBox());
hbox->set_spacing (6);
hbox->pack_start (waveform_gradient_depth, true, true);
hbox->pack_start (waveform_gradient_depth_label, false, false);
pack_start (*hbox, PACK_SHRINK);
hbox = Gtk::manage (new Gtk::HBox());
hbox->set_spacing (6);
hbox->pack_start (timeline_item_gradient_depth, true, true);
hbox->pack_start (timeline_item_gradient_depth_label, false, false);
pack_start (*hbox, PACK_SHRINK);
2014-06-10 14:23:14 -04:00
show_all ();
waveform_gradient_depth.set_update_policy (Gtk::UPDATE_DELAYED);
timeline_item_gradient_depth.set_update_policy (Gtk::UPDATE_DELAYED);
2015-10-05 10:17:49 -04:00
set_ui_to_state();
flat_buttons.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_flat_buttons_toggled));
2014-08-27 15:41:49 -04:00
blink_rec_button.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_blink_rec_arm_toggled));
region_color_button.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_region_color_toggled));
show_clipping_button.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_show_clip_toggled));
waveform_gradient_depth.signal_value_changed().connect (sigc::mem_fun (*this, &ThemeManager::on_waveform_gradient_depth_change));
timeline_item_gradient_depth.signal_value_changed().connect (sigc::mem_fun (*this, &ThemeManager::on_timeline_item_gradient_depth_change));
all_dialogs.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_all_dialogs_toggled));
transients_follow_front.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_transients_follow_front_toggled));
floating_monitor_section.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_floating_monitor_section_toggled));
icon_set_dropdown.signal_changed().connect (sigc::mem_fun (*this, &ThemeManager::on_icon_set_changed));
Gtkmm2ext::UI::instance()->set_tip (all_dialogs,
string_compose (_("Mark all floating windows to be type \"Dialog\" rather than using \"Utility\" for some.\n"
"This may help with some window managers. This requires a restart of %1 to take effect"),
PROGRAM_NAME));
Gtkmm2ext::UI::instance()->set_tip (transients_follow_front,
string_compose (_("Make transient windows follow the front window when toggling between the editor and mixer.\n"
"This requires a restart of %1 to take effect"), PROGRAM_NAME));
Gtkmm2ext::UI::instance()->set_tip (floating_monitor_section,
string_compose (_("When detaching the monitoring section, mark it as \"Utility\" window to stay in front.\n"
"This requires a restart of %1 to take effect"), PROGRAM_NAME));
}
void
ThemeManager::on_flat_buttons_toggled ()
{
UIConfiguration::instance().set_flat_buttons (flat_buttons.get_active());
ArdourButton::set_flat_buttons (flat_buttons.get_active());
/* force a redraw */
gtk_rc_reset_styles (gtk_settings_get_default());
}
2014-08-27 15:41:49 -04:00
void
ThemeManager::on_blink_rec_arm_toggled ()
{
UIConfiguration::instance().set_blink_rec_arm (blink_rec_button.get_active());
UIConfiguration::instance().ParameterChanged("blink-rec-arm");
2014-08-27 15:41:49 -04:00
}
void
ThemeManager::on_region_color_toggled ()
{
UIConfiguration::instance().set_color_regions_using_track_color (region_color_button.get_active());
}
void
ThemeManager::on_show_clip_toggled ()
{
UIConfiguration::instance().set_show_waveform_clipping (show_clipping_button.get_active());
// "show-waveform-clipping" was a session config key
ArdourCanvas::WaveView::set_global_show_waveform_clipping (UIConfiguration::instance().get_show_waveform_clipping());
}
void
ThemeManager::on_all_dialogs_toggled ()
{
UIConfiguration::instance().set_all_floating_windows_are_dialogs (all_dialogs.get_active());
}
void
ThemeManager::on_transients_follow_front_toggled ()
{
UIConfiguration::instance().set_transients_follow_front (transients_follow_front.get_active());
}
void
ThemeManager::on_floating_monitor_section_toggled ()
{
UIConfiguration::instance().set_floating_monitor_section (floating_monitor_section.get_active());
}
void
ThemeManager::on_waveform_gradient_depth_change ()
{
double v = waveform_gradient_depth.get_value();
UIConfiguration::instance().set_waveform_gradient_depth (v);
ArdourCanvas::WaveView::set_global_gradient_depth (v);
}
void
ThemeManager::on_timeline_item_gradient_depth_change ()
{
double v = timeline_item_gradient_depth.get_value();
UIConfiguration::instance().set_timeline_item_gradient_depth (v);
}
void
ThemeManager::on_icon_set_changed ()
{
string new_set = icon_set_dropdown.get_active_text();
UIConfiguration::instance().set_icon_set (new_set);
}
void
ThemeManager::set_ui_to_state()
{
/* there is no need to block signal handlers, here,
* all elements check if the value has changed and ignore NOOPs
*/
all_dialogs.set_active (UIConfiguration::instance().get_all_floating_windows_are_dialogs());
transients_follow_front.set_active (UIConfiguration::instance().get_transients_follow_front());
floating_monitor_section.set_active (UIConfiguration::instance().get_floating_monitor_section());
flat_buttons.set_active (UIConfiguration::instance().get_flat_buttons());
blink_rec_button.set_active (UIConfiguration::instance().get_blink_rec_arm());
region_color_button.set_active (UIConfiguration::instance().get_color_regions_using_track_color());
show_clipping_button.set_active (UIConfiguration::instance().get_show_waveform_clipping());
waveform_gradient_depth.set_value(UIConfiguration::instance().get_waveform_gradient_depth());
timeline_item_gradient_depth.set_value(UIConfiguration::instance().get_timeline_item_gradient_depth());
}