fix RTL bug when used with traffic light repositioning (#22132)
This commit is contained in:
parent
023a3ca722
commit
fe5318d753
1 changed files with 11 additions and 1 deletions
|
@ -542,17 +542,27 @@ void NativeWindowMac::RepositionTrafficLights() {
|
||||||
CGFloat buttonHeight = [close frame].size.height;
|
CGFloat buttonHeight = [close frame].size.height;
|
||||||
CGFloat titleBarFrameHeight = buttonHeight + traffic_light_position_.y();
|
CGFloat titleBarFrameHeight = buttonHeight + traffic_light_position_.y();
|
||||||
CGRect titleBarRect = titleBarContainerView.frame;
|
CGRect titleBarRect = titleBarContainerView.frame;
|
||||||
|
CGFloat titleBarWidth = NSWidth(titleBarRect);
|
||||||
titleBarRect.size.height = titleBarFrameHeight;
|
titleBarRect.size.height = titleBarFrameHeight;
|
||||||
titleBarRect.origin.y = window.frame.size.height - titleBarFrameHeight;
|
titleBarRect.origin.y = window.frame.size.height - titleBarFrameHeight;
|
||||||
[titleBarContainerView setFrame:titleBarRect];
|
[titleBarContainerView setFrame:titleBarRect];
|
||||||
|
|
||||||
|
BOOL isRTL = [titleBarContainerView userInterfaceLayoutDirection] ==
|
||||||
|
NSUserInterfaceLayoutDirectionRightToLeft;
|
||||||
NSArray* windowButtons = @[ close, miniaturize, zoom ];
|
NSArray* windowButtons = @[ close, miniaturize, zoom ];
|
||||||
const CGFloat space_between =
|
const CGFloat space_between =
|
||||||
[miniaturize frame].origin.x - [close frame].origin.x;
|
[miniaturize frame].origin.x - [close frame].origin.x;
|
||||||
for (NSUInteger i = 0; i < windowButtons.count; i++) {
|
for (NSUInteger i = 0; i < windowButtons.count; i++) {
|
||||||
NSView* view = [windowButtons objectAtIndex:i];
|
NSView* view = [windowButtons objectAtIndex:i];
|
||||||
CGRect rect = [view frame];
|
CGRect rect = [view frame];
|
||||||
rect.origin.x = traffic_light_position_.x() + (i * space_between);
|
if (isRTL) {
|
||||||
|
CGFloat buttonWidth = NSWidth(rect);
|
||||||
|
// origin is always top-left, even in RTL
|
||||||
|
rect.origin.x = titleBarWidth - traffic_light_position_.x() +
|
||||||
|
(i * space_between) - buttonWidth;
|
||||||
|
} else {
|
||||||
|
rect.origin.x = traffic_light_position_.x() + (i * space_between);
|
||||||
|
}
|
||||||
rect.origin.y = (titleBarFrameHeight - rect.size.height) / 2;
|
rect.origin.y = (titleBarFrameHeight - rect.size.height) / 2;
|
||||||
[view setFrameOrigin:rect.origin];
|
[view setFrameOrigin:rect.origin];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue