mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-07 14:15:46 +01:00
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:
parent
434ef34229
commit
c06c2c29db
2 changed files with 100 additions and 0 deletions
51
libs/gtkmm2ext/cairo_icon.cc
Normal file
51
libs/gtkmm2ext/cairo_icon.cc
Normal 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);
|
||||
}
|
||||
49
libs/gtkmm2ext/gtkmm2ext/cairo_icon.h
Normal file
49
libs/gtkmm2ext/gtkmm2ext/cairo_icon.h
Normal 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__ */
|
||||
Loading…
Add table
Add a link
Reference in a new issue