#include <msp/gl/meshbuilder.h>
#include "image.h"
#include "part.h"
+#include "resources.h"
+#include "root.h"
#include "style.h"
using namespace std;
void Image::set_image(const GL::Texture2D *i)
{
image = i;
+ icon_name = string();
signal_autosize_changed.emit();
rebuild();
}
+void Image::set_icon(const string &n)
+{
+ icon_name = n;
+ update_icon();
+}
+
void Image::set_keep_aspect(bool ka)
{
keep_aspect = ka;
rebuild();
}
+void Image::update_icon()
+{
+ if(style)
+ {
+ Root *root = find_ancestor<Root>();
+ if(root)
+ {
+ if(icon_name.empty())
+ image = 0;
+ else
+ image = &root->get_resources().get<GL::Texture2D>(icon_name);
+ signal_autosize_changed.emit();
+ rebuild();
+ return;
+ }
+ }
+
+ image = 0;
+}
+
void Image::rebuild_special(const Part &part)
{
if(part.get_name()=="image")
}
}
+void Image::on_style_change()
+{
+ if(!icon_name.empty())
+ update_icon();
+}
+
+void Image::on_reparent()
+{
+ if(!icon_name.empty())
+ update_icon();
+}
+
} // namespace GLtk
} // namespace Msp
{
private:
const GL::Texture2D *image;
+ std::string icon_name;
bool keep_aspect;
public:
public:
void set_image(const GL::Texture2D *);
+ void set_icon(const std::string &);
void set_keep_aspect(bool);
private:
+ void update_icon();
virtual void rebuild_special(const Part &);
+ virtual void on_style_change();
+ virtual void on_reparent();
};
} // namespace GLtk