Commit graph

38 commits

Author SHA1 Message Date
Andreas Kling
b71c7a6e44 Userland: Use Font::pixel_size_rounded_up() instead of glyph_height()
The only remaining clients of this API are specific to bitmap fonts and
editing thereof.
2023-03-04 00:29:38 +01:00
thankyouverycool
804baa42f9 LibGUI: Standardize automatic scrolling in TextEditor+GlyphMapWidget
Both widgets now make use of their base class's scrolling timer and
now always accept drag selection updates on mousemove_event().

This guarantees much snappier feeling selections when actively moving
the mouse.
2022-12-26 09:27:19 +01:00
thankyouverycool
40e94a315a LibGUI+FontEditor: Restore normalized selections on Undo/Redo
Selections are always normalized when saving undo commands.
The restore_selection() function reverses this process so
negatively sized selections (created right-to-left) continue
to resize correctly with the keyboard when restored.
2022-12-20 10:22:27 +01:00
thankyouverycool
02212f373b LibGUI: Reset GlyphMapWidget scroll value when changing active range
Fixes being teleported to the old location when scrolling on a
previously browsed range.
2022-12-20 10:22:27 +01:00
thankyouverycool
d973d43b13 LibGUI: Focus the actively resizing end of GlyphMapWidget selections 2022-12-20 10:22:27 +01:00
thankyouverycool
673afffd5a LibGUI: Only reset GlyphMapWidget selection on Escape
and when using unmodified arrows.
2022-12-20 10:22:27 +01:00
thankyouverycool
4c81fbc8c4 LibGUI: Add Page{Up,Down} support for GlyphMapWidget 2022-12-20 10:22:27 +01:00
thankyouverycool
a98d5c52f8 LibGUI: Improve visible glyph estimate in GlyphMapWidget
Previously the widget used a very rough estimate for visible glyphs
based on viewport and glyph areas. Now it simply figures rows times
columns with a two row overdraw to accommodate fractional glyphs
on either end of visible content. For KaticaRegular10, this ends up
reducing unnecessary glyph iterations during painting by about 30%.
2022-12-20 10:22:27 +01:00
thankyouverycool
e34503800c LibGUI: Adjust GlyphMapWidget content sizing and glyph padding
Fixes a slightly oversized content rect and erroneous glyph outer
rect values. Increases glyph rect padding to guarantee at least 1px
between the focus rect and glyph.
2022-12-20 10:22:27 +01:00
thankyouverycool
0f5ce017c5 LibGUI: Implement calculated_min_size() for GlyphMapWidget 2022-12-20 10:22:27 +01:00
thankyouverycool
c4ac73d073 LibGUI: Check bounds when moving GlyphMapWidget selections
Fixes crashing on invalid code points when creating selections
with the keyboard and applying actions to them.

Also adds Home/End key support for selections. Ctrl+Shift+{Home,End}
now extends the selection to the beginning or end of the active range,
respectively. Shift+{Home,End} extends the selection to the start or
end of the row. Alt+{Home,End} resets the selection and moves the
active glyph to the beginning or end of the active range.
2022-12-20 10:22:27 +01:00
thankyouverycool
12cd30f1ac LibGUI: Ensure GlyphMapWidget selection resets when requested
Previously selection reset was ignored on active glyph change if the
old glyph equaled the new one. This was an intentional behavior that
allowed selections to resize by dragging the focused glyph, but has
proved more counterintuitive than useful.

Now the widget behaves like other text selection controls: selections
can be reset by clicking anywhere in them or shift can be held to
grow the selection.
2022-12-20 10:22:27 +01:00
thankyouverycool
360e58a276 LibGUI: Disallow GlyphMapWidget selection sizes equal to zero
This is a bogus size as the map must always have at least 1 glyph
selected, and it was causing occasional desync between selection
contents and the focused glyph when manipulating selections with
the keyboard.
2022-12-20 10:22:27 +01:00
thankyouverycool
8d3f60c7ef LibGUI: Forward GlyphMapWidget Key_Tab events
Allows focus to be passed using the keyboard.
2022-12-20 10:22:27 +01:00
thankyouverycool
ef30073127 LibGUI: Let Delete remove selections greater than 1 in GlyphMapWidget
Updates keydown_event() to work with the new bubbling mechanism
for action shortcuts.
2022-11-19 15:41:09 +01:00
thankyouverycool
9725fd162f LibGUI+Applications: Allow GlyphMapWidget's set_font() to fail
And TRY early during initialization in FontEditor to leave the app
in a valid state on error. Fixes OOM crashes when cloning the original
font for highlight modifications.
2022-11-19 15:41:09 +01:00
thankyouverycool
d9fb838cf6 LibGUI+FontEditor: Allow system emoji to be toggled in GlyphMapWidget
And remove their red backgrounds when visible to not be confused with
deletion highlights.
2022-11-19 15:41:09 +01:00
Sam Atkins
014d825472 LibGUI: Allow GlyphMapWidget to highlight modified glyphs
This makes modifications in FontEditor more visible, both so you know
what you've changed, and for taking a handy "here's what's changed"
screenshot for a font PR. :^)

The background color for new glyphs is green, modified glyphs is blue,
and deleted glyphs is red. The changes persist until you load a new
font file, so you can continue saving your work as you go and still be
able to take a convenient screenshot at the end.

I didn't feel like this one use was enough to add 3 new color roles to
themes, so to make this look decent on dark themes, it detects if the
theme is marked as dark, and uses darker colors for the highlights
which look nice with a light text color.
2022-08-14 13:59:19 +01:00
Simon Wanner
206d6ece55 LibGfx: Move other font-related files to LibGfx/Font/ 2022-04-09 23:48:18 +02:00
thankyouverycool
b8cc18896f LibGUI+FontEditor: Add context menu for editor actions
GlyphMapWidget now reports context menu requests when secondary
clicking the map. This also adds a new Select All action and updates
the Copy Character action to work on multi-glyph selections. Glyph
navigation actions have been moved to a separate Go menu, as is
common in other apps.
2022-03-20 20:00:25 +01:00
thankyouverycool
df443863bd LibGUI: Add set_selection() convenience helper to GlyphMapWidget 2022-03-20 20:00:25 +01:00
thankyouverycool
5c6326ae23 LibGUI: Add automatic scrolling to GlyphMapWidget
Similar to TextEditor, GlyphMapWidget now automatically scrolls
when dragging a selection outside its boundaries.
2022-03-20 20:00:25 +01:00
thankyouverycool
a26e71a137 LibGUI: Use system theme when painting GlyphMapWidget focus outline 2022-03-20 20:00:25 +01:00
thankyouverycool
cf13cf7225 LibGUI: Reset GlyphMapWidget only if clicking a new active glyph
Fixes an edge case in which mousing down on the active glyph within
a larger selection would reset the selection but fail to update the
glyph map. Now we can grow or shrink the selection by dragging the
active glyph even after an initial selection is made.
2022-03-20 20:00:25 +01:00
thankyouverycool
4f7b37de9c LibGUI: Use nicer API for contrained positions in GlyphMapWidget
Forgot about this little guy. Functionally the same here, but more
robust if scrollbars change.
2022-03-20 20:00:25 +01:00
thankyouverycool
54634fc2df LibGUI: Remove unnecessary MouseEvent calls in GlyphMapWidget
And pass KeyEvents directly to the relevant predecessor.
2022-03-20 20:00:25 +01:00
Maciej
a95794a356 LibGUI: Clamp selection when drag-selecting over out of range area 2022-03-17 17:05:56 +01:00
Maciej
bee9cd2113 LibGUI: Update active glyph when drag-selecting in GlyphMapWidget
This matches behavior of text selecting
2022-03-17 17:05:56 +01:00
Maciej
d3836f982a LibGUI: Use different color for GlyphMapWidget background
This patch makes background a bit darkened so that it is possible to
distinguish out of range area from glyphs that are just not drawn.

The default background color is also changed to Window so that it looks
good in more themes.
2022-03-17 17:05:56 +01:00
Lenny Maiorani
fe3b846ac8 Libraries: Use default constructors/destructors in LibGUI
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-12 14:44:43 -08:00
thankyouverycool
170afc2f47 LibGUI: Allow GlyphMapWidget to filter by code point ranges 2022-02-15 10:13:19 -05:00
thankyouverycool
66e72ed5e6 LibGUI: Allow selecting glyphs by dragging in GlyphMapWidget 2022-01-16 21:36:39 +01:00
Sam Atkins
e975db23c0 LibGUI+FontEditor: Move seek-prev/next-glyph logic into GlyphMapWidget 2022-01-16 11:17:03 +01:00
Sam Atkins
ff500ffcc4 LibGUI: Add on_glyph_double_clicked() callback to GlyphMapWidget
This will be used by CharacterMap.

In implementing this, extracted the logic for finding which glyph is at
a given position within the widget.
2022-01-16 11:17:03 +01:00
Sam Atkins
1d79e8cb0f LibGUI: Preserve glyph selection when changing font 2022-01-16 11:17:03 +01:00
Sam Atkins
15a7dfbc30 LibGUI: Recalculate GlyphMapWidget content size when changing font
Previously, if it was displaying N glyphs per line, then you changed
font to one that was a drastically different size, it would continue to
display N glyphs per line until you resized the window. Now, we
immediately recalculate how many to show, so that they fill the
available width. :^)
2022-01-16 11:17:03 +01:00
Sam Atkins
21a24c36a8 LibGUI: Make GlyphMapWidget work with vector fonts
This basically just meant replacing the `m_font` field with the one
inherited from Widget.
2022-01-16 11:17:03 +01:00
Sam Atkins
8175cd0a28 LibGUI+FontEditor: Move GlyphMapWidget to LibGUI
This will allow us to use this in other apps, such as the upcoming
Character Map. :^)
2022-01-16 11:17:03 +01:00
Renamed from Userland/Applications/FontEditor/GlyphMapWidget.cpp (Browse further)