#include "canvas/stateful_image.h"
#include "canvas/utils.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
using namespace ArdourCanvas;
using PBD::error;
ImageHandle image = _states[_state].image;
Rect self = item_to_window (Rect (0, 0, image->get_width(), image->get_height()));
- boost::optional<Rect> draw = self.intersection (area);
-
+ Rect draw = self.intersection (area);
+
if (!draw) {
return;
}
("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()) {
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);
}
name) << endmsg;
return ImageHandle();
}
-
+
return Cairo::ImageSurface::create_from_png (path);
}