Skip to content

Commit d88fe14

Browse files
authored
Implement trafficLightPosition() method on Window (#310)
1 parent 91adb88 commit d88fe14

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/Windows/Window.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ class Window
4343

4444
protected string $titleBarStyle = 'default';
4545

46+
protected array $trafficLightPosition = [];
47+
4648
protected string $title = '';
4749

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

93+
public function trafficLightPosition(int $x, int $y): self
94+
{
95+
$this->trafficLightPosition = ['x' => $x, 'y' => $y];
96+
97+
return $this;
98+
}
99+
91100
public function rememberState(): self
92101
{
93102
$this->rememberState = true;
@@ -225,6 +234,7 @@ public function toArray()
225234
'hasShadow' => $this->hasShadow,
226235
'frame' => $this->frame,
227236
'titleBarStyle' => $this->titleBarStyle,
237+
'trafficLightPosition' => $this->trafficLightPosition,
228238
'showDevTools' => $this->showDevTools,
229239
'vibrancy' => $this->vibrancy,
230240
'transparency' => $this->transparent,

tests/Windows/WindowTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,25 @@
5858
expect($window->toArray()['titleBarStyle'])->toBe('customButtonsOnHover');
5959
});
6060

61+
it('test for trafficLightPosition in window', function () {
62+
$window = Window::open()
63+
->trafficLightPosition(10, 10);
64+
65+
expect($window->toArray()['trafficLightPosition'])
66+
->toBeArray()
67+
->toHaveKeys(['x', 'y'])
68+
->toHaveLength(2)
69+
->toMatchArray(['x' => 10, 'y' => 10]);
70+
71+
$window->trafficLightPosition(5, 15);
72+
73+
expect($window->toArray()['trafficLightPosition'])
74+
->toBeArray()
75+
->toHaveKeys(['x', 'y'])
76+
->toHaveLength(2)
77+
->toMatchArray(['x' => 5, 'y' => 15]);
78+
});
79+
6180
it('test for invisibleFrameless in window', function () {
6281
$window = Window::open()->invisibleFrameless();
6382
$windowArray = $window->toArray();

0 commit comments

Comments
 (0)