From 863f18adc6f9297c7226c6e31f8dfd979f244e62 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 8 Apr 2024 11:12:10 -0600 Subject: [PATCH] basics of the livetrax TC widget --- gtk2_ardour/ardour_ui_dependents.cc | 5 ++ gtk2_ardour/livetrax_tc_widget.cc | 92 +++++++++++++++++++++++++++++ gtk2_ardour/livetrax_tc_widget.h | 40 +++++++++++++ gtk2_ardour/wscript | 1 + 4 files changed, 138 insertions(+) create mode 100644 gtk2_ardour/livetrax_tc_widget.cc create mode 100644 gtk2_ardour/livetrax_tc_widget.h diff --git a/gtk2_ardour/ardour_ui_dependents.cc b/gtk2_ardour/ardour_ui_dependents.cc index 97cb83b8c6..b11ff5ce61 100644 --- a/gtk2_ardour/ardour_ui_dependents.cc +++ b/gtk2_ardour/ardour_ui_dependents.cc @@ -51,6 +51,7 @@ #include "luainstance.h" #include "luawindow.h" #include "livetrax_meters.h" +#include "livetrax_tc_widget.h" #include "main_clock.h" #include "meterbridge.h" #include "mixer_ui.h" @@ -429,6 +430,10 @@ ARDOUR_UI::livetrax_setup_windows () vb->pack_start (*livetrax_sr_button, false, false); livetrax_top_bar.pack_start (*vb, false, false); + CairoWidget* cw = new LiveTraxTCWidget; + cw->show (); + livetrax_top_bar.pack_start (*cw, false, false); + vb = manage (new VBox); vb->pack_start (*ev_dsp, true, true); vb->pack_start (disk_space_label, true, true); diff --git a/gtk2_ardour/livetrax_tc_widget.cc b/gtk2_ardour/livetrax_tc_widget.cc new file mode 100644 index 0000000000..3a33dfb0df --- /dev/null +++ b/gtk2_ardour/livetrax_tc_widget.cc @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2024 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include + +#include "livetrax_tc_widget.h" +#include "ui_config.h" + +LiveTraxTCWidget::LiveTraxTCWidget() +{ + Gtkmm2ext::Color c; + c = UIConfiguration::instance().color ("widget:blue"); + Gtkmm2ext::color_to_rgba (c, bg_r, bg_g, bg_b, bg_a); + c = UIConfiguration::instance().color ("neutral:foreground"); + Gtkmm2ext::color_to_rgba (c, txt_r, txt_g, txt_b, txt_a); + c = UIConfiguration::instance().color ("theme:bg1"); + Gtkmm2ext::color_to_rgba (c, fg_r, fg_g, fg_b, fg_a); +} + +bool +LiveTraxTCWidget::on_button_release_event (GdkEventButton* ev) +{ + std::cerr << "here\n"; + return true; +} + +void +LiveTraxTCWidget::render (Cairo::RefPtr const & context, cairo_rectangle_t*) +{ + /* draw the background */ + context->set_source_rgba (bg_r, bg_g, bg_b, 1.); + context->rectangle (0, 0, get_width(), get_height()); + context->fill (); + + Glib::RefPtr layout = Pango::Layout::create (context); + layout->set_text ("TC\nSource"); + layout->set_font_description (UIConfiguration::instance().get_NormalBoldFont()); + context->move_to (get_width() / 2.0 + 10., 10.); + context->set_source_rgba (txt_r, txt_g, txt_b, 1.); + layout->show_in_cairo_context (context); + + double rect_width = (get_width() / 2.); + double rect_height = (get_height() - 3.) / 2.; + + + context->set_source_rgba (fg_r, fg_g, fg_b, 1.); + context->rectangle (1., 1., rect_width, rect_height); + context->fill (); + + context->set_source_rgba (fg_r, fg_g, fg_b, 1.); + context->rectangle (1., 2 + rect_height, rect_width, rect_height); + context->fill (); + + layout->set_text ("LTC"); + layout->set_font_description (UIConfiguration::instance().get_NormalFont()); + context->move_to (4., 3.); // XXXX need to adjust by + text height/2 + context->set_source_rgba (txt_r, txt_g, txt_b, 1.); + layout->show_in_cairo_context (context); + + layout->set_text ("25 FPS"); + layout->set_font_description (UIConfiguration::instance().get_NormalFont()); + context->move_to (4., 3. + rect_height); // XXXX need to adjust by + text height/2 + context->set_source_rgba (txt_r, txt_g, txt_b, 1.); + layout->show_in_cairo_context (context); +} + +void +LiveTraxTCWidget::parameter_changed (std::string const & param) +{ +} + +void +LiveTraxTCWidget::on_size_request (Gtk::Requisition* r) +{ + r->width = 150; + r->height = -1; +} diff --git a/gtk2_ardour/livetrax_tc_widget.h b/gtk2_ardour/livetrax_tc_widget.h new file mode 100644 index 0000000000..558822d199 --- /dev/null +++ b/gtk2_ardour/livetrax_tc_widget.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2024 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __gtk2_ardour_livetrax_tc_widget_h__ +#define __gtk2_ardour_livetrax_tc_widget_h__ + +#include "gtkmm2ext/cairo_widget.h" + +class LiveTraxTCWidget : public CairoWidget +{ + public: + LiveTraxTCWidget (); + + bool on_button_release_event (GdkEventButton*); + void render (Cairo::RefPtr const&, cairo_rectangle_t*); + void parameter_changed (std::string const &); + void on_size_request (Gtk::Requisition*); + + private: + double bg_r, bg_g, bg_b, bg_a; + double fg_r, fg_g, fg_b, fg_a; + double txt_r, txt_g, txt_b, txt_a; +}; + +#endif /* __gtk2_ardour_livetrax_tc_widget_h__ */ diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 9fc55ddce1..92630085a7 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -145,6 +145,7 @@ gtk2_ardour_sources = [ 'library_download_dialog.cc', 'livetrax_add_track_dialog.cc', 'livetrax_meters.cc', + 'livetrax_tc_widget.cc', 'location_ui.cc', 'loudness_dialog.cc', 'loudness_settings.cc',