mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-30 15:32:38 +00:00
Add option to reset symmetry to the center (fix #2195)
This commit is contained in:
parent
5ac07c0823
commit
8c2a99f952
@ -1520,3 +1520,5 @@ image_preset_text = Text
|
||||
toggle = Toggle Symmetry
|
||||
toggle_horizontal = Toggle Horizontal Symmetry
|
||||
toggle_vertical = Toggle Vertical Symmetry
|
||||
show_options = Symmetry Options
|
||||
reset_position = Reset Symmetry to Center
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "app/commands/quick_command.h"
|
||||
#include "app/doc.h"
|
||||
#include "app/doc_event.h"
|
||||
#include "app/i18n/strings.h"
|
||||
#include "app/ini_file.h"
|
||||
#include "app/match_words.h"
|
||||
#include "app/modules/editors.h"
|
||||
@ -1106,16 +1107,18 @@ protected:
|
||||
|
||||
class ContextBar::SymmetryField : public ButtonSet {
|
||||
public:
|
||||
SymmetryField() : ButtonSet(2) {
|
||||
SymmetryField() : ButtonSet(3) {
|
||||
setMultiMode(MultiMode::Set);
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
addItem(theme->parts.horizontalSymmetry());
|
||||
addItem(theme->parts.verticalSymmetry());
|
||||
addItem("...");
|
||||
}
|
||||
|
||||
void setupTooltips(TooltipManager* tooltipManager) {
|
||||
tooltipManager->addTooltipFor(at(0), "Horizontal Symmetry", BOTTOM);
|
||||
tooltipManager->addTooltipFor(at(1), "Vertical Symmetry", BOTTOM);
|
||||
tooltipManager->addTooltipFor(at(0), Strings::symmetry_toggle_horizontal(), BOTTOM);
|
||||
tooltipManager->addTooltipFor(at(1), Strings::symmetry_toggle_vertical(), BOTTOM);
|
||||
tooltipManager->addTooltipFor(at(2), Strings::symmetry_show_options(), BOTTOM);
|
||||
}
|
||||
|
||||
void updateWithCurrentDocument() {
|
||||
@ -1143,10 +1146,32 @@ private:
|
||||
int mode = 0;
|
||||
if (at(0)->isSelected()) mode |= int(app::gen::SymmetryMode::HORIZONTAL);
|
||||
if (at(1)->isSelected()) mode |= int(app::gen::SymmetryMode::VERTICAL);
|
||||
docPref.symmetry.mode(app::gen::SymmetryMode(mode));
|
||||
if (app::gen::SymmetryMode(mode) != docPref.symmetry.mode()) {
|
||||
docPref.symmetry.mode(app::gen::SymmetryMode(mode));
|
||||
// Redraw symmetry rules
|
||||
doc->notifyGeneralUpdate();
|
||||
}
|
||||
else if (at(2)->isSelected()) {
|
||||
auto item = at(2);
|
||||
|
||||
// Redraw symmetry rules
|
||||
doc->notifyGeneralUpdate();
|
||||
gfx::Rect bounds = item->bounds();
|
||||
item->setSelected(false);
|
||||
|
||||
Menu menu;
|
||||
MenuItem
|
||||
reset(Strings::symmetry_reset_position());
|
||||
menu.addChild(&reset);
|
||||
|
||||
reset.Click.connect(
|
||||
[doc, &docPref]{
|
||||
docPref.symmetry.xAxis(doc->sprite()->width()/2.0);
|
||||
docPref.symmetry.yAxis(doc->sprite()->height()/2.0);
|
||||
// Redraw symmetry rules
|
||||
doc->notifyGeneralUpdate();
|
||||
});
|
||||
|
||||
menu.showPopup(gfx::Point(bounds.x, bounds.y+bounds.h));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user