Skip to content

Feature/menubar improvement #411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions src/MenuBar/MenuBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ class MenuBar

protected string $label = '';

protected bool $onlyShowContextWindow = false;
protected string $tooltip = '';

protected bool $resizable = true;

protected bool $onlyShowContextMenu = false;

protected ?Menu $contextMenu = null;

protected bool $alwaysOnTop = false;

protected ?string $event = null;

protected bool $showDockIcon = false;

protected Client $client;
Expand All @@ -51,28 +57,35 @@ public function icon(string $icon): self

public function onlyShowContextMenu(bool $onlyContextMenu = true): self
{
$this->onlyShowContextWindow = $onlyContextMenu;
$this->onlyShowContextMenu = $onlyContextMenu;

return $this;
}

public function url(string $url): self
public function showDockIcon($value = true): self
{
$this->url = $url;
$this->showDockIcon = $value;

return $this;
}

public function showDockIcon($value = true): self
public function label(string $label = ''): self
{
$this->showDockIcon = $value;
$this->label = $label;

return $this;
}

public function label(string $label = ''): self
public function tooltip(string $tooltip = ''): self
{
$this->label = $label;
$this->tooltip = $tooltip;

return $this;
}

public function resizable(bool $resizable = true): static
{
$this->resizable = $resizable;

return $this;
}
Expand All @@ -84,6 +97,13 @@ public function alwaysOnTop($alwaysOnTop = true): self
return $this;
}

public function event(string $event): self
{
$this->event = $event;

return $this;
}

public function withContextMenu(Menu $menu): self
{
$this->contextMenu = $menu;
Expand All @@ -100,15 +120,18 @@ public function toArray(): array
'x' => $this->x,
'y' => $this->y,
'label' => $this->label,
'tooltip' => $this->tooltip,
'resizable' => $this->resizable,
'width' => $this->width,
'height' => $this->height,
'vibrancy' => $this->vibrancy,
'showDockIcon' => $this->showDockIcon,
'transparency' => $this->transparent,
'backgroundColor' => $this->backgroundColor,
'onlyShowContextWindow' => $this->onlyShowContextWindow,
'onlyShowContextMenu' => $this->onlyShowContextMenu,
'contextMenu' => ! is_null($this->contextMenu) ? $this->contextMenu->toArray()['submenu'] : null,
'alwaysOnTop' => $this->alwaysOnTop,
'event' => $this->event,
];
}
}
14 changes: 14 additions & 0 deletions src/MenuBar/MenuBarManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ public function label(string $label)
]);
}

public function tooltip(string $tooltip)
{
$this->client->post('menu-bar/tooltip', [
'tooltip' => $tooltip,
]);
}

public function icon(string $icon)
{
$this->client->post('menu-bar/icon', [
'icon' => $icon,
]);
}

public function contextMenu(Menu $contextMenu)
{
$this->client->post('menu-bar/context-menu', [
Expand Down
Loading