mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Add SpriteWrap::commitImages() to commit changes to images
This might be useful to use before we execute commands like Sprite.resize or Sprite.crop, which they need all images in the most updated state.
This commit is contained in:
parent
573f68451a
commit
84d8a7a4ec
@ -39,6 +39,9 @@ void ImageWrap::commit()
|
||||
m_backup.get(),
|
||||
m_modifiedRegion, 0, 0,
|
||||
true));
|
||||
|
||||
m_backup.reset(nullptr);
|
||||
m_modifiedRegion.clear();
|
||||
}
|
||||
|
||||
void ImageWrap::modifyRegion(const gfx::Region& rgn)
|
||||
|
@ -58,6 +58,8 @@ script::result_t Sprite_resize(script::ContextHandle handle)
|
||||
|
||||
auto wrap = (SpriteWrap*)ctx.getThis();
|
||||
if (wrap) {
|
||||
wrap->commitImages();
|
||||
|
||||
Document* doc = wrap->document();
|
||||
DocumentApi api(doc, wrap->transaction());
|
||||
api.setSpriteSize(doc->sprite(), w, h);
|
||||
@ -76,6 +78,8 @@ script::result_t Sprite_crop(script::ContextHandle handle)
|
||||
|
||||
auto wrap = (SpriteWrap*)ctx.getThis();
|
||||
if (wrap) {
|
||||
wrap->commitImages();
|
||||
|
||||
Document* doc = wrap->document();
|
||||
DocumentApi api(doc, wrap->transaction());
|
||||
api.cropSprite(doc->sprite(), gfx::Rect(x, y, w, h));
|
||||
|
@ -51,8 +51,7 @@ Transaction& SpriteWrap::transaction()
|
||||
|
||||
void SpriteWrap::commit()
|
||||
{
|
||||
for (auto it : m_images)
|
||||
it.second->commit();
|
||||
commitImages();
|
||||
|
||||
if (m_transaction) {
|
||||
m_transaction->commit();
|
||||
@ -61,6 +60,12 @@ void SpriteWrap::commit()
|
||||
}
|
||||
}
|
||||
|
||||
void SpriteWrap::commitImages()
|
||||
{
|
||||
for (auto it : m_images)
|
||||
it.second->commit();
|
||||
}
|
||||
|
||||
app::Document* SpriteWrap::document()
|
||||
{
|
||||
return m_doc;
|
||||
@ -73,8 +78,11 @@ doc::Sprite* SpriteWrap::sprite()
|
||||
|
||||
ImageWrap* SpriteWrap::activeImage()
|
||||
{
|
||||
if (!m_view)
|
||||
return nullptr;
|
||||
if (!m_view) {
|
||||
m_view = UIContext::instance()->getFirstDocumentView(m_doc);
|
||||
if (!m_view)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
doc::Site site;
|
||||
m_view->getSite(&site);
|
||||
|
@ -32,6 +32,7 @@ namespace app {
|
||||
~SpriteWrap();
|
||||
|
||||
void commit();
|
||||
void commitImages();
|
||||
Transaction& transaction();
|
||||
|
||||
app::Document* document();
|
||||
|
Loading…
x
Reference in New Issue
Block a user