introduce typography system and motion module
This commit is contained in:
+16
-10
@@ -14,6 +14,7 @@ mod platform_kind;
|
||||
mod scrollbar_mode;
|
||||
mod syntax;
|
||||
mod theme;
|
||||
mod typography;
|
||||
|
||||
pub mod appearance;
|
||||
|
||||
@@ -38,6 +39,9 @@ pub use platform_kind::PlatformKind;
|
||||
pub use scrollbar_mode::*;
|
||||
pub use syntax::{HighlightKind, SyntaxPalette};
|
||||
pub use theme::*;
|
||||
pub use typography::{
|
||||
DEFAULT_BASE_TEXT_SIZE, Metrics, TextStyle, Typeset, base_text_size, set_base_text_size,
|
||||
};
|
||||
|
||||
/// Which appearance the app is painting. Bezel names this enum `Appearance`;
|
||||
/// coop's `ThemeMode` predates the port and carries the same two variants.
|
||||
@@ -78,6 +82,7 @@ pub trait AppExt {
|
||||
fn set_brand(&mut self, brand: Brand);
|
||||
fn set_palette(&mut self, build: PaletteBuilder);
|
||||
fn set_appearance_mode(&mut self, mode: AppearanceMode);
|
||||
fn set_base_text_size(&mut self, points: f32);
|
||||
}
|
||||
|
||||
impl AppExt for App {
|
||||
@@ -94,6 +99,11 @@ impl AppExt for App {
|
||||
fn set_appearance_mode(&mut self, mode: AppearanceMode) {
|
||||
appearance::set_mode(mode, self);
|
||||
}
|
||||
|
||||
fn set_base_text_size(&mut self, points: f32) {
|
||||
typography::set_base_text_size(points);
|
||||
self.refresh_windows();
|
||||
}
|
||||
}
|
||||
|
||||
/// Re-install the palette for the current appearance.
|
||||
@@ -123,12 +133,12 @@ pub fn sync_base(cx: &mut App) {
|
||||
ScrollbarMode::Always => gpui_base::ScrollbarMode::Always,
|
||||
};
|
||||
let colors = theme.colors;
|
||||
let font_family = theme.font_family.clone();
|
||||
let font_sans = theme.font_sans.clone();
|
||||
|
||||
let base = gpui_base::Theme::global_mut(cx);
|
||||
base.appearance = appearance;
|
||||
base.scrollbar = base.scrollbar.clone().with_mode(scrollbar_mode);
|
||||
base.tokens.typography.sans = font_family;
|
||||
base.tokens.typography.sans = font_sans;
|
||||
|
||||
let tokens = &mut base.tokens.colors;
|
||||
tokens.background = colors.bg;
|
||||
@@ -166,10 +176,8 @@ impl ActiveTheme for App {
|
||||
pub struct Theme {
|
||||
pub colors: ThemeColors,
|
||||
pub mode: ThemeMode,
|
||||
pub font_family: SharedString,
|
||||
pub font_body: SharedString,
|
||||
pub font_sans: SharedString,
|
||||
pub font_mono: SharedString,
|
||||
pub font_size: Pixels,
|
||||
pub shadow: bool,
|
||||
pub scrollbar_mode: ScrollbarMode,
|
||||
pub notification: NotificationSettings,
|
||||
@@ -272,16 +280,14 @@ impl Default for Theme {
|
||||
let platform = PlatformKind::platform();
|
||||
let mode = ThemeMode::default();
|
||||
|
||||
// Define the font family based on the platform.
|
||||
let font_family = match platform {
|
||||
// The system UI font, by platform.
|
||||
let font_sans = match platform {
|
||||
PlatformKind::Linux => "Inter",
|
||||
_ => ".SystemUIFont",
|
||||
};
|
||||
|
||||
Self {
|
||||
font_size: px(15.),
|
||||
font_family: font_family.into(),
|
||||
font_body: font_family.into(),
|
||||
font_sans: font_sans.into(),
|
||||
font_mono: system_mono().into(),
|
||||
shadow: true,
|
||||
scrollbar_mode: ScrollbarMode::default(),
|
||||
|
||||
Reference in New Issue
Block a user