mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 00:55:28 +00:00
define dependencies
This commit is contained in:
parent
4f6445d167
commit
137b9926e1
7 changed files with 69 additions and 48 deletions
|
|
@ -4,11 +4,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Content;
|
||||
|
||||
use \GdkEvent;
|
||||
use \GtkLabel;
|
||||
|
||||
use \Yggverse\Yoda\Entity\Browser\Container\Page\Content;
|
||||
|
||||
abstract class Markup
|
||||
{
|
||||
public \GtkLabel $gtk;
|
||||
public GtkLabel $gtk;
|
||||
|
||||
// Dependencies
|
||||
public Content $content;
|
||||
|
|
@ -23,7 +26,7 @@ abstract class Markup
|
|||
$this->content = $content;
|
||||
|
||||
// Init markup label
|
||||
$this->gtk = new \GtkLabel;
|
||||
$this->gtk = new GtkLabel;
|
||||
|
||||
$this->gtk->set_use_markup(
|
||||
true
|
||||
|
|
@ -55,7 +58,7 @@ abstract class Markup
|
|||
$this->gtk->connect(
|
||||
'activate-link',
|
||||
function(
|
||||
\GtkLabel $label,
|
||||
GtkLabel $label,
|
||||
string $href
|
||||
) {
|
||||
return $this->_onActivateLink(
|
||||
|
|
@ -68,8 +71,8 @@ abstract class Markup
|
|||
$this->gtk->connect(
|
||||
'button-press-event',
|
||||
function(
|
||||
\GtkLabel $label,
|
||||
\GdkEvent $event
|
||||
GtkLabel $label,
|
||||
GdkEvent $event
|
||||
) {
|
||||
return $this->_onButtonPressEvent(
|
||||
$label,
|
||||
|
|
@ -80,13 +83,13 @@ abstract class Markup
|
|||
}
|
||||
|
||||
abstract protected function _onActivateLink(
|
||||
\GtkLabel $label,
|
||||
GtkLabel $label,
|
||||
string $href
|
||||
): bool;
|
||||
|
||||
abstract protected function _onButtonPressEvent(
|
||||
\GtkLabel $label,
|
||||
\GdkEvent $event
|
||||
GtkLabel $label,
|
||||
GdkEvent $event
|
||||
): bool;
|
||||
|
||||
abstract public function set(
|
||||
|
|
|
|||
|
|
@ -4,9 +4,16 @@ declare(strict_types=1);
|
|||
|
||||
namespace Yggverse\Yoda\Abstract\Entity;
|
||||
|
||||
use \Exception;
|
||||
|
||||
use \GtkButton;
|
||||
use \GtkIconSize;
|
||||
use \GtkIconTheme;
|
||||
use \GtkImage;
|
||||
|
||||
abstract class Button
|
||||
{
|
||||
public \GtkButton $gtk;
|
||||
public GtkButton $gtk;
|
||||
|
||||
public const SENSITIVE = false;
|
||||
public const IMAGE = null;
|
||||
|
|
@ -16,7 +23,7 @@ abstract class Button
|
|||
public function __construct()
|
||||
{
|
||||
// Init button
|
||||
$this->gtk = new \GtkButton;
|
||||
$this->gtk = new GtkButton;
|
||||
|
||||
if ($this::IMAGE)
|
||||
{
|
||||
|
|
@ -47,7 +54,7 @@ abstract class Button
|
|||
$this->gtk->connect(
|
||||
'clicked',
|
||||
function(
|
||||
\GtkButton $entity
|
||||
GtkButton $entity
|
||||
) {
|
||||
$this->_onClick(
|
||||
$entity
|
||||
|
|
@ -57,12 +64,12 @@ abstract class Button
|
|||
}
|
||||
|
||||
abstract protected function _onClick(
|
||||
\GtkButton $entity
|
||||
GtkButton $entity
|
||||
): void;
|
||||
|
||||
public function setImage(
|
||||
?string $image = null,
|
||||
int $size = \GtkIconSize::BUTTON
|
||||
int $size = GtkIconSize::BUTTON
|
||||
): void
|
||||
{
|
||||
switch (true)
|
||||
|
|
@ -74,7 +81,7 @@ abstract class Button
|
|||
):
|
||||
|
||||
$this->gtk->set_image(
|
||||
\GtkImage::new_from_file(
|
||||
GtkImage::new_from_file(
|
||||
$image,
|
||||
$size
|
||||
)
|
||||
|
|
@ -82,12 +89,12 @@ abstract class Button
|
|||
|
||||
break;
|
||||
|
||||
case \GtkIconTheme::get_default()->has_icon(
|
||||
case GtkIconTheme::get_default()->has_icon(
|
||||
$image
|
||||
):
|
||||
|
||||
$this->gtk->set_image(
|
||||
\GtkImage::new_from_icon_name(
|
||||
GtkImage::new_from_icon_name(
|
||||
$image,
|
||||
$size
|
||||
)
|
||||
|
|
@ -97,7 +104,7 @@ abstract class Button
|
|||
|
||||
default:
|
||||
|
||||
throw new \Exception;
|
||||
throw new Exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,9 +4,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Yggverse\Yoda\Abstract\Entity;
|
||||
|
||||
use \GdkEvent;
|
||||
use \GtkEntry;
|
||||
|
||||
abstract class Entry
|
||||
{
|
||||
public \GtkEntry $gtk;
|
||||
public GtkEntry $gtk;
|
||||
|
||||
public const LENGTH = 1024;
|
||||
public const PLACEHOLDER = '';
|
||||
|
|
@ -15,7 +18,7 @@ abstract class Entry
|
|||
|
||||
public function __construct()
|
||||
{
|
||||
$this->gtk = new \GtkEntry;
|
||||
$this->gtk = new GtkEntry;
|
||||
|
||||
$this->gtk->set_placeholder_text(
|
||||
_($this::PLACEHOLDER)
|
||||
|
|
@ -40,7 +43,7 @@ abstract class Entry
|
|||
$this->gtk->connect(
|
||||
'activate',
|
||||
function(
|
||||
\GtkEntry $entry
|
||||
GtkEntry $entry
|
||||
) {
|
||||
$this->_onActivate(
|
||||
$entry
|
||||
|
|
@ -51,8 +54,8 @@ abstract class Entry
|
|||
$this->gtk->connect(
|
||||
'key-release-event',
|
||||
function (
|
||||
\GtkEntry $entry,
|
||||
\GdkEvent $event
|
||||
GtkEntry $entry,
|
||||
GdkEvent $event
|
||||
) {
|
||||
$this->_onKeyRelease(
|
||||
$entry,
|
||||
|
|
@ -64,7 +67,7 @@ abstract class Entry
|
|||
$this->gtk->connect(
|
||||
'changed',
|
||||
function (
|
||||
\GtkEntry $entry
|
||||
GtkEntry $entry
|
||||
) {
|
||||
$this->_onChanged(
|
||||
$entry
|
||||
|
|
@ -75,8 +78,8 @@ abstract class Entry
|
|||
$this->gtk->connect(
|
||||
'focus-out-event',
|
||||
function (
|
||||
\GtkEntry $entry,
|
||||
\GdkEvent $event
|
||||
GtkEntry $entry,
|
||||
GdkEvent $event
|
||||
) {
|
||||
$this->_onFocusOut(
|
||||
$entry,
|
||||
|
|
@ -87,21 +90,21 @@ abstract class Entry
|
|||
}
|
||||
|
||||
abstract protected function _onActivate(
|
||||
\GtkEntry $entry
|
||||
GtkEntry $entry
|
||||
): void;
|
||||
|
||||
abstract protected function _onKeyRelease(
|
||||
\GtkEntry $entry,
|
||||
\GdkEvent $event
|
||||
GtkEntry $entry,
|
||||
GdkEvent $event
|
||||
): void;
|
||||
|
||||
abstract protected function _onChanged(
|
||||
\GtkEntry $entry
|
||||
GtkEntry $entry
|
||||
): void;
|
||||
|
||||
abstract protected function _onFocusOut(
|
||||
\GtkEntry $entry,
|
||||
\GdkEvent $event
|
||||
GtkEntry $entry,
|
||||
GdkEvent $event
|
||||
): void;
|
||||
|
||||
public function setLength(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue