MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / selectionDetails

Function selectionDetails

player/NymphCastPlayer/container_qpainter.cpp:177–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175}
176
177static Selection::Element selectionDetails(const litehtml::element::ptr &element,
178 const QString &text,
179 const QPoint &pos)
180{
181 // shortcut, which _might_ not really be correct
182 if (element->get_children_count() > 0)
183 return {element, -1, -1}; // everything selected
184 const QFont &font = toQFont(element->get_font());
185 const QFontMetrics fm(font);
186 int previous = 0;
187 for (int i = 0; i < text.size(); ++i) {
188 const int width = fm.size(0, text.left(i + 1)).width();
189 if ((width + previous) / 2 >= pos.x())
190 return {element, i, previous};
191 previous = width;
192 }
193 return {element, int(text.size()), previous};
194}
195
196static Selection::Element deepest_child_at_point(const litehtml::document::ptr &document,
197 const QPoint &pos,

Callers 1

deepest_child_at_pointFunction · 0.85

Calls 6

toQFontFunction · 0.85
get_children_countMethod · 0.80
get_fontMethod · 0.45
sizeMethod · 0.45
widthMethod · 0.45
leftMethod · 0.45

Tested by

no test coverage detected