mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Userland: Draw tooltip over glyph to show UTF-8 code point
Currently finding a particular glyph with a given code point is a bit tedious as it requires clicking on the glyph to update the status bar and display the glyph's name and codepoint. A more convenient way to know where we are in the Glyph Map is by seeing a tooltip over the glyph where the mouse is currently hovering over. This patch adds that support by setting the Widget tooltip with the glyph found at the current position in GlyphMapWidget::mousemove_event.
This commit is contained in:
parent
3748f1d290
commit
f4515aae80
Notes:
sideshowbarker
2024-07-17 17:06:59 +09:00
Author: https://github.com/navadev Commit: https://github.com/SerenityOS/serenity/commit/f4515aae80 Pull-request: https://github.com/SerenityOS/serenity/pull/21404
2 changed files with 12 additions and 0 deletions
|
@ -247,6 +247,17 @@ void GlyphMapWidget::mouseup_event(GUI::MouseEvent& event)
|
|||
void GlyphMapWidget::mousemove_event(GUI::MouseEvent& event)
|
||||
{
|
||||
m_last_mousemove_position = event.position();
|
||||
if (auto maybe_glyph = glyph_at_position(event.position()); maybe_glyph.has_value() && maybe_glyph != m_tooltip_glyph) {
|
||||
m_tooltip_glyph = maybe_glyph.value();
|
||||
auto draw_tooltip = [this]() -> ErrorOr<void> {
|
||||
StringBuilder builder;
|
||||
TRY(builder.try_appendff("U+{:04X}", m_tooltip_glyph));
|
||||
set_tooltip(TRY(builder.to_string()));
|
||||
return {};
|
||||
}();
|
||||
if (draw_tooltip.is_error())
|
||||
warnln("Failed to draw tooltip");
|
||||
}
|
||||
if (m_in_drag_select) {
|
||||
auto constrained = event.position().constrained(widget_inner_rect());
|
||||
auto glyph = glyph_at_position_clamped(constrained);
|
||||
|
|
|
@ -111,6 +111,7 @@ private:
|
|||
int m_vertical_spacing { 4 };
|
||||
Selection m_selection;
|
||||
int m_active_glyph { 0 };
|
||||
int m_tooltip_glyph { 0 };
|
||||
int m_visible_glyphs { 0 };
|
||||
bool m_in_drag_select { false };
|
||||
bool m_highlight_modifications { false };
|
||||
|
|
Loading…
Reference in a new issue