summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-07-21 22:36:46 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2016-02-22 15:31:22 -0500
commitc06c2c29db73d4cae8a675165616cf879f1758b0 (patch)
tree6ed1e71ef364d6a9b995d3d98ee4883aea9241c7
parent434ef342297ba9971b2a02a961109d3078e97fa6 (diff)
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
-rw-r--r--libs/gtkmm2ext/cairo_icon.cc51
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/cairo_icon.h49
2 files changed, 100 insertions, 0 deletions
diff --git a/libs/gtkmm2ext/cairo_icon.cc b/libs/gtkmm2ext/cairo_icon.cc
new file mode 100644
index 0000000000..1bbf081cdd
--- /dev/null
+++ b/libs/gtkmm2ext/cairo_icon.cc
@@ -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);
+}
diff --git a/libs/gtkmm2ext/gtkmm2ext/cairo_icon.h b/libs/gtkmm2ext/gtkmm2ext/cairo_icon.h
new file mode 100644
index 0000000000..7be75861c7
--- /dev/null
+++ b/libs/gtkmm2ext/gtkmm2ext/cairo_icon.h
@@ -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__ */