2014-05-15 08:25:23 -05:00
|
|
|
/*
|
|
|
|
|
Copyright (C) 2010 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 "gtkmm2ext/utils.h"
|
|
|
|
|
#include "gtkmm2ext/rgb_macros.h"
|
|
|
|
|
#include "gtkmm2ext/gui_thread.h"
|
|
|
|
|
|
|
|
|
|
#include "ardour/rc_configuration.h" // for widget prelight preference
|
|
|
|
|
|
|
|
|
|
#include "waves_icon_button.h"
|
|
|
|
|
#include "ardour_ui.h"
|
|
|
|
|
#include "global_signals.h"
|
|
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
|
|
#define REFLECTION_HEIGHT 2
|
|
|
|
|
|
|
|
|
|
using namespace Gdk;
|
|
|
|
|
using namespace Gtk;
|
|
|
|
|
using namespace Glib;
|
|
|
|
|
using namespace PBD;
|
|
|
|
|
using std::max;
|
|
|
|
|
using std::min;
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
2014-09-03 09:46:26 +03:00
|
|
|
WavesIconButton::WavesIconButton (const std::string& title)
|
|
|
|
|
: WavesButton (title)
|
2014-05-15 08:25:23 -05:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-03 09:46:26 +03:00
|
|
|
WavesIconButton::~WavesIconButton ()
|
2014-05-15 08:25:23 -05:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2014-08-17 14:40:16 -04:00
|
|
|
WavesIconButton::render (cairo_t* cr, cairo_rectangle_t*)
|
2014-05-15 08:25:23 -05:00
|
|
|
{
|
2014-07-08 12:12:12 +03:00
|
|
|
Glib::RefPtr<Gdk::Pixbuf> pixbuf = ((CairoWidget::active_state() == Gtkmm2ext::ImplicitActive) ? _implicit_active_pixbuf : Glib::RefPtr<Gdk::Pixbuf>(0));
|
|
|
|
|
|
|
|
|
|
if (pixbuf == 0) {
|
|
|
|
|
pixbuf = (get_state() == Gtk::STATE_INSENSITIVE) ?
|
2014-07-10 13:01:48 +03:00
|
|
|
(_inactive_pixbuf ? _inactive_pixbuf : _normal_pixbuf) :
|
2014-10-02 00:24:57 +03:00
|
|
|
(get_active() ? (_active_pixbuf ? _active_pixbuf : _normal_pixbuf) :
|
|
|
|
|
_normal_pixbuf);
|
2014-07-08 12:12:12 +03:00
|
|
|
}
|
2014-05-15 08:25:23 -05:00
|
|
|
|
|
|
|
|
// pixbuf, if any
|
|
|
|
|
if (pixbuf) {
|
2014-07-09 13:05:09 +03:00
|
|
|
double x = (get_width() - pixbuf->get_width())/2.0;
|
|
|
|
|
double y = (get_height() - pixbuf->get_height())/2.0;
|
2014-05-15 08:25:23 -05:00
|
|
|
|
|
|
|
|
cairo_rectangle (cr, x, y, pixbuf->get_width(), pixbuf->get_height());
|
|
|
|
|
gdk_cairo_set_source_pixbuf (cr, pixbuf->gobj(), x, y);
|
|
|
|
|
cairo_fill (cr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
WavesIconButton::set_normal_image (const RefPtr<Gdk::Pixbuf>& img)
|
|
|
|
|
{
|
|
|
|
|
_normal_pixbuf = img;
|
|
|
|
|
queue_draw ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
WavesIconButton::set_active_image (const RefPtr<Gdk::Pixbuf>& img)
|
|
|
|
|
{
|
|
|
|
|
_active_pixbuf = img;
|
|
|
|
|
queue_draw ();
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-08 12:12:12 +03:00
|
|
|
void
|
|
|
|
|
WavesIconButton::set_implicit_active_image (const RefPtr<Gdk::Pixbuf>& img)
|
|
|
|
|
{
|
|
|
|
|
_implicit_active_pixbuf = img;
|
|
|
|
|
queue_draw ();
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-15 08:25:23 -05:00
|
|
|
void
|
|
|
|
|
WavesIconButton::set_inactive_image (const RefPtr<Gdk::Pixbuf>& img)
|
|
|
|
|
{
|
|
|
|
|
_inactive_pixbuf = img;
|
|
|
|
|
queue_draw ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
WavesIconButton::set_prelight_image (const RefPtr<Gdk::Pixbuf>& img)
|
|
|
|
|
{
|
|
|
|
|
_prelight_pixbuf = img;
|
|
|
|
|
queue_draw ();
|
|
|
|
|
}
|