Integrate macOS window controls and fix palette text rendering
Center native window controls in the draggable tab bar. Preserve full text runs during GPUI layout and let AppKit compose text in palette and rename fields.
This commit is contained in:
Vendored
+17
-9
@@ -316,6 +316,7 @@ struct TextLayoutInner {
|
||||
lines: SmallVec<[WrappedLine; 1]>,
|
||||
line_height: Pixels,
|
||||
wrap_width: Option<Pixels>,
|
||||
truncate_width: Option<Pixels>,
|
||||
size: Option<Size<Pixels>>,
|
||||
bounds: Option<Bounds<Pixels>>,
|
||||
}
|
||||
@@ -334,7 +335,7 @@ impl TextLayout {
|
||||
.line_height
|
||||
.to_pixels(font_size.into(), window.rem_size());
|
||||
|
||||
let mut runs = if let Some(runs) = runs {
|
||||
let runs = if let Some(runs) = runs {
|
||||
runs
|
||||
} else {
|
||||
vec![text_style.to_run(text.len())]
|
||||
@@ -372,19 +373,24 @@ impl TextLayout {
|
||||
|
||||
if let Some(text_layout) = element_state.0.borrow().as_ref()
|
||||
&& text_layout.size.is_some()
|
||||
&& (wrap_width.is_none() || wrap_width == text_layout.wrap_width)
|
||||
&& wrap_width == text_layout.wrap_width
|
||||
&& truncate_width == text_layout.truncate_width
|
||||
{
|
||||
return text_layout.size.unwrap();
|
||||
}
|
||||
|
||||
let mut line_wrapper = cx.text_system().line_wrapper(text_style.font(), font_size);
|
||||
// Flex layout may measure the same element at several widths. Each
|
||||
// measurement needs the original runs, including their full lengths.
|
||||
let mut runs = std::borrow::Cow::Borrowed(&runs);
|
||||
let text = if let Some(truncate_width) = truncate_width {
|
||||
line_wrapper.truncate_line(
|
||||
text.clone(),
|
||||
truncate_width,
|
||||
&truncation_suffix,
|
||||
&mut runs,
|
||||
)
|
||||
cx.text_system()
|
||||
.line_wrapper(text_style.font(), font_size)
|
||||
.truncate_line(
|
||||
text.clone(),
|
||||
truncate_width,
|
||||
&truncation_suffix,
|
||||
runs.to_mut(),
|
||||
)
|
||||
} else {
|
||||
text.clone()
|
||||
};
|
||||
@@ -406,6 +412,7 @@ impl TextLayout {
|
||||
len: 0,
|
||||
line_height,
|
||||
wrap_width,
|
||||
truncate_width,
|
||||
size: Some(Size::default()),
|
||||
bounds: None,
|
||||
});
|
||||
@@ -424,6 +431,7 @@ impl TextLayout {
|
||||
len,
|
||||
line_height,
|
||||
wrap_width,
|
||||
truncate_width,
|
||||
size: Some(size),
|
||||
bounds: None,
|
||||
});
|
||||
|
||||
+11
@@ -1498,6 +1498,17 @@ impl PlatformWindow for MacWindow {
|
||||
.detach()
|
||||
}
|
||||
|
||||
fn start_window_move(&self) {
|
||||
let window = self.0.lock().native_window;
|
||||
unsafe {
|
||||
let app = NSApplication::sharedApplication(nil);
|
||||
let event: id = msg_send![app, currentEvent];
|
||||
if !event.is_null() {
|
||||
let _: () = msg_send![window, performWindowDragWithEvent: event];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn titlebar_double_click(&self) {
|
||||
let this = self.0.lock();
|
||||
let window = this.native_window;
|
||||
|
||||
Reference in New Issue
Block a user