use constants for defaults, use namespaces

This commit is contained in:
yggverse 2024-07-21 18:29:02 +03:00
parent ea30508f52
commit a8b2fa0d23
15 changed files with 55 additions and 41 deletions

View file

@ -14,7 +14,7 @@ abstract class Markup
public Content $content;
// Defaults
protected int $_wrap = 140;
public const WRAP = 140;
public function __construct(
Content $content

View file

@ -4,12 +4,14 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar;
use \Yggverse\Yoda\Entity\Browser\History\Container\Navbar;
abstract class Button extends \Yggverse\Yoda\Abstract\Entity\Button
{
public \Yggverse\Yoda\Entity\Browser\History\Container\Navbar $navbar;
public Navbar $navbar;
public function __construct(
\Yggverse\Yoda\Entity\Browser\History\Container\Navbar $navbar
Navbar $navbar
) {
parent::__construct();

View file

@ -4,12 +4,14 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar;
use \Yggverse\Yoda\Entity\Browser\History\Container\Navbar;
abstract class Entry extends \Yggverse\Yoda\Abstract\Entity\Entry
{
public \Yggverse\Yoda\Entity\Browser\History\Container\Navbar $navbar;
public Navbar $navbar;
public function __construct(
\Yggverse\Yoda\Entity\Browser\History\Container\Navbar $navbar
Navbar $navbar
) {
parent::__construct();

View file

@ -8,19 +8,19 @@ abstract class Button
{
public \GtkButton $gtk;
protected bool $_sensitive = false;
protected string $_label = 'Button';
public const SENSITIVE = false;
public const LABEL = 'Button';
public function __construct()
{
$this->gtk = new \GtkButton;
$this->gtk->set_sensitive(
$this->_sensitive
$this::SENSITIVE
);
$this->gtk->set_label(
_($this->_label)
_($this::LABEL)
);
// Render

View file

@ -8,29 +8,29 @@ abstract class Entry
{
public \GtkEntry $gtk;
protected int $_length = 1024;
protected string $_placeholder = '';
protected string $_value = '';
protected bool $_visible = true;
public const LENGTH = 1024;
public const PLACEHOLDER = '';
public const VALUE = '';
public const VISIBLE = true;
public function __construct()
{
$this->gtk = new \GtkEntry;
$this->gtk->set_placeholder_text(
_($this->_placeholder)
_($this::PLACEHOLDER)
);
$this->gtk->set_max_length(
$this->_length
$this::LENGTH
);
$this->gtk->set_text(
_($this->_value)
_($this::VALUE)
);
$this->gtk->set_visibility(
$this->_visible
$this::VISIBLE
);
// Render
@ -105,22 +105,22 @@ abstract class Entry
): void;
public function setLength(
?int $value = null
?int $length = null
): void
{
$this->gtk->set_max_length(
is_null($value) ? $this->_length : $value
is_null($length) ? $this::LENGTH : $length
);
}
public function setPlaceholder(
?string $value = null
?string $placeholder = null
): void
{
$this->gtk->set_placeholder_text(
is_null($value) ? $this->_value : trim(
is_null($placeholder) ? $this::PLACEHOLDER : trim(
strval(
$value
$placeholder
)
)
);
@ -131,7 +131,7 @@ abstract class Entry
): void
{
$this->gtk->set_text(
is_null($value) ? $this->_value : trim(
is_null($value) ? $this::VALUE : trim(
strval(
$value
)
@ -140,11 +140,11 @@ abstract class Entry
}
public function setVisible(
?bool $value = null
?bool $visible = null
): void
{
$this->gtk->set_visibility(
is_null($value) ? $this->_visible : $value
is_null($visible) ? $this::VISIBLE : $visible
);
}