2021-12-04 09:04:36 -05:00
|
|
|
/*
|
|
|
|
Copyright (C) 2019 Paul Davis
|
|
|
|
Author: Ben Loftis <ben@harrisonconsoles.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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <cairomm/context.h>
|
|
|
|
|
|
|
|
#include <pangomm/layout.h>
|
|
|
|
|
|
|
|
#include "pbd/compose.h"
|
|
|
|
|
|
|
|
#include "gtkmm2ext/keyboard.h"
|
|
|
|
#include "gtkmm2ext/utils.h"
|
|
|
|
|
|
|
|
#include "canvas/canvas.h"
|
|
|
|
#include "canvas/debug.h"
|
|
|
|
#include "canvas/utils.h"
|
|
|
|
|
|
|
|
#include "actions.h"
|
|
|
|
#include "gui_thread.h"
|
|
|
|
#include "timers.h"
|
2021-12-17 09:30:14 -05:00
|
|
|
#include "utils.h"
|
2021-12-04 09:04:36 -05:00
|
|
|
|
|
|
|
#include "fitted_canvas_widget.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ArdourCanvas;
|
|
|
|
using namespace Gtk;
|
|
|
|
using namespace Gtkmm2ext;
|
|
|
|
using namespace ARDOUR_UI_UTILS;
|
|
|
|
|
2021-12-17 09:30:14 -05:00
|
|
|
/** a gtk widget with fixed-size semantics */
|
2021-12-04 09:04:36 -05:00
|
|
|
FittedCanvasWidget::FittedCanvasWidget (float w, float h, bool follow_scale)
|
|
|
|
{
|
2021-12-17 09:30:14 -05:00
|
|
|
_nominal_width = w;
|
2021-12-04 09:04:36 -05:00
|
|
|
_nominal_height = h;
|
2021-12-17 09:30:14 -05:00
|
|
|
_follow_scale = follow_scale;
|
|
|
|
|
|
|
|
/* our rendering speed suffers if we re-render knobs simply because
|
|
|
|
* they are in-between 2 meters that got invalidated (for example)
|
|
|
|
*/
|
|
|
|
// set_single_exposure(false);
|
|
|
|
#ifdef __APPLE__
|
|
|
|
// use_intermediate_surface (false);
|
|
|
|
#endif
|
2021-12-04 09:04:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FittedCanvasWidget::on_size_request (Gtk::Requisition* req)
|
|
|
|
{
|
2021-12-17 09:30:14 -05:00
|
|
|
const double scale = _follow_scale ? UIConfiguration::instance ().get_ui_scale () : 1;
|
|
|
|
if (_nominal_width > 0) {
|
|
|
|
req->width = _nominal_width * scale;
|
2021-12-04 09:04:36 -05:00
|
|
|
}
|
2021-12-17 09:30:14 -05:00
|
|
|
if (_nominal_height > 0) {
|
|
|
|
req->height = _nominal_height * scale;
|
2021-12-04 09:04:36 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FittedCanvasWidget::on_size_allocate (Gtk::Allocation& alloc)
|
|
|
|
{
|
2021-12-17 09:30:14 -05:00
|
|
|
GtkCanvas::on_size_allocate (alloc);
|
2021-12-16 20:54:32 -05:00
|
|
|
repeat_size_allocation ();
|
|
|
|
}
|
2021-12-04 09:04:36 -05:00
|
|
|
|
2021-12-16 20:54:32 -05:00
|
|
|
void
|
|
|
|
FittedCanvasWidget::repeat_size_allocation ()
|
|
|
|
{
|
2021-12-17 09:30:14 -05:00
|
|
|
if (_root.items ().empty ()) {
|
|
|
|
return;
|
2021-12-04 09:04:36 -05:00
|
|
|
}
|
|
|
|
|
2021-12-17 09:30:14 -05:00
|
|
|
Gtk::Allocation a = get_allocation ();
|
|
|
|
_root.items ().front ()->size_allocate (ArdourCanvas::Rect (0, 0, a.get_width (), a.get_height ()));
|
|
|
|
}
|