summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2006-03-14 20:51:55 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2006-03-14 20:51:55 +0000
commit8d3fdc3c5b87f6d1444830d82f28d18a2201afea (patch)
treef4fc9893bbb92d5d7b2fc3c5321db4bb6ffa0635 /libs
parente72e0caf9949be20b3d5416648a902ab3fe9c588 (diff)
fix problems with pixmaps/xpm files
git-svn-id: svn://localhost/trunk/ardour2@392 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/gtkmm2ext/fastmeter.cc60
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/fastmeter.h7
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/pix.h8
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/pixscroller.h5
-rw-r--r--libs/gtkmm2ext/pix.cc20
-rw-r--r--libs/gtkmm2ext/pixscroller.cc18
-rw-r--r--libs/gtkmm2ext/slider_controller.cc2
-rw-r--r--libs/gtkmm2ext/utils.cc12
8 files changed, 77 insertions, 55 deletions
diff --git a/libs/gtkmm2ext/fastmeter.cc b/libs/gtkmm2ext/fastmeter.cc
index 82a04b5521..bf160441c2 100644
--- a/libs/gtkmm2ext/fastmeter.cc
+++ b/libs/gtkmm2ext/fastmeter.cc
@@ -32,6 +32,8 @@ using namespace Glib;
using namespace Gtkmm2ext;
using namespace std;
+string FastMeter::v_image_path;
+string FastMeter::h_image_path;
RefPtr<Pixmap> FastMeter::v_pixmap;
RefPtr<Bitmap> FastMeter::v_mask;
gint FastMeter::v_pixheight = 0;
@@ -56,16 +58,8 @@ FastMeter::FastMeter (long hold, unsigned long dimen, Orientation o)
pixrect.x = 0;
pixrect.y = 0;
- if (orientation == Vertical) {
- pixrect.width = min (v_pixwidth, (gint) dimen);
- pixrect.height = v_pixheight;
- } else {
- pixrect.width = h_pixwidth;
- pixrect.height = min (h_pixheight, (gint) dimen);
- }
-
- request_width = pixrect.width;
- request_height= pixrect.height;
+ request_width = dimen;
+ request_height = dimen;
}
FastMeter::~FastMeter ()
@@ -73,31 +67,57 @@ FastMeter::~FastMeter ()
}
void
-FastMeter::set_vertical_xpm (const std::string& xpm_file)
+FastMeter::on_realize ()
{
- if (v_pixmap == 0) {
- gint w, h;
+ DrawingArea::on_realize ();
- v_pixmap = Pixmap::create_from_xpm(get_bogus_drawable(), Colormap::get_system(), v_mask, Gdk::Color(), xpm_file);
+ Glib::RefPtr<Gdk::Drawable> drawable = Glib::RefPtr<Gdk::Window>::cast_dynamic (get_window());
+ Gdk::Color transparent;
+
+ if (!v_image_path.empty() && v_pixmap == 0) {
+ gint w, h;
+
+ v_pixmap = Pixmap::create_from_xpm (drawable, Colormap::get_system(), v_mask, transparent, v_image_path);
v_pixmap->get_size(w, h);
v_pixheight = h;
v_pixwidth = w;
}
-}
-void
-FastMeter::set_horizontal_xpm (const std::string& xpm_file)
-{
- if (h_pixmap == 0) {
+ if (!h_image_path.empty() && h_pixmap == 0) {
gint w, h;
- h_pixmap = Pixmap::create_from_xpm(get_bogus_drawable(), Colormap::get_system(), h_mask, Gdk::Color(), xpm_file);
+ h_pixmap = Pixmap::create_from_xpm (drawable, Colormap::get_system(), h_mask, transparent, h_image_path);
h_pixmap->get_size(w, h);
h_pixheight = h;
h_pixwidth = w;
}
+
+ if (orientation == Vertical) {
+ pixrect.width = min (v_pixwidth, request_width);
+ pixrect.height = v_pixheight;
+ } else {
+ pixrect.width = h_pixwidth;
+ pixrect.height = min (h_pixheight, request_height);
+ }
+
+ request_width = pixrect.width;
+ request_height= pixrect.height;
+
+ set_size_request (request_width, request_height);
+}
+
+void
+FastMeter::set_vertical_xpm (std::string path)
+{
+ v_image_path = path;
+}
+
+void
+FastMeter::set_horizontal_xpm (std::string path)
+{
+ h_image_path = path;
}
void
diff --git a/libs/gtkmm2ext/gtkmm2ext/fastmeter.h b/libs/gtkmm2ext/gtkmm2ext/fastmeter.h
index 5defcfae8f..87cfd0b836 100644
--- a/libs/gtkmm2ext/gtkmm2ext/fastmeter.h
+++ b/libs/gtkmm2ext/gtkmm2ext/fastmeter.h
@@ -46,14 +46,17 @@ class FastMeter : public Gtk::DrawingArea {
long hold_count() { return hold_cnt; }
void set_hold_count (long);
- static void set_horizontal_xpm (const std::string&);
- static void set_vertical_xpm (const std::string&);
+ static void set_horizontal_xpm (std::string);
+ static void set_vertical_xpm (std::string);
protected:
bool on_expose_event (GdkEventExpose*);
void on_size_request (GtkRequisition*);
+ void on_realize ();
private:
+ static std::string h_image_path;
+ static std::string v_image_path;
static Glib::RefPtr<Gdk::Pixmap> h_pixmap;
static Glib::RefPtr<Gdk::Bitmap> h_mask;
static gint h_pixheight;
diff --git a/libs/gtkmm2ext/gtkmm2ext/pix.h b/libs/gtkmm2ext/gtkmm2ext/pix.h
index b06f6046ea..65526151d4 100644
--- a/libs/gtkmm2ext/gtkmm2ext/pix.h
+++ b/libs/gtkmm2ext/gtkmm2ext/pix.h
@@ -17,7 +17,7 @@ class Pix
int refcnt;
bool generated;
std::vector<std::string *> *files;
- std::vector<const char **> data;
+ std::vector<const char* const*> data;
bool from_files;
int pixmap_count;
int last_pixmap;
@@ -29,21 +29,21 @@ class Pix
Pix (const std::string &dirpath, const std::string &regexp,
bool homogenous = true);
- Pix (std::vector<const char **> xpm_data, bool homogenous = true);
+ Pix (std::vector<const char* const*> xpm_data, bool homogenous = true);
virtual ~Pix();
friend Pix *get_pix (const std::string &dirpath,
const std::string &regexp,
bool homogenous);
friend Pix *get_pix (std::string name,
- std::vector<const char **> xpm_data,
+ std::vector<const char* const*> xpm_data,
bool homogenous);
friend void finish_pix (Pix *);
public:
Pix (bool homogenous = true);
- void generate ();
+ void generate (Glib::RefPtr<Gdk::Drawable>&);
int n_pixmaps() { return pixmap_count; }
int max_pixmap() { return last_pixmap; }
bool homogenous () { return _homegenous; }
diff --git a/libs/gtkmm2ext/gtkmm2ext/pixscroller.h b/libs/gtkmm2ext/gtkmm2ext/pixscroller.h
index 4501a0c88c..55b84dfacc 100644
--- a/libs/gtkmm2ext/gtkmm2ext/pixscroller.h
+++ b/libs/gtkmm2ext/gtkmm2ext/pixscroller.h
@@ -20,11 +20,14 @@ class PixScroller : public Gtk::DrawingArea
bool on_button_press_event (GdkEventButton*);
bool on_button_release_event (GdkEventButton*);
void on_size_request (GtkRequisition*);
-
+ void on_realize ();
+
protected:
Gtk::Adjustment& adj;
private:
+ Pix& pix;
+
Glib::RefPtr<Gdk::Pixmap> rail;
Glib::RefPtr<Gdk::Pixmap> slider;
Glib::RefPtr<Gdk::Bitmap> rail_mask;
diff --git a/libs/gtkmm2ext/pix.cc b/libs/gtkmm2ext/pix.cc
index ba10715861..1d3696ffdc 100644
--- a/libs/gtkmm2ext/pix.cc
+++ b/libs/gtkmm2ext/pix.cc
@@ -57,7 +57,7 @@ Pix::Pix (bool homog)
_homegenous = homog;
}
-Pix::Pix (vector<const char **> xpm_data, bool homog)
+Pix::Pix (vector<const char* const*> xpm_data, bool homog)
{
if (xpm_data.size() == 0) {
throw failed_constructor();
@@ -132,24 +132,22 @@ Pix::~Pix ()
}
void
-Pix::generate ()
-
+Pix::generate (Glib::RefPtr<Gdk::Drawable>& drawable)
{
if (generated) {
return;
}
for (int i = 0; i < pixmap_count; i++) {
+
+ Gdk::Color transparent;
+
if (from_files) {
- pixmaps[i] = Gdk::Pixmap::create_from_xpm (get_bogus_drawable(), Gdk::Colormap::get_system(),
- bitmaps[i], Gdk::Color(), *(*files)[i]);
+ pixmaps[i] = Gdk::Pixmap::create_from_xpm(drawable, bitmaps[i], transparent, *(*files)[i]);
} else {
- gchar **xpm;
- xpm = const_cast<gchar **> (data[i]);
-
- pixmaps[i] = Gdk::Pixmap::create_from_xpm(Gdk::Colormap::get_system(),
- bitmaps[i], Gdk::Color(), xpm);
+ pixmaps[i] = Gdk::Pixmap::create_from_xpm(drawable, Gdk::Colormap::get_system(), bitmaps[i], Gdk::Color(), data[i]);
}
+
int w, h;
pixmaps[i]->get_size(w, h);
@@ -161,7 +159,7 @@ Pix::generate ()
}
Pix *
-Gtkmm2ext::get_pix (string name, vector<const char **> xpm_data, bool homog)
+Gtkmm2ext::get_pix (string name, vector<const char* const*> xpm_data, bool homog)
{
Pix *ret = 0;
Pix::PixCache::iterator iter;
diff --git a/libs/gtkmm2ext/pixscroller.cc b/libs/gtkmm2ext/pixscroller.cc
index 9489a532ca..95861fd930 100644
--- a/libs/gtkmm2ext/pixscroller.cc
+++ b/libs/gtkmm2ext/pixscroller.cc
@@ -29,8 +29,9 @@ using namespace std;
using namespace Gtk;
using namespace Gtkmm2ext;
-PixScroller::PixScroller (Adjustment& a, Pix& pix)
- : adj (a)
+PixScroller::PixScroller (Adjustment& a, Pix& p)
+ : adj (a),
+ pix (p)
{
dragging = false;
add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK|Gdk::SCROLL_MASK);
@@ -38,7 +39,16 @@ PixScroller::PixScroller (Adjustment& a, Pix& pix)
adj.signal_value_changed().connect (mem_fun (*this, &PixScroller::adjustment_changed));
default_value = adj.get_value();
- pix.generate ();
+}
+
+void
+PixScroller::on_realize ()
+{
+ DrawingArea::on_realize ();
+
+ Glib::RefPtr<Gdk::Drawable> drawable = Glib::RefPtr<Gdk::Window>::cast_dynamic (get_window());
+
+ pix.generate (drawable);
rail = *(pix.pixmap (0));
rail_mask = *(pix.shape_mask (0));
@@ -61,6 +71,8 @@ PixScroller::PixScroller (Adjustment& a, Pix& pix)
sliderrect.set_y((int) rint ((overall_height - sliderrect.get_height()) * (adj.get_upper() - adj.get_value())));
railrect.set_x((sliderrect.get_width() / 2) - 2);
+
+ set_size_request (sliderrect.get_width(), overall_height);
}
void
diff --git a/libs/gtkmm2ext/slider_controller.cc b/libs/gtkmm2ext/slider_controller.cc
index ca75fbb7b4..4305c22738 100644
--- a/libs/gtkmm2ext/slider_controller.cc
+++ b/libs/gtkmm2ext/slider_controller.cc
@@ -43,8 +43,6 @@ SliderController::SliderController (Pix *pixset,
bind_statemask (Gdk::CONTROL_MASK)
{
- pixset->generate ();
-
signal_button_press_event().connect (mem_fun (this, &SliderController::button_press));
spin.set_name ("SliderControllerValue");
spin.set_size_request (70,-1); // should be based on font size somehow
diff --git a/libs/gtkmm2ext/utils.cc b/libs/gtkmm2ext/utils.cc
index 79b84aa26d..401ed3e8ad 100644
--- a/libs/gtkmm2ext/utils.cc
+++ b/libs/gtkmm2ext/utils.cc
@@ -83,15 +83,3 @@ void Gtkmm2ext::set_treeview_header_as_default_label(Gtk::TreeViewColumn* c)
gtk_tree_view_column_set_widget( c->gobj(), GTK_WIDGET(0) );
}
-Glib::RefPtr<Gdk::Drawable>
-Gtkmm2ext::get_bogus_drawable()
-{
- static Gtk::Button* button = 0;
-
- if (button == 0) {
- button = new Gtk::Button ("blah"); //bogus button to extract a Gdk::Drawable from
- }
- static Glib::RefPtr<Gdk::Drawable> drawable = button->get_window();
- return drawable;
-}
-