UI size + other theme refinements (#3347)

[[PR Description]]

- Fixes bad titlebar states when the ui scale is set very low
- Tidies up a number of workspace styles

Release Notes:

- N/A
This commit is contained in:
Nate Butler
2023-11-16 16:30:47 -05:00
committed by GitHub
4 changed files with 28 additions and 15 deletions
+13 -7
View File
@@ -31,9 +31,9 @@ use std::sync::Arc;
use call::ActiveCall; use call::ActiveCall;
use client::{Client, UserStore}; use client::{Client, UserStore};
use gpui::{ use gpui::{
div, rems, AppContext, Component, Div, InteractiveComponent, Model, ParentComponent, Render, div, px, rems, AppContext, Component, Div, InteractiveComponent, Model, ParentComponent,
Stateful, StatefulInteractiveComponent, Styled, Subscription, ViewContext, VisualContext, Render, Stateful, StatefulInteractiveComponent, Styled, Subscription, ViewContext,
WeakView, WindowBounds, VisualContext, WeakView, WindowBounds,
}; };
use project::Project; use project::Project;
use theme::ActiveTheme; use theme::ActiveTheme;
@@ -88,12 +88,17 @@ impl Render for CollabTitlebarItem {
h_stack() h_stack()
.id("titlebar") .id("titlebar")
.justify_between() .justify_between()
.when(
!matches!(cx.window_bounds(), WindowBounds::Fullscreen),
|s| s.pl_20(),
)
.w_full() .w_full()
.h(rems(1.75)) .h(rems(1.75))
// Set a non-scaling min-height here to ensure the titlebar is
// always at least the height of the traffic lights.
.min_h(px(32.))
.when(
!matches!(cx.window_bounds(), WindowBounds::Fullscreen),
// Use pixels here instead of a rem-based size because the macOS traffic
// lights are a static size, and don't scale with the rest of the UI.
|s| s.pl(px(68.)),
)
.bg(cx.theme().colors().title_bar_background) .bg(cx.theme().colors().title_bar_background)
.on_click(|_, event, cx| { .on_click(|_, event, cx| {
if event.up.click_count == 2 { if event.up.click_count == 2 {
@@ -102,6 +107,7 @@ impl Render for CollabTitlebarItem {
}) })
.child( .child(
h_stack() h_stack()
.gap_1()
// TODO - Add player menu // TODO - Add player menu
.child( .child(
div() div()
+1
View File
@@ -178,6 +178,7 @@ impl<V: 'static> Button<V> {
.text_ui() .text_ui()
.rounded_md() .rounded_md()
.bg(self.variant.bg_color(cx)) .bg(self.variant.bg_color(cx))
.cursor_pointer()
.hover(|style| style.bg(self.variant.bg_color_hover(cx))) .hover(|style| style.bg(self.variant.bg_color_hover(cx)))
.active(|style| style.bg(self.variant.bg_color_active(cx))); .active(|style| style.bg(self.variant.bg_color_active(cx)));
+6 -7
View File
@@ -72,7 +72,7 @@ impl<V: 'static> IconButton<V> {
fn render(mut self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> { fn render(mut self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let icon_color = match (self.state, self.color) { let icon_color = match (self.state, self.color) {
(InteractionState::Disabled, _) => TextColor::Disabled, (InteractionState::Disabled, _) => TextColor::Disabled,
(InteractionState::Active, _) => TextColor::Error, (InteractionState::Active, _) => TextColor::Selected,
_ => self.color, _ => self.color,
}; };
@@ -95,17 +95,16 @@ impl<V: 'static> IconButton<V> {
.rounded_md() .rounded_md()
.p_1() .p_1()
.bg(bg_color) .bg(bg_color)
.cursor_pointer()
.hover(|style| style.bg(bg_hover_color)) .hover(|style| style.bg(bg_hover_color))
.active(|style| style.bg(bg_active_color)) .active(|style| style.bg(bg_active_color))
.child(IconElement::new(self.icon).color(icon_color)); .child(IconElement::new(self.icon).color(icon_color));
if let Some(click_handler) = self.handlers.click.clone() { if let Some(click_handler) = self.handlers.click.clone() {
button = button button = button.on_mouse_down(MouseButton::Left, move |state, event, cx| {
.on_mouse_down(MouseButton::Left, move |state, event, cx| { cx.stop_propagation();
cx.stop_propagation(); click_handler(state, cx);
click_handler(state, cx); })
})
.cursor_pointer();
} }
if let Some(tooltip) = self.tooltip.take() { if let Some(tooltip) = self.tooltip.take() {
+8 -1
View File
@@ -7,6 +7,7 @@ use gpui::{
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::sync::Arc; use std::sync::Arc;
use theme2::ActiveTheme;
use ui::{h_stack, IconButton, InteractionState, Tooltip}; use ui::{h_stack, IconButton, InteractionState, Tooltip};
pub enum PanelEvent { pub enum PanelEvent {
@@ -443,10 +444,16 @@ impl Render for Dock {
let size = entry.panel.size(cx); let size = entry.panel.size(cx);
div() div()
.border_color(cx.theme().colors().border)
.map(|this| match self.position().axis() { .map(|this| match self.position().axis() {
Axis::Horizontal => this.w(px(size)).h_full(), Axis::Horizontal => this.w(px(size)).h_full(),
Axis::Vertical => this.h(px(size)).w_full(), Axis::Vertical => this.h(px(size)).w_full(),
}) })
.map(|this| match self.position() {
DockPosition::Left => this.border_r(),
DockPosition::Right => this.border_l(),
DockPosition::Bottom => this.border_t(),
})
.child(entry.panel.to_any()) .child(entry.panel.to_any())
} else { } else {
div() div()
@@ -675,7 +682,7 @@ impl Render for PanelButtons {
Some(button) Some(button)
}); });
h_stack().children(buttons) h_stack().gap_0p5().children(buttons)
} }
} }