|
20 | 20 | */ |
21 | 21 |
|
22 | 22 | #include <lsp-plug.in/tk/tk.h> |
| 23 | +#include <lsp-plug.in/tk/helpers/draw.h> |
23 | 24 | #include <lsp-plug.in/common/debug.h> |
24 | 25 | #include <lsp-plug.in/stdlib/math.h> |
25 | 26 | #include <lsp-plug.in/ipc/Process.h> |
@@ -288,39 +289,10 @@ namespace lsp |
288 | 289 | // Draw background |
289 | 290 | s->clear(bg_color); |
290 | 291 |
|
291 | | - float halign = lsp_limit(sTextLayout.halign() + 1.0f, 0.0f, 2.0f); |
292 | | - float valign = lsp_limit(sTextLayout.valign() + 1.0f, 0.0f, 2.0f); |
293 | | - float dy = (r.nHeight - tp.Height) * 0.5f; |
294 | | - ssize_t y = r.nTop + dy * valign - fp.Descent; |
295 | | - |
296 | | - // Estimate text size |
297 | | - ssize_t last = 0, curr = 0, tail = 0, len = text.length(); |
298 | | - |
299 | | - while (curr < len) |
300 | | - { |
301 | | - // Get next line indexes |
302 | | - curr = text.index_of(last, '\n'); |
303 | | - if (curr < 0) |
304 | | - { |
305 | | - curr = len; |
306 | | - tail = len; |
307 | | - } |
308 | | - else |
309 | | - { |
310 | | - tail = curr; |
311 | | - if ((tail > last) && (text.at(tail-1) == '\r')) |
312 | | - --tail; |
313 | | - } |
314 | | - |
315 | | - // Calculate text location |
316 | | - sFont.get_text_parameters(s, &tp, fscaling, &text, last, tail); |
317 | | - float dx = (r.nWidth - tp.Width) * 0.5f; |
318 | | - ssize_t x = r.nLeft + dx * halign - tp.XBearing; |
319 | | - y += fp.Height; |
320 | | - |
321 | | - sFont.draw(s, f_color, x, y, fscaling, &text, last, tail); |
322 | | - last = curr + 1; |
323 | | - } |
| 292 | + draw_multiline_text(s, |
| 293 | + &sFont, &r, f_color, &fp, &tp, |
| 294 | + sTextLayout.halign(), sTextLayout.valign(), |
| 295 | + fscaling, &text); |
324 | 296 | } |
325 | 297 |
|
326 | 298 | status_t Hyperlink::create_default_menu() |
|
0 commit comments