mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-09 04:15:52 +00:00
nitpicker_gfx: Text_painter::Font::index_at_xpos
This method is useful for finding the character under a mouse position.
This commit is contained in:
parent
1273c573b6
commit
46c5a90ba1
@ -97,6 +97,20 @@ struct Text_painter
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned index_at_xpos(Genode::Utf8_ptr utf8, unsigned xpos) const
|
||||
{
|
||||
unsigned index = 0;
|
||||
Fixpoint_number x { (int)0 };
|
||||
|
||||
for (; utf8.complete(); utf8 = utf8.next(), index++) {
|
||||
x.value += advance_info(utf8.codepoint()).advance.value;
|
||||
if (x.decimal() > (int)xpos)
|
||||
break;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user