@@ -30,7 +30,6 @@ pub struct PlatformTitleBar {
platform_style: PlatformStyle,
children: SmallVec<[AnyElement; 2]>,
should_move: bool,
- background_color: Option<Hsla>,
system_window_tabs: Entity<SystemWindowTabs>,
}
@@ -44,16 +43,11 @@ impl PlatformTitleBar {
platform_style,
children: SmallVec::new(),
should_move: false,
- background_color: None,
system_window_tabs,
}
}
pub fn title_bar_color(&self, window: &mut Window, cx: &mut Context<Self>) -> Hsla {
- if let Some(background_color) = self.background_color {
- return background_color;
- }
-
if cfg!(any(target_os = "linux", target_os = "freebsd")) {
if window.is_window_active() && !self.should_move {
cx.theme().colors().title_bar_background
@@ -72,10 +66,6 @@ impl PlatformTitleBar {
self.children = children.into_iter().collect();
}
- pub fn set_background_color(&mut self, background_color: Option<Hsla>) {
- self.background_color = background_color;
- }
-
pub fn init(cx: &mut App) {
SystemWindowTabs::init(cx);
}
@@ -3,9 +3,9 @@ use collections::{HashMap, HashSet};
use editor::{CompletionProvider, SelectionEffects};
use editor::{CurrentLineHighlight, Editor, EditorElement, EditorEvent, EditorStyle, actions::Tab};
use gpui::{
- App, Bounds, DEFAULT_ADDITIONAL_WINDOW_SIZE, Entity, EventEmitter, Focusable, MouseButton,
- PromptLevel, Subscription, Task, TextStyle, Tiling, TitlebarOptions, WindowBounds,
- WindowHandle, WindowOptions, actions, point, size, transparent_black,
+ App, Bounds, DEFAULT_ADDITIONAL_WINDOW_SIZE, Entity, EventEmitter, Focusable, PromptLevel,
+ Subscription, Task, TextStyle, Tiling, TitlebarOptions, WindowBounds, WindowHandle,
+ WindowOptions, actions, point, size, transparent_black,
};
use language::{Buffer, LanguageRegistry, language_settings::SoftWrap};
use language_model::{
@@ -133,7 +133,6 @@ pub fn open_rules_library(
window_decorations: Some(window_decorations),
window_min_size: Some(DEFAULT_ADDITIONAL_WINDOW_SIZE),
kind: gpui::WindowKind::Floating,
- is_movable: !cfg!(target_os = "macos"),
..Default::default()
},
|window, cx| {
@@ -504,7 +503,11 @@ impl RulesLibrary {
});
Self {
- title_bar: Some(cx.new(|cx| PlatformTitleBar::new("rules-library-title-bar", cx))),
+ title_bar: if !cfg!(target_os = "macos") {
+ Some(cx.new(|cx| PlatformTitleBar::new("rules-library-title-bar", cx)))
+ } else {
+ None
+ },
store,
language_registry,
rule_editors: HashMap::default(),
@@ -1126,44 +1129,30 @@ impl RulesLibrary {
v_flex()
.id("rule-list")
.capture_action(cx.listener(Self::focus_active_rule))
+ .px_1p5()
.h_full()
.w_64()
.overflow_x_hidden()
.bg(cx.theme().colors().panel_background)
- .when(!cfg!(target_os = "macos"), |this| this.px_1p5())
.map(|this| {
if cfg!(target_os = "macos") {
- let Some(title_bar) = self.title_bar.as_ref() else {
- return this;
- };
- let button_padding = DynamicSpacing::Base08.rems(cx);
- let panel_background = cx.theme().colors().panel_background;
- title_bar.update(cx, |title_bar, _cx| {
- title_bar.set_background_color(Some(panel_background));
- title_bar.set_children(Some(
- h_flex()
- .w_full()
- .pr(button_padding)
- .justify_end()
- .child(
- div()
- .on_mouse_down(MouseButton::Left, |_, _, cx| {
- cx.stop_propagation();
- })
- .child(
- IconButton::new("new-rule", IconName::Plus)
- .tooltip(move |_window, cx| {
- Tooltip::for_action("New Rule", &NewRule, cx)
- })
- .on_click(|_, window, cx| {
- window.dispatch_action(Box::new(NewRule), cx);
- }),
- ),
- )
- .into_any_element(),
- ));
- });
- this.child(title_bar.clone())
+ this.child(
+ h_flex()
+ .p(DynamicSpacing::Base04.rems(cx))
+ .h_9()
+ .w_full()
+ .flex_none()
+ .justify_end()
+ .child(
+ IconButton::new("new-rule", IconName::Plus)
+ .tooltip(move |_window, cx| {
+ Tooltip::for_action("New Rule", &NewRule, cx)
+ })
+ .on_click(|_, window, cx| {
+ window.dispatch_action(Box::new(NewRule), cx);
+ }),
+ ),
+ )
} else {
this.child(
h_flex().p_1().w_full().child(
@@ -1182,12 +1171,7 @@ impl RulesLibrary {
)
}
})
- .child(
- div()
- .flex_grow()
- .when(cfg!(target_os = "macos"), |this| this.px_1p5())
- .child(self.picker.clone()),
- )
+ .child(div().flex_grow().child(self.picker.clone()))
}
fn render_active_rule_editor(
@@ -1434,9 +1418,7 @@ impl Render for RulesLibrary {
.overflow_hidden()
.font(ui_font)
.text_color(theme.colors().text)
- .when(!cfg!(target_os = "macos"), |this| {
- this.children(self.title_bar.clone())
- })
+ .children(self.title_bar.clone())
.bg(theme.colors().background)
.child(
h_flex()