Skip to content

Commit 7a675b0

Browse files
committedJul 14, 2024·
Merge branch 'skia_2024'
1 parent 33059c9 commit 7a675b0

File tree

3 files changed

+62
-11
lines changed

3 files changed

+62
-11
lines changed
 

‎lib/host/macos/base_view.mm

+24-2
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,9 @@ void clipboard(std::string const& text)
751751
forType:NSPasteboardTypeString];
752752
}
753753

754+
#pragma clang diagnostic push
755+
#pragma clang diagnostic ignored "-Wundeclared-selector"
756+
754757
void set_cursor(cursor_type type)
755758
{
756759
switch (type)
@@ -768,13 +771,32 @@ void set_cursor(cursor_type type)
768771
[[NSCursor openHandCursor] set];
769772
break;
770773
case cursor_type::h_resize:
771-
[[NSCursor resizeLeftRightCursor] set];
774+
{
775+
NSCursor* cursor = [NSCursor performSelector:@selector(_windowResizeEastWestCursor)];
776+
[cursor set];
772777
break;
778+
}
773779
case cursor_type::v_resize:
774-
[[NSCursor resizeUpDownCursor] set];
780+
{
781+
NSCursor* cursor = [NSCursor performSelector:@selector(_windowResizeNorthSouthCursor)];
782+
[cursor set];
783+
break;
784+
}
785+
case cursor_type::ne_resize:
786+
{
787+
NSCursor* cursor = [NSCursor performSelector:@selector(_windowResizeNorthWestSouthEastCursor)];
788+
[cursor set];
789+
break;
790+
}
791+
case cursor_type::sw_resize:
792+
{
793+
NSCursor* cursor = [NSCursor performSelector:@selector(_windowResizeNorthEastSouthWestCursor)];
794+
[cursor set];
775795
break;
796+
}
776797
}
777798
}
799+
#pragma clang diagnostic pop
778800

779801
point scroll_direction()
780802
{

‎lib/include/elements/base_view.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,9 @@ namespace cycfi::elements
385385
cross_hair,
386386
hand,
387387
h_resize,
388-
v_resize
388+
v_resize,
389+
ne_resize,
390+
sw_resize
389391
};
390392

391393
void set_cursor(cursor_type type);

‎lib/src/element/child_window.cpp

+35-8
Original file line numberDiff line numberDiff line change
@@ -130,20 +130,47 @@ namespace cycfi::elements
130130
if (ctx.enabled && is_enabled() && ctx.bounds.includes(p) && !inner.includes(p))
131131
{
132132
auto const& b = ctx.bounds;
133-
bool h_resize = false;
134-
bool v_resize = false;
133+
bool l_resize = false;
134+
bool r_resize = false;
135+
bool t_resize = false;
136+
bool b_resize = false;
135137
if (p.x > b.left && p.x < b.left + resize_margin)
136-
h_resize = true;
138+
l_resize = true;
137139
else if (p.x > b.right - resize_margin && p.x < b.right)
138-
h_resize = true;
140+
r_resize = true;
139141

140142
if (p.y > b.top && p.y < b.top + resize_margin)
141-
v_resize = true;
143+
t_resize = true;
142144
else if (p.y > b.bottom - resize_margin && p.y < b.bottom)
143-
v_resize = true;
145+
b_resize = true;
146+
147+
if (l_resize)
148+
{
149+
if (t_resize)
150+
set_cursor(cursor_type::ne_resize);
151+
else if (b_resize)
152+
set_cursor(cursor_type::sw_resize);
153+
else
154+
set_cursor(cursor_type::h_resize);
155+
}
156+
else if (r_resize)
157+
{
158+
if (t_resize)
159+
set_cursor(cursor_type::sw_resize);
160+
else if (b_resize)
161+
set_cursor(cursor_type::ne_resize);
162+
else
163+
set_cursor(cursor_type::h_resize);
164+
}
165+
else if (t_resize || b_resize)
166+
{
167+
set_cursor(cursor_type::v_resize);
168+
}
169+
else
170+
{
171+
set_cursor(cursor_type::arrow);
172+
}
144173

145-
if (h_resize != v_resize)
146-
set_cursor(h_resize? cursor_type::h_resize : cursor_type::v_resize);
147174
return true;
148175
}
149176
return r;

0 commit comments

Comments
 (0)
Please sign in to comment.