1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:07:34 +00:00

FontEditor: Convert mode and transform buttons into toolbar actions

This will let us more easily organize and assign shortcuts to new
modes and transformations as they are built, and it generally looks
more polished as a uniform interface. Also adds a counterclockwise
option to the rotate action, moves Copy as Character to the edit
menu as it doesn't directly impact GlyphEditor, and makes the paint
and move modes exclusive checkables to make the editor's state more
visually obvious.
This commit is contained in:
thankyouverycool 2021-11-29 09:26:24 -05:00 committed by Andreas Kling
parent b7c8dee29a
commit 1e052f5a91
5 changed files with 75 additions and 97 deletions

View file

@ -276,7 +276,7 @@ static Vector<Vector<u8>> glyph_as_matrix(Gfx::GlyphBitmap const& bitmap)
return result;
}
void GlyphEditorWidget::rotate_90()
void GlyphEditorWidget::rotate_90(Direction direction)
{
if (on_undo_event)
on_undo_event();
@ -286,11 +286,11 @@ void GlyphEditorWidget::rotate_90()
for (int y = 0; y < bitmap.height(); y++) {
for (int x = 0; x < bitmap.width(); x++) {
int source_x = y;
int source_y = bitmap.width() - 1 - x;
int source_x = (direction == Counterclockwise) ? max(bitmap.width() - 1 - y, 0) : y;
int source_y = (direction == Counterclockwise) ? x : bitmap.width() - 1 - x;
bool value = false;
if (source_x < bitmap.width() && source_y < bitmap.height()) {
value = matrix[source_y][source_x];
value = (direction == Counterclockwise && y >= bitmap.width()) ? false : matrix[source_y][source_x];
}
bitmap.set_bit_at(x, y, value);
}