Skip to content

Commit

Permalink
Implement trafficLightPosition() method on Window (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarukomine authored May 24, 2024
1 parent 91adb88 commit d88fe14
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Windows/Window.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class Window

protected string $titleBarStyle = 'default';

protected array $trafficLightPosition = [];

protected string $title = '';

protected string $id = 'main';
Expand Down Expand Up @@ -88,6 +90,13 @@ public function titleBarHiddenInset(): self
return $this->titleBarStyle('hiddenInset');
}

public function trafficLightPosition(int $x, int $y): self
{
$this->trafficLightPosition = ['x' => $x, 'y' => $y];

return $this;
}

public function rememberState(): self
{
$this->rememberState = true;
Expand Down Expand Up @@ -225,6 +234,7 @@ public function toArray()
'hasShadow' => $this->hasShadow,
'frame' => $this->frame,
'titleBarStyle' => $this->titleBarStyle,
'trafficLightPosition' => $this->trafficLightPosition,
'showDevTools' => $this->showDevTools,
'vibrancy' => $this->vibrancy,
'transparency' => $this->transparent,
Expand Down
19 changes: 19 additions & 0 deletions tests/Windows/WindowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@
expect($window->toArray()['titleBarStyle'])->toBe('customButtonsOnHover');
});

it('test for trafficLightPosition in window', function () {
$window = Window::open()
->trafficLightPosition(10, 10);

expect($window->toArray()['trafficLightPosition'])
->toBeArray()
->toHaveKeys(['x', 'y'])
->toHaveLength(2)
->toMatchArray(['x' => 10, 'y' => 10]);

$window->trafficLightPosition(5, 15);

expect($window->toArray()['trafficLightPosition'])
->toBeArray()
->toHaveKeys(['x', 'y'])
->toHaveLength(2)
->toMatchArray(['x' => 5, 'y' => 15]);
});

it('test for invisibleFrameless in window', function () {
$window = Window::open()->invisibleFrameless();
$windowArray = $window->toArray();
Expand Down

0 comments on commit d88fe14

Please sign in to comment.