13
0

move color utility functions from ARDOUR_UI_UTILS to Gtkmm2ext namespace (GUI)

This commit is contained in:
Paul Davis 2022-08-10 21:11:52 -06:00
parent a2e4897a49
commit 9ea1e5bdee
23 changed files with 62 additions and 118 deletions

View File

@ -39,6 +39,7 @@
#include "pbd/stl_delete.h" #include "pbd/stl_delete.h"
#include "pbd/memento_command.h" #include "pbd/memento_command.h"
#include "gtkmm2ext/colors.h"
#include "gtkmm2ext/gtk_ui.h" #include "gtkmm2ext/gtk_ui.h"
#include "gtkmm2ext/utils.h" #include "gtkmm2ext/utils.h"
@ -60,14 +61,12 @@
#include "audio_region_view.h" #include "audio_region_view.h"
#include "audio_streamview.h" #include "audio_streamview.h"
#include "ui_config.h" #include "ui_config.h"
#include "utils.h"
#include "pbd/i18n.h" #include "pbd/i18n.h"
using namespace std; using namespace std;
using namespace ARDOUR; using namespace ARDOUR;
using namespace ArdourWidgets; using namespace ArdourWidgets;
using namespace ARDOUR_UI_UTILS;
using namespace PBD; using namespace PBD;
using namespace Gtk; using namespace Gtk;
using namespace Editing; using namespace Editing;
@ -92,7 +91,7 @@ AudioTimeAxisView::set_route (boost::shared_ptr<Route> rt)
RouteTimeAxisView::set_route (rt); RouteTimeAxisView::set_route (rt);
_view->apply_color (gdk_color_to_rgba (color()), StreamView::RegionColor); _view->apply_color (Gtkmm2ext::gdk_color_to_rgba (color()), StreamView::RegionColor);
// Make sure things are sane... // Make sure things are sane...
assert(!is_track() || is_audio_track()); assert(!is_track() || is_audio_track());

View File

@ -339,7 +339,7 @@ CueBoxUI::set_all_colors (uint64_t idx)
_color_dialog.get_ok_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (_color_dialog, &Gtk::Dialog::response), Gtk::RESPONSE_ACCEPT)); _color_dialog.get_ok_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (_color_dialog, &Gtk::Dialog::response), Gtk::RESPONSE_ACCEPT));
_color_dialog.get_cancel_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (_color_dialog, &Gtk::Dialog::response), Gtk::RESPONSE_CANCEL)); _color_dialog.get_cancel_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (_color_dialog, &Gtk::Dialog::response), Gtk::RESPONSE_CANCEL));
Gdk::Color c = ARDOUR_UI_UTILS::gdk_color_from_rgba(0xBEBEBEFF); Gdk::Color c = Gtkmm2ext::gdk_color_from_rgba(0xBEBEBEFF);
_color_dialog.get_color_selection()->set_previous_color (c); _color_dialog.get_color_selection()->set_previous_color (c);
_color_dialog.get_color_selection()->set_current_color (c); _color_dialog.get_color_selection()->set_current_color (c);
@ -347,7 +347,7 @@ CueBoxUI::set_all_colors (uint64_t idx)
switch (_color_dialog.run()) { switch (_color_dialog.run()) {
case Gtk::RESPONSE_ACCEPT: { case Gtk::RESPONSE_ACCEPT: {
c = _color_dialog.get_color_selection()->get_current_color(); c = _color_dialog.get_color_selection()->get_current_color();
color_t ct = ARDOUR_UI_UTILS::gdk_color_to_rgba(c); color_t ct = Gtkmm2ext::gdk_color_to_rgba(c);
TriggerList tl; TriggerList tl;
get_slots(tl, idx); get_slots(tl, idx);
for (TriggerList::iterator t = tl.begin(); t != tl.end(); ++t) { for (TriggerList::iterator t = tl.begin(); t != tl.end(); ++t) {

View File

@ -30,6 +30,7 @@
#include <gtkmm/stock.h> #include <gtkmm/stock.h>
#include "gtkmm2ext/colors.h"
#include "gtkmm2ext/gtk_ui.h" #include "gtkmm2ext/gtk_ui.h"
#include "gtkmm2ext/cell_renderer_color_selector.h" #include "gtkmm2ext/cell_renderer_color_selector.h"
@ -50,13 +51,11 @@
#include "route_group_dialog.h" #include "route_group_dialog.h"
#include "route_time_axis.h" #include "route_time_axis.h"
#include "time_axis_view.h" #include "time_axis_view.h"
#include "utils.h"
#include "pbd/i18n.h" #include "pbd/i18n.h"
using namespace std; using namespace std;
using namespace ARDOUR; using namespace ARDOUR;
using namespace ARDOUR_UI_UTILS;
using namespace ArdourWidgets; using namespace ArdourWidgets;
using namespace PBD; using namespace PBD;
using namespace Gtk; using namespace Gtk;
@ -274,7 +273,7 @@ EditorRouteGroups::button_press_event (GdkEventButton* ev)
switch (color_dialog.run()) { switch (color_dialog.run()) {
case RESPONSE_ACCEPT: case RESPONSE_ACCEPT:
c = color_dialog.get_color_selection()->get_current_color(); c = color_dialog.get_color_selection()->get_current_color();
GroupTabs::set_group_color (group, gdk_color_to_rgba (c)); GroupTabs::set_group_color (group, Gtkmm2ext::gdk_color_to_rgba (c));
break; break;
default: default:
@ -404,7 +403,7 @@ EditorRouteGroups::row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel
group->apply_changes (plist); group->apply_changes (plist);
GroupTabs::set_group_color ((*iter)[_columns.routegroup], gdk_color_to_rgba ((*iter)[_columns.gdkcolor])); GroupTabs::set_group_color ((*iter)[_columns.routegroup], Gtkmm2ext::gdk_color_to_rgba ((*iter)[_columns.gdkcolor]));
} }
void void
@ -427,7 +426,7 @@ EditorRouteGroups::add (RouteGroup* group)
row[_columns.is_visible] = !group->is_hidden(); row[_columns.is_visible] = !group->is_hidden();
Gdk::Color c; Gdk::Color c;
set_color_from_rgba (c, GroupTabs::group_color (group)); Gtkmm2ext::set_color_from_rgba (c, GroupTabs::group_color (group));
row[_columns.gdkcolor] = c; row[_columns.gdkcolor] = c;
_in_row_change = true; _in_row_change = true;
@ -501,7 +500,7 @@ EditorRouteGroups::property_changed (RouteGroup* group, const PropertyChange&)
(*iter)[_columns.is_visible] = !group->is_hidden(); (*iter)[_columns.is_visible] = !group->is_hidden();
Gdk::Color c; Gdk::Color c;
set_color_from_rgba (c, GroupTabs::group_color (group)); Gtkmm2ext::set_color_from_rgba (c, GroupTabs::group_color (group));
(*iter)[_columns.gdkcolor] = c; (*iter)[_columns.gdkcolor] = c;
break; break;

View File

@ -840,7 +840,7 @@ GroupTabs::group_color (RouteGroup* group)
if (empty) { if (empty) {
/* no color has yet been set, so use a random one */ /* no color has yet been set, so use a random one */
uint32_t c = gdk_color_to_rgba (unique_random_color (_used_colors)); uint32_t c = Gtkmm2ext::gdk_color_to_rgba (unique_random_color (_used_colors));
set_group_color (group, c); set_group_color (group, c);
return c; return c;
} }

View File

@ -28,6 +28,7 @@
#include "ardour/types.h" #include "ardour/types.h"
#include "ardour/user_bundle.h" #include "ardour/user_bundle.h"
#include "gtkmm2ext/colors.h"
#include "gtkmm2ext/keyboard.h" #include "gtkmm2ext/keyboard.h"
#include "gtkmm2ext/menu_elems.h" #include "gtkmm2ext/menu_elems.h"
#include "gtkmm2ext/utils.h" #include "gtkmm2ext/utils.h"
@ -43,7 +44,6 @@
#include "plugin_selector.h" #include "plugin_selector.h"
#include "plugin_ui.h" #include "plugin_ui.h"
#include "ui_config.h" #include "ui_config.h"
#include "utils.h"
#include "pbd/i18n.h" #include "pbd/i18n.h"
@ -289,7 +289,7 @@ IOPluginWindow::IOPlugUI::IOPlugUI (boost::shared_ptr<ARDOUR::IOPlug> iop)
_box.set_border_width (1); _box.set_border_width (1);
Gdk::Color bg; Gdk::Color bg;
ARDOUR_UI_UTILS::set_color_from_rgba (bg, UIConfiguration::instance ().color (X_("theme:bg1"))); Gtkmm2ext::set_color_from_rgba (bg, UIConfiguration::instance ().color (X_("theme:bg1")));
_frame.modify_bg (STATE_NORMAL, bg); _frame.modify_bg (STATE_NORMAL, bg);
_frame.add (_box); _frame.add (_box);

View File

@ -806,9 +806,9 @@ LoudnessDialog::test_conformity ()
uint32_t c_warn = UIConfigurationBase::instance ().color ("alert:yellow"); // Warning / yellow uint32_t c_warn = UIConfigurationBase::instance ().color ("alert:yellow"); // Warning / yellow
uint32_t c_fail = UIConfigurationBase::instance ().color ("alert:red"); // Fail / red uint32_t c_fail = UIConfigurationBase::instance ().color ("alert:red"); // Fail / red
Gdk::Color color_good = ARDOUR_UI_UTILS::gdk_color_from_rgba (c_good); Gdk::Color color_good = Gtkmm2ext::gdk_color_from_rgba (c_good);
Gdk::Color color_warn = ARDOUR_UI_UTILS::gdk_color_from_rgba (c_warn); Gdk::Color color_warn = Gtkmm2ext::gdk_color_from_rgba (c_warn);
Gdk::Color color_fail = ARDOUR_UI_UTILS::gdk_color_from_rgba (c_fail); Gdk::Color color_fail = Gtkmm2ext::gdk_color_from_rgba (c_fail);
for (size_t i = 1; i < n_pset; ++i) { for (size_t i = 1; i < n_pset; ++i) {
CLoudnessPreset const& preset = _lp[i]; CLoudnessPreset const& preset = _lp[i];

View File

@ -24,6 +24,7 @@
#include "ardour/dB.h" #include "ardour/dB.h"
#include "ardour/rc_configuration.h" #include "ardour/rc_configuration.h"
#include "gtkmm2ext/colors.h"
#include "gtkmm2ext/utils.h" #include "gtkmm2ext/utils.h"
#include "widgets/ardour_dropdown.h" #include "widgets/ardour_dropdown.h"
@ -184,7 +185,7 @@ public:
return &_cs; return &_cs;
} }
void assign (luabridge::LuaRef* rv) const { void assign (luabridge::LuaRef* rv) const {
uint32_t rgba = ARDOUR_UI_UTILS::gdk_color_to_rgba(_cs.get_color()); uint32_t rgba = Gtkmm2ext::gdk_color_to_rgba(_cs.get_color());
(*rv)[_key] = rgba; (*rv)[_key] = rgba;
} }
protected: protected:

View File

@ -46,6 +46,7 @@
#include "pbd/stateful_diff_command.h" #include "pbd/stateful_diff_command.h"
#include "pbd/unwind.h" #include "pbd/unwind.h"
#include "gtkmm2ext/colors.h"
#include "gtkmm2ext/gtk_ui.h" #include "gtkmm2ext/gtk_ui.h"
#include "gtkmm2ext/utils.h" #include "gtkmm2ext/utils.h"
@ -97,7 +98,6 @@
#include "rgb_macros.h" #include "rgb_macros.h"
#include "selection.h" #include "selection.h"
#include "step_editor.h" #include "step_editor.h"
#include "utils.h"
#include "note_base.h" #include "note_base.h"
#include "ardour/midi_track.h" #include "ardour/midi_track.h"
@ -166,7 +166,7 @@ MidiTimeAxisView::set_route (boost::shared_ptr<Route> rt)
*/ */
RouteTimeAxisView::set_route (rt); RouteTimeAxisView::set_route (rt);
_view->apply_color (ARDOUR_UI_UTILS::gdk_color_to_rgba (color()), StreamView::RegionColor); _view->apply_color (Gtkmm2ext::gdk_color_to_rgba (color()), StreamView::RegionColor);
_note_range_changed_connection.disconnect(); _note_range_changed_connection.disconnect();

View File

@ -298,7 +298,7 @@ PortMatrixColumnLabels::render_bundle_name (
cairo_stroke (cr); cairo_stroke (cr);
Gdk::Color textcolor; Gdk::Color textcolor;
ARDOUR_UI_UTILS::set_color_from_rgba(textcolor, Gtkmm2ext::contrasting_text_color(ARDOUR_UI_UTILS::gdk_color_to_rgba(bg_colour))); Gtkmm2ext::set_color_from_rgba(textcolor, Gtkmm2ext::contrasting_text_color(Gtkmm2ext::gdk_color_to_rgba(bg_colour)));
set_source_rgb (cr, textcolor); set_source_rgb (cr, textcolor);
double const q = ((grid_spacing() * sin (angle())) - _text_height) / 2 + _descender_height; double const q = ((grid_spacing() * sin (angle())) - _text_height) / 2 + _descender_height;
@ -365,7 +365,7 @@ PortMatrixColumnLabels::render_channel_name (
} }
Gdk::Color textcolor; Gdk::Color textcolor;
ARDOUR_UI_UTILS::set_color_from_rgba(textcolor, Gtkmm2ext::contrasting_text_color(ARDOUR_UI_UTILS::gdk_color_to_rgba(bg_colour))); Gtkmm2ext::set_color_from_rgba(textcolor, Gtkmm2ext::contrasting_text_color(Gtkmm2ext::gdk_color_to_rgba(bg_colour)));
set_source_rgb (cr, textcolor); set_source_rgb (cr, textcolor);
double const q = ((grid_spacing() * sin (angle())) - _text_height) / 2 + _descender_height; double const q = ((grid_spacing() * sin (angle())) - _text_height) / 2 + _descender_height;

View File

@ -22,10 +22,11 @@
#include <iostream> #include <iostream>
#include <boost/weak_ptr.hpp> #include <boost/weak_ptr.hpp>
#include <cairo.h> #include <cairo.h>
#include "gtkmm2ext/keyboard.h" #include "gtkmm2ext/keyboard.h"
#include "ardour/bundle.h" #include "ardour/bundle.h"
#include "gtkmm2ext/colors.h" #include "gtkmm2ext/colors.h"
#include "utils.h"
#include "port_matrix_row_labels.h" #include "port_matrix_row_labels.h"
#include "port_matrix_column_labels.h" #include "port_matrix_column_labels.h"
#include "port_matrix.h" #include "port_matrix.h"
@ -250,7 +251,7 @@ PortMatrixRowLabels::render_bundle_name (
double const off = (grid_spacing() - ext.height) / 2; double const off = (grid_spacing() - ext.height) / 2;
Gdk::Color textcolor; Gdk::Color textcolor;
ARDOUR_UI_UTILS::set_color_from_rgba(textcolor, Gtkmm2ext::contrasting_text_color(ARDOUR_UI_UTILS::gdk_color_to_rgba(bg_colour))); Gtkmm2ext::set_color_from_rgba(textcolor, Gtkmm2ext::contrasting_text_color(Gtkmm2ext::gdk_color_to_rgba(bg_colour)));
set_source_rgb (cr, textcolor); set_source_rgb (cr, textcolor);
cairo_move_to (cr, rint (xoff + x + name_pad()), rint (yoff + name_pad() + off)); cairo_move_to (cr, rint (xoff + x + name_pad()), rint (yoff + name_pad() + off));
cairo_show_text (cr, b->name().c_str()); cairo_show_text (cr, b->name().c_str());
@ -286,7 +287,7 @@ PortMatrixRowLabels::render_channel_name (
double const off = (grid_spacing() - ext.height) / 2; double const off = (grid_spacing() - ext.height) / 2;
Gdk::Color textcolor; Gdk::Color textcolor;
ARDOUR_UI_UTILS::set_color_from_rgba(textcolor, Gtkmm2ext::contrasting_text_color(ARDOUR_UI_UTILS::gdk_color_to_rgba(bg_colour))); Gtkmm2ext::set_color_from_rgba(textcolor, Gtkmm2ext::contrasting_text_color(Gtkmm2ext::gdk_color_to_rgba(bg_colour)));
set_source_rgb (cr, textcolor); set_source_rgb (cr, textcolor);
cairo_move_to (cr, rint (port_name_x() + xoff + name_pad()), rint (yoff + name_pad() + off)); cairo_move_to (cr, rint (port_name_x() + xoff + name_pad()), rint (yoff + name_pad() + off));
cairo_show_text (cr, bc.bundle->channel_name(bc.channel).c_str()); cairo_show_text (cr, bc.bundle->channel_name(bc.channel).c_str());

View File

@ -40,6 +40,7 @@
#include "ardour/session.h" #include "ardour/session.h"
#include "ardour/solo_mute_release.h" #include "ardour/solo_mute_release.h"
#include "gtkmm2ext/colors.h"
#include "gtkmm2ext/gtk_ui.h" #include "gtkmm2ext/gtk_ui.h"
#include "gtkmm2ext/keyboard.h" #include "gtkmm2ext/keyboard.h"
#include "gtkmm2ext/utils.h" #include "gtkmm2ext/utils.h"
@ -1464,9 +1465,9 @@ RecorderUI::InputPort::InputPort (string const& name, DataType dt, RecorderUI* p
Gdk::Color bg; Gdk::Color bg;
if (_ioplug) { if (_ioplug) {
ARDOUR_UI_UTILS::set_color_from_rgba (bg, UIConfiguration::instance ().color ("neutral:background")); Gtkmm2ext::set_color_from_rgba (bg, UIConfiguration::instance ().color ("neutral:background"));
} else { } else {
ARDOUR_UI_UTILS::set_color_from_rgba (bg, UIConfiguration::instance ().color ("neutral:background2")); Gtkmm2ext::set_color_from_rgba (bg, UIConfiguration::instance ().color ("neutral:background2"));
} }
_frame.modify_bg (Gtk::STATE_NORMAL, bg); _frame.modify_bg (Gtk::STATE_NORMAL, bg);

View File

@ -37,6 +37,7 @@
#include "ardour/silentfilesource.h" #include "ardour/silentfilesource.h"
#include "ardour/smf_source.h" #include "ardour/smf_source.h"
#include "gtkmm2ext/colors.h"
#include "gtkmm2ext/treeutils.h" #include "gtkmm2ext/treeutils.h"
#include "gtkmm2ext/utils.h" #include "gtkmm2ext/utils.h"
@ -51,7 +52,6 @@
#include "public_editor.h" #include "public_editor.h"
#include "region_list_base.h" #include "region_list_base.h"
#include "ui_config.h" #include "ui_config.h"
#include "utils.h"
#include "pbd/i18n.h" #include "pbd/i18n.h"
@ -508,9 +508,9 @@ RegionListBase::populate_row (boost::shared_ptr<Region> region, TreeModel::Row c
Gdk::Color c; Gdk::Color c;
bool missing_source = boost::dynamic_pointer_cast<SilentFileSource> (region->source ()) != NULL; bool missing_source = boost::dynamic_pointer_cast<SilentFileSource> (region->source ()) != NULL;
if (missing_source) { if (missing_source) {
set_color_from_rgba (c, UIConfiguration::instance ().color ("region list missing source")); Gtkmm2ext::set_color_from_rgba (c, UIConfiguration::instance ().color ("region list missing source"));
} else { } else {
set_color_from_rgba (c, UIConfiguration::instance ().color ("region list whole file")); Gtkmm2ext::set_color_from_rgba (c, UIConfiguration::instance ().color ("region list whole file"));
} }
row[_columns.color_] = c; row[_columns.color_] = c;
} }

View File

@ -28,15 +28,15 @@
#include <gtkmm/stock.h> #include <gtkmm/stock.h>
#include <gtkmm/messagedialog.h> #include <gtkmm/messagedialog.h>
#include "gtkmm2ext/colors.h"
#include "route_group_dialog.h" #include "route_group_dialog.h"
#include "group_tabs.h" #include "group_tabs.h"
#include "utils.h"
#include "pbd/i18n.h" #include "pbd/i18n.h"
using namespace Gtk; using namespace Gtk;
using namespace ARDOUR; using namespace ARDOUR;
using namespace ARDOUR_UI_UTILS;
using namespace std; using namespace std;
using namespace PBD; using namespace PBD;
@ -92,7 +92,7 @@ RouteGroupDialog::RouteGroupDialog (RouteGroup* g, bool creating_new)
_active.set_active (_group->is_active ()); _active.set_active (_group->is_active ());
Gdk::Color c; Gdk::Color c;
set_color_from_rgba (c, GroupTabs::group_color (_group)); Gtkmm2ext::set_color_from_rgba (c, GroupTabs::group_color (_group));
_color.set_color (c); _color.set_color (c);
VBox* options_box = manage (new VBox); VBox* options_box = manage (new VBox);
@ -220,7 +220,7 @@ RouteGroupDialog::update ()
_group->apply_changes (plist); _group->apply_changes (plist);
GroupTabs::set_group_color (_group, gdk_color_to_rgba (_color.get_color ())); GroupTabs::set_group_color (_group, Gtkmm2ext::gdk_color_to_rgba (_color.get_color ()));
} }
void void

View File

@ -59,6 +59,7 @@
#include "ardour/solo_mute_release.h" #include "ardour/solo_mute_release.h"
#include "ardour/template_utils.h" #include "ardour/template_utils.h"
#include "gtkmm2ext/colors.h"
#include "gtkmm2ext/gtk_ui.h" #include "gtkmm2ext/gtk_ui.h"
#include "gtkmm2ext/doi.h" #include "gtkmm2ext/doi.h"
#include "gtkmm2ext/gtk_ui.h" #include "gtkmm2ext/gtk_ui.h"
@ -88,7 +89,6 @@
#include "save_template_dialog.h" #include "save_template_dialog.h"
#include "timers.h" #include "timers.h"
#include "ui_config.h" #include "ui_config.h"
#include "utils.h"
#include "pbd/i18n.h" #include "pbd/i18n.h"
@ -2239,9 +2239,9 @@ RouteUI::route_color () const
string p; string p;
if (g && g->is_color()) { if (g && g->is_color()) {
set_color_from_rgba (c, GroupTabs::group_color (g)); Gtkmm2ext::set_color_from_rgba (c, GroupTabs::group_color (g));
} else { } else {
set_color_from_rgba (c, _route->presentation_info().color()); Gtkmm2ext::set_color_from_rgba (c, _route->presentation_info().color());
} }
return c; return c;

View File

@ -28,6 +28,7 @@
#include <gtkmm.h> #include <gtkmm.h>
#include <gtkmm2ext/colors.h>
#include <gtkmm2ext/gtk_ui.h> #include <gtkmm2ext/gtk_ui.h>
#include <gtkmm2ext/utils.h> #include <gtkmm2ext/utils.h>
@ -51,13 +52,11 @@
#include "rgb_macros.h" #include "rgb_macros.h"
#include "gui_thread.h" #include "gui_thread.h"
#include "ui_config.h" #include "ui_config.h"
#include "utils.h"
#include "pbd/i18n.h" #include "pbd/i18n.h"
using namespace std; using namespace std;
using namespace ARDOUR; using namespace ARDOUR;
using namespace ARDOUR_UI_UTILS;
using namespace PBD; using namespace PBD;
using namespace Editing; using namespace Editing;
@ -343,7 +342,7 @@ StreamView::playlist_switched (boost::weak_ptr<Track> wtr)
void void
StreamView::apply_color (Gdk::Color const& c, ColorTarget target) StreamView::apply_color (Gdk::Color const& c, ColorTarget target)
{ {
return apply_color (gdk_color_to_rgba (c), target); return apply_color (Gtkmm2ext::gdk_color_to_rgba (c), target);
} }
void void

View File

@ -18,15 +18,15 @@
#include "pbd/compose.h" #include "pbd/compose.h"
#include "gtkmm2ext/colors.h"
#include "public_editor.h" #include "public_editor.h"
#include "stripable_colorpicker.h" #include "stripable_colorpicker.h"
#include "ui_config.h" #include "ui_config.h"
#include "utils.h"
#include "pbd/i18n.h" #include "pbd/i18n.h"
using namespace Gtk; using namespace Gtk;
using namespace ARDOUR_UI_UTILS;
bool StripableColorDialog::palette_initialized = false; bool StripableColorDialog::palette_initialized = false;
Gtk::ColorSelection::SlotChangePaletteHook StripableColorDialog::gtk_palette_changed_hook; Gtk::ColorSelection::SlotChangePaletteHook StripableColorDialog::gtk_palette_changed_hook;
@ -113,7 +113,7 @@ StripableColorDialog::popup (const std::string& name, uint32_t color)
get_color_selection()->set_has_opacity_control (false); get_color_selection()->set_has_opacity_control (false);
get_color_selection()->set_has_palette (true); get_color_selection()->set_has_palette (true);
Gdk::Color c = gdk_color_from_rgba (_initial_color); Gdk::Color c = Gtkmm2ext::gdk_color_from_rgba (_initial_color);
get_color_selection()->set_previous_color (c); get_color_selection()->set_previous_color (c);
get_color_selection()->set_current_color (c); get_color_selection()->set_current_color (c);
@ -147,13 +147,13 @@ StripableColorDialog::finish_color_edit (int response)
ARDOUR::RouteList rl = PublicEditor::instance().get_selection().tracks.routelist(); ARDOUR::RouteList rl = PublicEditor::instance().get_selection().tracks.routelist();
if (response == RESPONSE_OK) { if (response == RESPONSE_OK) {
ColorChanged (gdk_color_to_rgba (get_color_selection()->get_current_color())); /* EMIT SIGNAL */ ColorChanged (Gtkmm2ext::gdk_color_to_rgba (get_color_selection()->get_current_color())); /* EMIT SIGNAL */
} }
if (_stripable && response == RESPONSE_OK) { if (_stripable && response == RESPONSE_OK) {
for (ARDOUR::RouteList::iterator i = rl.begin(); i != rl.end(); ++i) { for (ARDOUR::RouteList::iterator i = rl.begin(); i != rl.end(); ++i) {
(*i)->presentation_info().set_color (gdk_color_to_rgba (get_color_selection()->get_current_color())); (*i)->presentation_info().set_color (Gtkmm2ext::gdk_color_to_rgba (get_color_selection()->get_current_color()));
} }
_stripable->presentation_info().set_color (gdk_color_to_rgba (get_color_selection()->get_current_color())); _stripable->presentation_info().set_color (Gtkmm2ext::gdk_color_to_rgba (get_color_selection()->get_current_color()));
} else if (_stripable) { } else if (_stripable) {
_stripable->presentation_info().set_color (_initial_color); _stripable->presentation_info().set_color (_initial_color);
} }
@ -164,7 +164,7 @@ void
StripableColorDialog::color_changed () StripableColorDialog::color_changed ()
{ {
if (_stripable) { if (_stripable) {
_stripable->presentation_info().set_color (gdk_color_to_rgba (get_color_selection()->get_current_color())); _stripable->presentation_info().set_color (Gtkmm2ext::gdk_color_to_rgba (get_color_selection()->get_current_color()));
} }
} }
@ -177,7 +177,7 @@ ArdourColorButton::ArdourColorButton ()
void void
ArdourColorButton::on_clicked () ArdourColorButton::on_clicked ()
{ {
_color_picker.popup ("", gdk_color_to_rgba (get_color ())); _color_picker.popup ("", Gtkmm2ext::gdk_color_to_rgba (get_color ()));
_color_picker.get_window ()->set_transient_for (get_window ()); _color_picker.get_window ()->set_transient_for (get_window ());
} }
@ -185,7 +185,7 @@ void
ArdourColorButton::color_selected (uint32_t color) ArdourColorButton::color_selected (uint32_t color)
{ {
Gdk::Color c; Gdk::Color c;
set_color_from_rgba (c, color); Gtkmm2ext::set_color_from_rgba (c, color);
set_color (c); set_color (c);
g_signal_emit_by_name (GTK_WIDGET(gobj()), "color-set", 0); g_signal_emit_by_name (GTK_WIDGET(gobj()), "color-set", 0);
} }

View File

@ -30,6 +30,7 @@
#include "widgets/tooltips.h" #include "widgets/tooltips.h"
#include "widgets/ardour_icon.h" #include "widgets/ardour_icon.h"
#include "gtkmm2ext/colors.h"
#include "gtkmm2ext/utils.h" #include "gtkmm2ext/utils.h"
#include "gtkmm2ext/gui_thread.h" #include "gtkmm2ext/gui_thread.h"
@ -37,7 +38,6 @@
#include "floating_text_entry.h" #include "floating_text_entry.h"
#include "transport_masters_dialog.h" #include "transport_masters_dialog.h"
#include "ui_config.h" #include "ui_config.h"
#include "utils.h"
#include "pbd/i18n.h" #include "pbd/i18n.h"
@ -331,8 +331,8 @@ TransportMastersWidget::Row::Row (TransportMastersWidget& p)
uint32_t bg = UIConfigurationBase::instance().color ("clock: background"); uint32_t bg = UIConfigurationBase::instance().color ("clock: background");
uint32_t fg = UIConfigurationBase::instance().color ("clock: text"); uint32_t fg = UIConfigurationBase::instance().color ("clock: text");
Gdk::Color bg_color = ARDOUR_UI_UTILS::gdk_color_from_rgba (bg); Gdk::Color bg_color = Gtkmm2ext::gdk_color_from_rgba (bg);
Gdk::Color fg_color = ARDOUR_UI_UTILS::gdk_color_from_rgba (fg); Gdk::Color fg_color = Gtkmm2ext::gdk_color_from_rgba (fg);
current_box.modify_bg (Gtk::STATE_NORMAL, bg_color); current_box.modify_bg (Gtk::STATE_NORMAL, bg_color);
current.modify_fg (Gtk::STATE_NORMAL, fg_color); current.modify_fg (Gtk::STATE_NORMAL, fg_color);

View File

@ -43,7 +43,6 @@
#include "trigger_master.h" #include "trigger_master.h"
#include "trigger_ui.h" #include "trigger_ui.h"
#include "ui_config.h" #include "ui_config.h"
#include "utils.h"
#include "pbd/i18n.h" #include "pbd/i18n.h"
@ -376,7 +375,7 @@ TriggerMaster::set_all_colors ()
_color_dialog.get_ok_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (_color_dialog, &Gtk::Dialog::response), Gtk::RESPONSE_ACCEPT)); _color_dialog.get_ok_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (_color_dialog, &Gtk::Dialog::response), Gtk::RESPONSE_ACCEPT));
_color_dialog.get_cancel_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (_color_dialog, &Gtk::Dialog::response), Gtk::RESPONSE_CANCEL)); _color_dialog.get_cancel_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (_color_dialog, &Gtk::Dialog::response), Gtk::RESPONSE_CANCEL));
Gdk::Color c = ARDOUR_UI_UTILS::gdk_color_from_rgba(0xBEBEBEFF); Gdk::Color c = Gtkmm2ext::gdk_color_from_rgba(0xBEBEBEFF);
_color_dialog.get_color_selection()->set_previous_color (c); _color_dialog.get_color_selection()->set_previous_color (c);
_color_dialog.get_color_selection()->set_current_color (c); _color_dialog.get_color_selection()->set_current_color (c);
@ -384,7 +383,7 @@ TriggerMaster::set_all_colors ()
switch (_color_dialog.run()) { switch (_color_dialog.run()) {
case Gtk::RESPONSE_ACCEPT: { case Gtk::RESPONSE_ACCEPT: {
c = _color_dialog.get_color_selection()->get_current_color(); c = _color_dialog.get_color_selection()->get_current_color();
color_t ct = ARDOUR_UI_UTILS::gdk_color_to_rgba(c); color_t ct = Gtkmm2ext::gdk_color_to_rgba(c);
for (int n = 0; n < default_triggers_per_box; n++) { for (int n = 0; n < default_triggers_per_box; n++) {
_triggerbox->trigger (n)->set_color(ct); _triggerbox->trigger (n)->set_color(ct);
} }

View File

@ -37,6 +37,8 @@
#include "ardour/region.h" #include "ardour/region.h"
#include "ardour/triggerbox.h" #include "ardour/triggerbox.h"
#include "gtkmm2ext/colors.h"
#include "slot_properties_box.h" #include "slot_properties_box.h"
#include "ardour_ui.h" #include "ardour_ui.h"
@ -183,7 +185,7 @@ TriggerUI::choose_color ()
_color_dialog.get_ok_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (_color_dialog, &Gtk::Dialog::response), Gtk::RESPONSE_ACCEPT)); _color_dialog.get_ok_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (_color_dialog, &Gtk::Dialog::response), Gtk::RESPONSE_ACCEPT));
_color_dialog.get_cancel_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (_color_dialog, &Gtk::Dialog::response), Gtk::RESPONSE_CANCEL)); _color_dialog.get_cancel_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (_color_dialog, &Gtk::Dialog::response), Gtk::RESPONSE_CANCEL));
Gdk::Color c = ARDOUR_UI_UTILS::gdk_color_from_rgba(trigger()->color()); Gdk::Color c = Gtkmm2ext::gdk_color_from_rgba(trigger()->color());
_color_dialog.get_color_selection()->set_previous_color (c); _color_dialog.get_color_selection()->set_previous_color (c);
_color_dialog.get_color_selection()->set_current_color (c); _color_dialog.get_color_selection()->set_current_color (c);
@ -191,7 +193,7 @@ TriggerUI::choose_color ()
switch (_color_dialog.run()) { switch (_color_dialog.run()) {
case Gtk::RESPONSE_ACCEPT: { case Gtk::RESPONSE_ACCEPT: {
c = _color_dialog.get_color_selection()->get_current_color(); c = _color_dialog.get_color_selection()->get_current_color();
color_t ct = ARDOUR_UI_UTILS::gdk_color_to_rgba(c); color_t ct = Gtkmm2ext::gdk_color_to_rgba(c);
trigger()->set_color(ct); trigger()->set_color(ct);
} break; } break;
default: default:

View File

@ -70,7 +70,6 @@
#include "keyboard.h" #include "keyboard.h"
#include "utils.h" #include "utils.h"
#include "pbd/i18n.h" #include "pbd/i18n.h"
#include "rgb_macros.h"
#include "gui_thread.h" #include "gui_thread.h"
#include "ui_config.h" #include "ui_config.h"
#include "ardour_dialog.h" #include "ardour_dialog.h"
@ -314,55 +313,6 @@ ARDOUR_UI_UTILS::get_font_for_style (string widgetname)
return Pango::FontDescription (pfd); /* make a copy */ return Pango::FontDescription (pfd); /* make a copy */
} }
Gdk::Color
ARDOUR_UI_UTILS::gdk_color_from_rgb (uint32_t rgb)
{
Gdk::Color c;
set_color_from_rgb (c, rgb);
return c;
}
Gdk::Color
ARDOUR_UI_UTILS::gdk_color_from_rgba (uint32_t rgba)
{
Gdk::Color c;
set_color_from_rgb (c, rgba >> 8);
return c;
}
void
ARDOUR_UI_UTILS::set_color_from_rgb (Gdk::Color& c, uint32_t rgb)
{
/* Gdk::Color color ranges are 16 bit, so scale from 8 bit by
multiplying by 256.
*/
c.set_rgb ((rgb >> 16)*256, ((rgb & 0xff00) >> 8)*256, (rgb & 0xff)*256);
}
void
ARDOUR_UI_UTILS::set_color_from_rgba (Gdk::Color& c, uint32_t rgba)
{
/* Gdk::Color color ranges are 16 bit, so scale from 8 bit by
multiplying by 256.
*/
c.set_rgb ((rgba >> 24)*256, ((rgba & 0xff0000) >> 16)*256, ((rgba & 0xff00) >> 8)*256);
}
uint32_t
ARDOUR_UI_UTILS::gdk_color_to_rgba (Gdk::Color const& c)
{
/* since alpha value is not available from a Gdk::Color, it is
hardcoded as 0xff (aka 255 or 1.0)
*/
const uint32_t r = c.get_red_p () * 255.0;
const uint32_t g = c.get_green_p () * 255.0;
const uint32_t b = c.get_blue_p () * 255.0;
const uint32_t a = 0xff;
return RGBA_TO_UINT (r,g,b,a);
}
bool bool
ARDOUR_UI_UTILS::relay_key_press (GdkEventKey* ev, Gtk::Window* win) ARDOUR_UI_UTILS::relay_key_press (GdkEventKey* ev, Gtk::Window* win)
{ {

View File

@ -79,13 +79,6 @@ Pango::FontDescription get_font_for_style (std::string widgetname);
void decorate (Gtk::Window& w, Gdk::WMDecoration d); void decorate (Gtk::Window& w, Gdk::WMDecoration d);
Gdk::Color gdk_color_from_rgb (uint32_t);
Gdk::Color gdk_color_from_rgba (uint32_t);
uint32_t gdk_color_to_rgba (Gdk::Color const&);
void set_color_from_rgb (Gdk::Color&, uint32_t);
void set_color_from_rgba (Gdk::Color&, uint32_t);
bool relay_key_press (GdkEventKey* ev, Gtk::Window* win); bool relay_key_press (GdkEventKey* ev, Gtk::Window* win);
bool key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev); bool key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev);
bool emulate_key_event (unsigned int); bool emulate_key_event (unsigned int);

View File

@ -27,6 +27,7 @@
#include "ardour/vca.h" #include "ardour/vca.h"
#include "ardour/vca_manager.h" #include "ardour/vca_manager.h"
#include "gtkmm2ext/colors.h"
#include "gtkmm2ext/doi.h" #include "gtkmm2ext/doi.h"
#include "gtkmm2ext/keyboard.h" #include "gtkmm2ext/keyboard.h"
#include "widgets/tooltips.h" #include "widgets/tooltips.h"
@ -37,7 +38,6 @@
#include "gui_thread.h" #include "gui_thread.h"
#include "mixer_ui.h" #include "mixer_ui.h"
#include "ui_config.h" #include "ui_config.h"
#include "utils.h"
#include "vca_master_strip.h" #include "vca_master_strip.h"
#include "pbd/i18n.h" #include "pbd/i18n.h"
@ -62,7 +62,7 @@ VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr<VCA> v)
/* set color for the VCA, if not already done. */ /* set color for the VCA, if not already done. */
if (!_vca->presentation_info().color_set()) { if (!_vca->presentation_info().color_set()) {
_vca->presentation_info().set_color (ARDOUR_UI_UTILS::gdk_color_to_rgba (unique_random_color())); _vca->presentation_info().set_color (Gtkmm2ext::gdk_color_to_rgba (unique_random_color()));
} }
control_slave_ui.set_stripable (boost::dynamic_pointer_cast<Stripable> (v)); control_slave_ui.set_stripable (boost::dynamic_pointer_cast<Stripable> (v));
@ -554,7 +554,7 @@ VCAMasterStrip::drop_all_slaves ()
Gdk::Color Gdk::Color
VCAMasterStrip::color () const VCAMasterStrip::color () const
{ {
return ARDOUR_UI_UTILS::gdk_color_from_rgba (_vca->presentation_info().color ()); return Gtkmm2ext::gdk_color_from_rgba (_vca->presentation_info().color ());
} }
string string

View File

@ -350,7 +350,7 @@ VCATimeAxisView::stripable () const
Gdk::Color Gdk::Color
VCATimeAxisView::color () const VCATimeAxisView::color () const
{ {
return ARDOUR_UI_UTILS::gdk_color_from_rgb (_vca->presentation_info().color ()); return Gtkmm2ext::gdk_color_from_rgb (_vca->presentation_info().color ());
} }
void void