feat: unify theme system #7
@@ -9,7 +9,8 @@ use gpui::{
|
|||||||
};
|
};
|
||||||
use gpui_native_icons::{Icon, IconRole};
|
use gpui_native_icons::{Icon, IconRole};
|
||||||
use gpui_native_theme::{
|
use gpui_native_theme::{
|
||||||
ALERT_STACK_WIDTH, ActiveTheme as _, ENTER_SLIDE_DISTANCE, Size, TextRole, Typeset as _,
|
ALERT_EDGE_WIDTH, ALERT_STACK_WIDTH, ActiveTheme as _, ENTER_SLIDE_DISTANCE, Size, TextRole,
|
||||||
|
Typeset as _,
|
||||||
};
|
};
|
||||||
use gpui_native_utils::ResultLogErr as _;
|
use gpui_native_utils::ResultLogErr as _;
|
||||||
|
|
||||||
@@ -228,7 +229,13 @@ impl RenderOnce for Alert {
|
|||||||
.overflow_hidden()
|
.overflow_hidden()
|
||||||
.bg(ramp.subtle)
|
.bg(ramp.subtle)
|
||||||
.refine_style(&self.style)
|
.refine_style(&self.style)
|
||||||
.child(div().flex_none().w_1p5().self_stretch().bg(ramp.base))
|
.child(
|
||||||
|
div()
|
||||||
|
.flex_none()
|
||||||
|
.w(ALERT_EDGE_WIDTH)
|
||||||
|
.self_stretch()
|
||||||
|
.bg(ramp.base),
|
||||||
|
)
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.flex_1()
|
.flex_1()
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ use gpui::{
|
|||||||
};
|
};
|
||||||
use gpui_native_icons::{IconRole, icon};
|
use gpui_native_icons::{IconRole, icon};
|
||||||
use gpui_native_theme::ActiveTheme as _;
|
use gpui_native_theme::ActiveTheme as _;
|
||||||
use gpui_native_theme::{POPUP_MAX_HEIGHT, Size};
|
use gpui_native_theme::{COMBOBOX_MIN_WIDTH, COMBOBOX_WIDTH, POPUP_MAX_HEIGHT, Size};
|
||||||
use gpui_native_utils::ResultLogErr as _;
|
use gpui_native_utils::ResultLogErr as _;
|
||||||
|
|
||||||
use crate::common::{OVERLAY_LAYER, Sizable, StyledExt as _, h_flex, v_flex};
|
use crate::common::{OVERLAY_LAYER, Sizable, StyledExt as _, h_flex, v_flex};
|
||||||
@@ -531,8 +531,8 @@ where
|
|||||||
.id(id.clone())
|
.id(id.clone())
|
||||||
.key_context(COMBOBOX_CONTEXT)
|
.key_context(COMBOBOX_CONTEXT)
|
||||||
.relative()
|
.relative()
|
||||||
.w(window.rem_size() * 12.0)
|
.w(COMBOBOX_WIDTH)
|
||||||
.min_w(window.rem_size() * 6.0)
|
.min_w(COMBOBOX_MIN_WIDTH)
|
||||||
.refine_style(&self.style)
|
.refine_style(&self.style)
|
||||||
.role(Role::ComboBox)
|
.role(Role::ComboBox)
|
||||||
.aria_expanded(open)
|
.aria_expanded(open)
|
||||||
@@ -682,7 +682,7 @@ where
|
|||||||
let popup_width = wrapper_bounds
|
let popup_width = wrapper_bounds
|
||||||
.borrow()
|
.borrow()
|
||||||
.map(|bounds| bounds.size.width)
|
.map(|bounds| bounds.size.width)
|
||||||
.unwrap_or_else(|| window.rem_size() * 12.0);
|
.unwrap_or(COMBOBOX_WIDTH);
|
||||||
|
|
||||||
let panel = v_flex()
|
let panel = v_flex()
|
||||||
.id((id.clone(), "panel"))
|
.id((id.clone(), "panel"))
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ use gpui::{
|
|||||||
};
|
};
|
||||||
use gpui_native_core::scrollbar::{Scrollbar, ScrollbarHandle, ScrollbarVisibility};
|
use gpui_native_core::scrollbar::{Scrollbar, ScrollbarHandle, ScrollbarVisibility};
|
||||||
use gpui_native_theme::{
|
use gpui_native_theme::{
|
||||||
ActiveTheme as _, CODE_LINE_HEIGHT, ColorTokens, MONO_ADVANCE_RATIO, Ramps, WASH_ALPHA_SOFT,
|
ActiveTheme as _, CODE_GUTTER_WIDTH, CODE_LINE_HEIGHT, ColorTokens, MONO_ADVANCE_RATIO, Ramps,
|
||||||
|
WASH_ALPHA_SOFT,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::highlight::{HighlightedCode, Language, Role, highlight};
|
use crate::highlight::{HighlightedCode, Language, Role, highlight};
|
||||||
@@ -264,7 +265,7 @@ impl Render for CodeViewState {
|
|||||||
let state = cx.entity();
|
let state = cx.entity();
|
||||||
let line_count = self.code.lines.len();
|
let line_count = self.code.lines.len();
|
||||||
let selection = self.selection();
|
let selection = self.selection();
|
||||||
let gutter_width = root_font_size * 2.5;
|
let gutter_width = CODE_GUTTER_WIDTH;
|
||||||
|
|
||||||
let bounds_cell: std::rc::Rc<std::cell::RefCell<Option<Bounds<Pixels>>>> =
|
let bounds_cell: std::rc::Rc<std::cell::RefCell<Option<Bounds<Pixels>>>> =
|
||||||
std::rc::Rc::new(std::cell::RefCell::new(None));
|
std::rc::Rc::new(std::cell::RefCell::new(None));
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use gpui::{
|
|||||||
point, uniform_list,
|
point, uniform_list,
|
||||||
};
|
};
|
||||||
use gpui_native_core::scrollbar::{Scrollbar, ScrollbarHandle, ScrollbarVisibility};
|
use gpui_native_core::scrollbar::{Scrollbar, ScrollbarHandle, ScrollbarVisibility};
|
||||||
use gpui_native_theme::{ActiveTheme as _, BORDER_WIDTH, MONO_ADVANCE_RATIO};
|
use gpui_native_theme::{ActiveTheme as _, BORDER_WIDTH, CODE_GUTTER_WIDTH, MONO_ADVANCE_RATIO};
|
||||||
use similar::{Change, ChangeTag, TextDiff};
|
use similar::{Change, ChangeTag, TextDiff};
|
||||||
|
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
@@ -524,10 +524,10 @@ fn render_row(
|
|||||||
.text_color(colors.muted_foreground)
|
.text_color(colors.muted_foreground)
|
||||||
.when(
|
.when(
|
||||||
options.indicators == DiffIndicators::Classic,
|
options.indicators == DiffIndicators::Classic,
|
||||||
|row_element| row_element.child(div().w_10().flex_none()),
|
|row_element| row_element.child(div().w(CODE_GUTTER_WIDTH).flex_none()),
|
||||||
)
|
)
|
||||||
.when(options.line_numbers, |row_element| {
|
.when(options.line_numbers, |row_element| {
|
||||||
row_element.child(div().w_10().flex_none())
|
row_element.child(div().w(CODE_GUTTER_WIDTH).flex_none())
|
||||||
})
|
})
|
||||||
.when(
|
.when(
|
||||||
options.indicators == DiffIndicators::Bars && !options.line_numbers,
|
options.indicators == DiffIndicators::Bars && !options.line_numbers,
|
||||||
@@ -654,7 +654,7 @@ fn render_row(
|
|||||||
.map(|number| number.to_string())
|
.map(|number| number.to_string())
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
)
|
)
|
||||||
.w_10()
|
.w(CODE_GUTTER_WIDTH)
|
||||||
.whitespace_nowrap()
|
.whitespace_nowrap()
|
||||||
.bg(match row.kind {
|
.bg(match row.kind {
|
||||||
DiffRowKind::Context => wash_gutter(&colors),
|
DiffRowKind::Context => wash_gutter(&colors),
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use gpui::StyledText;
|
|||||||
#[cfg(any(feature = "code", feature = "markdown"))]
|
#[cfg(any(feature = "code", feature = "markdown"))]
|
||||||
use gpui::{App, HighlightStyle, Hsla, IntoElement, ParentElement as _, Styled as _, div};
|
use gpui::{App, HighlightStyle, Hsla, IntoElement, ParentElement as _, Styled as _, div};
|
||||||
#[cfg(any(feature = "code", feature = "markdown"))]
|
#[cfg(any(feature = "code", feature = "markdown"))]
|
||||||
use gpui_native_theme::{ActiveTheme as _, ColorTokens, Ramps};
|
use gpui_native_theme::{ActiveTheme as _, CODE_GUTTER_WIDTH, ColorTokens, Ramps};
|
||||||
#[cfg(feature = "diff")]
|
#[cfg(feature = "diff")]
|
||||||
use gpui_native_theme::{WASH_ALPHA, WASH_ALPHA_GUTTER, WASH_ALPHA_STRONG};
|
use gpui_native_theme::{WASH_ALPHA, WASH_ALPHA_GUTTER, WASH_ALPHA_STRONG};
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ where
|
|||||||
let theme = cx.theme();
|
let theme = cx.theme();
|
||||||
|
|
||||||
div()
|
div()
|
||||||
.size_10()
|
.size(CODE_GUTTER_WIDTH)
|
||||||
.flex()
|
.flex()
|
||||||
.items_center()
|
.items_center()
|
||||||
.justify_center()
|
.justify_center()
|
||||||
|
|||||||
@@ -43,6 +43,14 @@ pub const DIALOG_MIN_WIDTH: Pixels = px(384.0);
|
|||||||
pub const MENU_MIN_WIDTH: Pixels = px(224.0);
|
pub const MENU_MIN_WIDTH: Pixels = px(224.0);
|
||||||
/// The width of the pushed-alert stack.
|
/// The width of the pushed-alert stack.
|
||||||
pub const ALERT_STACK_WIDTH: Pixels = px(320.0);
|
pub const ALERT_STACK_WIDTH: Pixels = px(320.0);
|
||||||
|
/// The accent edge of an inline alert.
|
||||||
|
pub const ALERT_EDGE_WIDTH: Pixels = px(6.0);
|
||||||
|
/// The default width of a combobox trigger.
|
||||||
|
pub const COMBOBOX_WIDTH: Pixels = px(192.0);
|
||||||
|
/// The narrowest a combobox trigger may shrink.
|
||||||
|
pub const COMBOBOX_MIN_WIDTH: Pixels = px(96.0);
|
||||||
|
/// The width of a code view's line-number gutter.
|
||||||
|
pub const CODE_GUTTER_WIDTH: Pixels = px(40.0);
|
||||||
/// The width of the speech waveform strip.
|
/// The width of the speech waveform strip.
|
||||||
pub const SPEECH_WAVEFORM_WIDTH: Pixels = px(96.0);
|
pub const SPEECH_WAVEFORM_WIDTH: Pixels = px(96.0);
|
||||||
/// The line-height ratio of monospace code.
|
/// The line-height ratio of monospace code.
|
||||||
|
|||||||
Reference in New Issue
Block a user