Add point symmetry mode and update related UI elements

This commit is contained in:
asqude 2025-06-30 19:37:43 +02:00
parent 3c350c3e67
commit ecc53c7c35
12 changed files with 63 additions and 20 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -256,12 +256,12 @@
<part id="pal_presets" x="160" y="200" w="5" h="5" />
<part id="pal_options" x="168" y="200" w="5" h="5" />
<part id="pal_resize" x="176" y="200" w="5" h="5" />
<part id="debug_continue" x="208" y="240" w="7" h="7" />
<part id="debug_pause" x="208" y="247" w="7" h="7" />
<part id="debug_step_into" x="222" y="240" w="7" h="7" />
<part id="debug_step_over" x="215" y="240" w="7" h="7" />
<part id="debug_step_out" x="229" y="240" w="7" h="7" />
<part id="debug_breakpoint" x="236" y="240" w="7" h="7" />
<part id="debug_continue" x="224" y="240" w="7" h="7" />
<part id="debug_pause" x="224" y="247" w="7" h="7" />
<part id="debug_step_into" x="238" y="240" w="7" h="7" />
<part id="debug_step_over" x="231" y="240" w="7" h="7" />
<part id="debug_step_out" x="245" y="240" w="7" h="7" />
<part id="debug_breakpoint" x="252" y="240" w="7" h="7" />
<part id="selection_replace" x="176" y="160" w="7" h="7" />
<part id="selection_add" x="184" y="160" w="7" h="7" />
<part id="selection_subtract" x="192" y="160" w="7" h="7" />
@ -456,6 +456,7 @@
<part id="spin_down" x="128" y="259" w="5" h="3" />
<part id="right_diagonal_symmetry" x="176" y="240" w="13" h="13" />
<part id="left_diagonal_symmetry" x="192" y="240" w="13" h="13" />
<part id="point_symmetry" x="208" y="240" w="13" h="13" />
</parts>
<styles>
<style id="box" />

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -252,12 +252,12 @@
<part id="pal_presets" x="160" y="200" w="5" h="5" />
<part id="pal_options" x="168" y="200" w="5" h="5" />
<part id="pal_resize" x="176" y="200" w="5" h="5" />
<part id="debug_continue" x="208" y="240" w="7" h="7" />
<part id="debug_pause" x="208" y="247" w="7" h="7" />
<part id="debug_step_into" x="222" y="240" w="7" h="7" />
<part id="debug_step_over" x="215" y="240" w="7" h="7" />
<part id="debug_step_out" x="229" y="240" w="7" h="7" />
<part id="debug_breakpoint" x="236" y="240" w="7" h="7" />
<part id="debug_continue" x="224" y="240" w="7" h="7" />
<part id="debug_pause" x="224" y="247" w="7" h="7" />
<part id="debug_step_into" x="238" y="240" w="7" h="7" />
<part id="debug_step_over" x="231" y="240" w="7" h="7" />
<part id="debug_step_out" x="245" y="240" w="7" h="7" />
<part id="debug_breakpoint" x="252" y="240" w="7" h="7" />
<part id="selection_replace" x="176" y="160" w="7" h="7" />
<part id="selection_add" x="184" y="160" w="7" h="7" />
<part id="selection_subtract" x="192" y="160" w="7" h="7" />
@ -452,6 +452,7 @@
<part id="spin_down" x="128" y="259" w="5" h="3" />
<part id="right_diagonal_symmetry" x="176" y="240" w="13" h="13" />
<part id="left_diagonal_symmetry" x="192" y="240" w="13" h="13" />
<part id="point_symmetry" x="208" y="240" w="13" h="13" />
</parts>
<styles>
<style id="box" />

View File

@ -554,6 +554,9 @@
<key command="SymmetryMode">
<param name="orientation" value="left_diagonal" />
</key>
<key command="SymmetryMode">
<param name="orientation" value="point" />
</key>
<key command="AutocropSprite" />
<key command="AutocropSprite">
<param name="byGrid" value="true" />

View File

@ -97,6 +97,7 @@
<value id="RIGHT_DIAG" value="4" />
<value id="LEFT_DIAG" value="8" />
<value id="BOTH_DIAG" value="12" />
<value id="POINT" value="16" />
<value id="ALL" value="15" />
</enum>
<enum id="PaintingCursorType">

View File

@ -1930,6 +1930,7 @@ toggle_horizontal = Toggle Horizontal Symmetry
toggle_vertical = Toggle Vertical Symmetry
toggle_right_diagonal = Toggle 45° Symmetry
toggle_left_diagonal = Toggle -45° Symmetry
toggle_point = Toggle Point Symmetry
show_options = Symmetry Options
reset_position = Reset Symmetry to Center
reset_position_to_view_center = Reset Symmetry to View Center

View File

@ -48,6 +48,7 @@ std::string SymmetryModeCommand::onGetFriendlyName() const
case app::gen::SymmetryMode::VERTICAL: return Strings::symmetry_toggle_vertical();
case app::gen::SymmetryMode::RIGHT_DIAG: return Strings::symmetry_toggle_right_diagonal();
case app::gen::SymmetryMode::LEFT_DIAG: return Strings::symmetry_toggle_left_diagonal();
case app::gen::SymmetryMode::POINT: return Strings::symmetry_toggle_point();
default: return Strings::symmetry_toggle();
}
}
@ -63,6 +64,8 @@ void SymmetryModeCommand::onLoadParams(const Params& params)
m_mode = app::gen::SymmetryMode::RIGHT_DIAG;
else if (mode == "left_diagonal")
m_mode = app::gen::SymmetryMode::LEFT_DIAG;
else if (mode == "point")
m_mode = app::gen::SymmetryMode::POINT;
else
m_mode = app::gen::SymmetryMode::NONE;
}

View File

@ -73,6 +73,15 @@ void Symmetry::generateStrokes(const Stroke& stroke, Strokes& strokes, ToolLoop*
break;
}
case gen::SymmetryMode::POINT: {
Stroke strokeTemp;
calculateSymmetricalStroke(stroke, strokeTemp, loop, doc::SymmetryIndex::FLIPPED_Y);
calculateSymmetricalStroke(strokeTemp, stroke2, loop, doc::SymmetryIndex::FLIPPED_XY);
strokes.push_back(stroke2);
break;
}
case gen::SymmetryMode::ALL: {
calculateSymmetricalStroke(stroke, stroke2, loop, doc::SymmetryIndex::FLIPPED_X);
strokes.push_back(stroke2);
@ -176,7 +185,12 @@ gen::SymmetryMode Symmetry::resolveMode(gen::SymmetryMode mode)
return (((int(mode) & int(gen::SymmetryMode::HORIZONTAL)) ||
(int(mode) & int(gen::SymmetryMode::VERTICAL))) &&
((int(mode) & int(gen::SymmetryMode::RIGHT_DIAG)) ||
(int(mode) & int(gen::SymmetryMode::LEFT_DIAG)))) ?
(int(mode) & int(gen::SymmetryMode::LEFT_DIAG)))) ||
((int(mode) & int(gen::SymmetryMode::POINT)) &&
((int(mode) & int(gen::SymmetryMode::RIGHT_DIAG)) ||
(int(mode) & int(gen::SymmetryMode::LEFT_DIAG)) ||
(int(mode) & int(gen::SymmetryMode::HORIZONTAL)) ||
(int(mode) & int(gen::SymmetryMode::VERTICAL)))) ?
gen::SymmetryMode::ALL :
mode;
}

View File

@ -1502,7 +1502,7 @@ protected:
class ContextBar::SymmetryField : public ButtonSet {
public:
SymmetryField() : ButtonSet(5)
SymmetryField() : ButtonSet(6)
{
setMultiMode(MultiMode::Set);
auto theme = SkinTheme::get(this);
@ -1510,6 +1510,7 @@ public:
addItem(theme->parts.verticalSymmetry(), theme->styles.symmetryField());
addItem(theme->parts.rightDiagonalSymmetry(), theme->styles.symmetryField());
addItem(theme->parts.leftDiagonalSymmetry(), theme->styles.symmetryField());
addItem(theme->parts.pointSymmetry(), theme->styles.symmetryField());
addItem("...", theme->styles.symmetryOptions());
}
@ -1519,7 +1520,8 @@ public:
tooltipManager->addTooltipFor(at(1), Strings::symmetry_toggle_vertical(), BOTTOM);
tooltipManager->addTooltipFor(at(2), Strings::symmetry_toggle_right_diagonal(), BOTTOM);
tooltipManager->addTooltipFor(at(3), Strings::symmetry_toggle_left_diagonal(), BOTTOM);
tooltipManager->addTooltipFor(at(4), Strings::symmetry_show_options(), BOTTOM);
tooltipManager->addTooltipFor(at(4), Strings::symmetry_toggle_point(), BOTTOM);
tooltipManager->addTooltipFor(at(5), Strings::symmetry_show_options(), BOTTOM);
}
void updateWithCurrentDocument()
@ -1534,6 +1536,7 @@ public:
at(1)->setSelected(int(docPref.symmetry.mode()) & int(app::gen::SymmetryMode::VERTICAL));
at(2)->setSelected(int(docPref.symmetry.mode()) & int(app::gen::SymmetryMode::RIGHT_DIAG));
at(3)->setSelected(int(docPref.symmetry.mode()) & int(app::gen::SymmetryMode::LEFT_DIAG));
at(4)->setSelected(int(docPref.symmetry.mode()) & int(app::gen::SymmetryMode::POINT));
}
private:
@ -1556,14 +1559,16 @@ private:
mode |= int(app::gen::SymmetryMode::RIGHT_DIAG);
if (at(3)->isSelected())
mode |= int(app::gen::SymmetryMode::LEFT_DIAG);
if (at(4)->isSelected())
mode |= int(app::gen::SymmetryMode::POINT);
if (app::gen::SymmetryMode(mode) != docPref.symmetry.mode()) {
docPref.symmetry.mode(app::gen::SymmetryMode(mode));
// Redraw symmetry rules
doc->notifyGeneralUpdate();
}
else if (at(4)->isSelected()) {
auto* item = at(4);
else if (at(5)->isSelected()) {
auto* item = at(5);
gfx::Rect bounds = item->bounds();
item->setSelected(false);

View File

@ -916,6 +916,18 @@ void Editor::drawOneSpriteUnclippedRect(ui::Graphics* g,
topLeft,
bottomRight);
}
if (mode & int(app::gen::SymmetryMode::POINT)) {
g->drawHLine(
symmetryButtons & int(app::gen::SymmetryMode::POINT) ? color : semiTransparentColor,
enclosingRect.x + x - enclosingRect.w * 0.10f,
enclosingRect.y + y,
enclosingRect.w * 0.10f * 2.0f);
g->drawVLine(
(symmetryButtons & int(app::gen::SymmetryMode::POINT)) ? color : semiTransparentColor,
enclosingRect.x + x,
enclosingRect.y + y - enclosingRect.h * 0.10f,
enclosingRect.h * 0.10f * 2.0f);
}
}
}
}

View File

@ -1030,7 +1030,8 @@ bool StandbyState::Decorator::getSymmetryHandles(Editor* editor, Handles& handle
if ((int(mode) & int(app::gen::SymmetryMode::HORIZONTAL)) ||
(int(mode) & int(app::gen::SymmetryMode::RIGHT_DIAG)) ||
(int(mode) & int(app::gen::SymmetryMode::LEFT_DIAG))) {
(int(mode) & int(app::gen::SymmetryMode::LEFT_DIAG)) ||
(int(mode) & int(app::gen::SymmetryMode::POINT))) {
double pos = symmetry.xAxis();
gfx::PointF pt1, pt2;
@ -1051,7 +1052,8 @@ bool StandbyState::Decorator::getSymmetryHandles(Editor* editor, Handles& handle
if ((int(mode) & int(app::gen::SymmetryMode::VERTICAL)) ||
(int(mode) & int(app::gen::SymmetryMode::RIGHT_DIAG)) ||
(int(mode) & int(app::gen::SymmetryMode::LEFT_DIAG))) {
(int(mode) & int(app::gen::SymmetryMode::LEFT_DIAG)) ||
(int(mode) & int(app::gen::SymmetryMode::POINT))) {
double pos = symmetry.yAxis();
gfx::PointF pt1, pt2;