mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-04 08:46:09 +00:00
Add <image> tag support
This commit is contained in:
parent
3da532453c
commit
e6d0c1858a
@ -487,21 +487,28 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
else if (elem_name == "image") {
|
||||
if (!widget) {
|
||||
const char* file = elem->Attribute("file");
|
||||
const char* icon = elem->Attribute("icon");
|
||||
|
||||
// Load image
|
||||
std::string icon(file);
|
||||
if (file) {
|
||||
ResourceFinder rf;
|
||||
rf.includeDataDir(file);
|
||||
if (!rf.findFirst())
|
||||
throw base::Exception("File %s not found", file);
|
||||
|
||||
ResourceFinder rf;
|
||||
rf.includeDataDir(file);
|
||||
if (!rf.findFirst())
|
||||
throw base::Exception("File %s not found", file);
|
||||
|
||||
try {
|
||||
os::SurfaceRef sur = os::instance()->loadRgbaSurface(rf.filename().c_str());
|
||||
widget = new ImageView(sur, 0);
|
||||
try {
|
||||
os::SurfaceRef sur = os::instance()->loadRgbaSurface(rf.filename().c_str());
|
||||
widget = new ImageView(sur, 0);
|
||||
}
|
||||
catch (...) {
|
||||
throw base::Exception("Error loading %s file", file);
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
throw base::Exception("Error loading %s file", file);
|
||||
|
||||
if (icon) {
|
||||
SkinPartPtr part = SkinTheme::instance()->getPartById(std::string(icon));
|
||||
if (part) {
|
||||
widget = new ImageView(part->bitmapRef(0), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -116,6 +116,9 @@ static Item convert_to_item(TiXmlElement* elem)
|
||||
if (name == "hbox")
|
||||
return item.typeIncl("ui::HBox",
|
||||
"ui/box.h");
|
||||
if (name == "image")
|
||||
return item.typeIncl("ui::ImageView",
|
||||
"ui/image_view.h");
|
||||
if (name == "item" &&
|
||||
parent == "buttonset")
|
||||
return item.typeIncl("app::ButtonSet::Item",
|
||||
|
Loading…
Reference in New Issue
Block a user