mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
use label widget as contain destroy method to free memory on width rule iteration
This commit is contained in:
parent
1ef9c91b64
commit
5b3f0c2497
1 changed files with 9 additions and 6 deletions
|
|
@ -4,8 +4,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Yggverse\Yoda\Abstract\Model\Gtk\Pango;
|
namespace Yggverse\Yoda\Abstract\Model\Gtk\Pango;
|
||||||
|
|
||||||
use \PangoLayout;
|
use \GtkLabel;
|
||||||
use \GtkDrawingArea;
|
|
||||||
|
|
||||||
class Markup implements \Yggverse\Yoda\Interface\Model\Gtk\Pango\Markup
|
class Markup implements \Yggverse\Yoda\Interface\Model\Gtk\Pango\Markup
|
||||||
{
|
{
|
||||||
|
|
@ -143,16 +142,20 @@ class Markup implements \Yggverse\Yoda\Interface\Model\Gtk\Pango\Markup
|
||||||
string $markup
|
string $markup
|
||||||
): ?int
|
): ?int
|
||||||
{
|
{
|
||||||
$layout = new PangoLayout( // @TODO cleanup
|
$label = new GtkLabel;
|
||||||
(new GtkDrawingArea)->create_pango_context()
|
|
||||||
|
$label->set_use_markup(
|
||||||
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
$layout->set_markup(
|
$label->set_markup(
|
||||||
$markup, -1
|
$markup, -1
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($size = $layout->get_pixel_size())
|
if ($size = $label->get_layout()->get_pixel_size())
|
||||||
{
|
{
|
||||||
|
$label->destroy();
|
||||||
|
|
||||||
return $size['width'];
|
return $size['width'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue