mirror of
https://github.com/aseprite/aseprite.git
synced 2024-12-29 09:23:32 +00:00
Added Undoable::deselect_mask() member function.
This commit is contained in:
parent
c4afb1a236
commit
cc7fd95559
@ -22,8 +22,8 @@
|
||||
#include "modules/gui.h"
|
||||
#include "raster/mask.h"
|
||||
#include "raster/sprite.h"
|
||||
#include "raster/undo.h"
|
||||
#include "sprite_wrappers.h"
|
||||
#include "undoable.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// deselect_mask
|
||||
@ -46,38 +46,20 @@ DeselectMaskCommand::DeselectMaskCommand()
|
||||
{
|
||||
}
|
||||
|
||||
bool DeselectMaskCommand::enabled(Context* context)
|
||||
{
|
||||
const CurrentSpriteReader sprite(context);
|
||||
return sprite && !sprite->mask->is_empty();
|
||||
}
|
||||
|
||||
void DeselectMaskCommand::execute(Context* context)
|
||||
bool DeselectMaskCommand::enabled(Context* context)
|
||||
{
|
||||
const CurrentSpriteReader sprite(context);
|
||||
return sprite && !sprite->mask->is_empty();
|
||||
}
|
||||
|
||||
void DeselectMaskCommand::execute(Context* context)
|
||||
{
|
||||
CurrentSpriteWriter sprite(context);
|
||||
Mask *mask;
|
||||
|
||||
/* destroy the *deselected* mask */
|
||||
mask = sprite_request_mask(sprite, "*deselected*");
|
||||
if (mask) {
|
||||
sprite_remove_mask(sprite, mask);
|
||||
mask_free(mask);
|
||||
{
|
||||
Undoable undoable(sprite, "Mask Deselection");
|
||||
undoable.deselect_mask();
|
||||
undoable.commit();
|
||||
}
|
||||
|
||||
/* save the selection in the repository */
|
||||
mask = mask_new_copy(sprite->mask);
|
||||
mask_set_name(mask, "*deselected*");
|
||||
sprite_add_mask(sprite, mask);
|
||||
|
||||
/* undo */
|
||||
if (undo_is_enabled(sprite->undo)) {
|
||||
undo_set_label(sprite->undo, "Mask Deselection");
|
||||
undo_set_mask(sprite->undo, sprite);
|
||||
}
|
||||
|
||||
/* deselect the mask */
|
||||
mask_none(sprite->mask);
|
||||
|
||||
sprite_generate_mask_boundaries(sprite);
|
||||
update_screen_for_sprite(sprite);
|
||||
}
|
||||
|
@ -1051,3 +1051,24 @@ void Undoable::set_mask_position(int x, int y)
|
||||
m_sprite->mask->x = x;
|
||||
m_sprite->mask->y = y;
|
||||
}
|
||||
|
||||
void Undoable::deselect_mask()
|
||||
{
|
||||
// Destroy the *deselected* mask
|
||||
Mask* mask = sprite_request_mask(m_sprite, "*deselected*");
|
||||
if (mask) {
|
||||
sprite_remove_mask(m_sprite, mask);
|
||||
mask_free(mask);
|
||||
}
|
||||
|
||||
// Save the selection in the repository
|
||||
mask = mask_new_copy(m_sprite->mask);
|
||||
mask_set_name(mask, "*deselected*");
|
||||
sprite_add_mask(m_sprite, mask);
|
||||
|
||||
if (undo_is_enabled(m_sprite->undo))
|
||||
undo_set_mask(m_sprite->undo, m_sprite);
|
||||
|
||||
/// Deselect the mask
|
||||
mask_none(m_sprite->mask);
|
||||
}
|
||||
|
@ -102,6 +102,7 @@ public:
|
||||
// for mask
|
||||
void copy_to_current_mask(Mask* mask);
|
||||
void set_mask_position(int x, int y);
|
||||
void deselect_mask();
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user