add new CairoWidget-derived class that does nothing but shown an ArdourIcon.

Somewhat necessary by placement of ArdourButton class in directory heirarchy. But these are also
much simpler
This commit is contained in:
Paul Davis 2015-07-21 22:36:46 -04:00
parent 434ef34229
commit c06c2c29db
2 changed files with 100 additions and 0 deletions

View file

@ -0,0 +1,51 @@
/*
Copyright (C) 2015 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 <iostream>
#include "gtkmm2ext/cairo_icon.h"
using namespace Gtkmm2ext;
CairoIcon::CairoIcon (ArdourIcon::Icon t, uint32_t foreground_color)
: icon_type (t)
, fg (foreground_color)
{
set_draw_background (false);
set_widget_prelight (false);
}
CairoIcon::~CairoIcon ()
{
}
void
CairoIcon::set_fg (uint32_t color)
{
fg = color;
queue_draw ();
}
void
CairoIcon::render (cairo_t* cr , cairo_rectangle_t* area)
{
int width = get_width();
int height = get_height ();
ArdourIcon::render (cr, icon_type, width, height, Off, fg);
}

View file

@ -0,0 +1,49 @@
/*
Copyright (C) 2015 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.
*/
#ifndef __gtk2_ardour_cairo_icon_h__
#define __gtk2_ardour_cairo_icon_h__
#include "gtkmm2ext/visibility.h"
#include "gtkmm2ext/cairo_widget.h"
#include "gtkmm2ext/ardour_icon.h"
/** A parent class for icons that are rendered using Cairo but need to be
* widgets for event handling
*/
namespace Gtkmm2ext {
class LIBGTKMM2EXT_API CairoIcon : public CairoWidget
{
public:
CairoIcon (Gtkmm2ext::ArdourIcon::Icon, uint32_t fg = 0x000000ff);
virtual ~CairoIcon ();
void render (cairo_t *, cairo_rectangle_t*);
void set_fg (uint32_t fg);
private:
ArdourIcon::Icon icon_type;
uint32_t fg;
};
}
#endif /* __gtk2_ardour_cairo_icon_h__ */