mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +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
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue