X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fcanvas%2Fstateful_image.cc;h=897500d5fddad048fa18f512414d9eafd3ee204b;hb=601c317d70a03190257577bd867cefc2c70d3275;hp=b372ade7b878f6d74f3008749f54949c058e76c2;hpb=590882f3c8e063528452d71daffb36d3151da05e;p=ardour.git diff --git a/libs/canvas/stateful_image.cc b/libs/canvas/stateful_image.cc index b372ade7b8..897500d5fd 100644 --- a/libs/canvas/stateful_image.cc +++ b/libs/canvas/stateful_image.cc @@ -9,9 +9,8 @@ #include "pbd/xml++.h" #include "canvas/stateful_image.h" -#include "canvas/utils.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace ArdourCanvas; using PBD::error; @@ -45,8 +44,8 @@ StatefulImage::render (Rect const & area, Cairo::RefPtr context) ImageHandle image = _states[_state].image; Rect self = item_to_window (Rect (0, 0, image->get_width(), image->get_height())); - boost::optional draw = self.intersection (area); - + Rect draw = self.intersection (area); + if (!draw) { return; } @@ -55,7 +54,7 @@ StatefulImage::render (Rect const & area, Cairo::RefPtr context) ("window" coordinates) and render it. */ context->set_source (image, self.x0, self.y0); - context->rectangle (draw->x0, draw->y0, draw->width(), draw->height()); + context->rectangle (draw.x0, draw.y0, draw.width(), draw.height()); context->fill (); if (!_text.empty()) { @@ -68,7 +67,7 @@ StatefulImage::render (Rect const & area, Cairo::RefPtr context) } // layout->set_alignment (_alignment); - set_source_rgba (context, _text_color); + Gtkmm2ext::set_source_rgba (context, _text_color); context->move_to (_text_x, _text_y); layout->show_in_cairo_context (context); } @@ -89,30 +88,30 @@ int StatefulImage::load_states (const XMLNode& node) { const XMLNodeList& nodes (node.children()); - + _states.clear (); - + for (XMLNodeList::const_iterator i = nodes.begin(); i != nodes.end(); ++i) { State s; States::size_type id; const XMLProperty* prop; - + if ((prop = (*i)->property ("id")) == 0) { error << _("no ID for state") << endmsg; continue; } - sscanf (prop->value().c_str(), "%zd", &id); + sscanf (prop->value().c_str(), "%" G_GSIZE_FORMAT, &id); if ((prop = (*i)->property ("image")) == 0) { error << _("no image for state") << endmsg; continue; } - - if ((s.image = find_image (prop->value())) == 0) { + + if (!(s.image = find_image (prop->value()))) { error << string_compose (_("image %1 not found for state"), prop->value()) << endmsg; continue; } - + if (_states.size() < id) { _states.reserve (id); } @@ -134,12 +133,12 @@ StatefulImage::find_image (const std::string& name) std::string path; - if (!find_file_in_search_path (_image_search_path, name, path)) { + if (!find_file (_image_search_path, name, path)) { error << string_compose (_("Image named %1 not found"), name) << endmsg; return ImageHandle(); } - + return Cairo::ImageSurface::create_from_png (path); }