fix(layout): make tab bars more compact
This commit is contained in:
1 parent
038b8884fc
commit
a3974c2dda
4 files changed
+24
-10
No files matched your search
@@ -99,7 +99,7 @@ fn label_font(database: &fontdb::Database, family: &str) -> Option<FontArc> {
|
||||
}
|
||||
|
||||
type LabelBuffer = (MemoryRenderBuffer, smithay::utils::Size<i32, smithay::utils::Buffer>);
|
||||
type LabelStyle = (u64, [u32; 4]);
|
||||
type LabelStyle = (u64, u64, [u32; 4]);
|
||||
type OverviewStateLabel = HashMap<String, HashMap<LabelStyle, LabelBuffer>>;
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -247,12 +247,16 @@ impl OverviewState {
|
||||
scale: f64,
|
||||
color: [f32; 4],
|
||||
) -> Option<(MemoryRenderBuffer, smithay::utils::Size<i32, smithay::utils::Buffer>)> {
|
||||
let key = (scale.to_bits(), color.map(f32::to_bits));
|
||||
self.label_with_size(text, scale, color, 13.0)
|
||||
}
|
||||
|
||||
fn label_with_size(&mut self, text: &str, scale: f64, color: [f32; 4], font_size: f64) -> Option<LabelBuffer> {
|
||||
let key = (scale.to_bits(), font_size.to_bits(), color.map(f32::to_bits));
|
||||
if let Some(buffer) = self.labels.get(text).and_then(|styles| styles.get(&key)) {
|
||||
return Some(buffer.clone());
|
||||
}
|
||||
let font = self.font.as_ref()?;
|
||||
let scaled = font.as_scaled((13.0 * scale) as f32);
|
||||
let scaled = font.as_scaled((font_size * scale) as f32);
|
||||
let width = (text
|
||||
.chars()
|
||||
.map(|ch| scaled.h_advance(font.glyph_id(ch)))
|
||||
@@ -260,7 +264,7 @@ impl OverviewState {
|
||||
.ceil() as i32
|
||||
+ 4)
|
||||
.max(1);
|
||||
let height = (18.0 * scale).ceil() as i32;
|
||||
let height = ((font_size + 5.0) * scale).ceil() as i32;
|
||||
let mut pixels = vec![0_u8; (width * height * 4) as usize];
|
||||
let mut pen = 2.0;
|
||||
for ch in text.chars() {
|
||||
@@ -520,10 +524,20 @@ impl Ferese {
|
||||
}
|
||||
|
||||
pub(crate) fn overview_window_label(&mut self, id: WindowId, scale: f64, width: f64) -> Option<LabelBuffer> {
|
||||
self.window_title_label(id, scale, width, 13.0)
|
||||
}
|
||||
|
||||
pub(crate) fn window_title_label(
|
||||
&mut self,
|
||||
id: WindowId,
|
||||
scale: f64,
|
||||
width: f64,
|
||||
font_size: f64,
|
||||
) -> Option<LabelBuffer> {
|
||||
let record = self.windows.record(id)?;
|
||||
let limit = ((width - 16.0) / 8.0).clamp(1.0, 48.0) as usize;
|
||||
let color = self.theme_settings.text_primary_color.0;
|
||||
let style = (scale.to_bits(), color.map(f32::to_bits));
|
||||
let style = (scale.to_bits(), font_size.to_bits(), color.map(f32::to_bits));
|
||||
|
||||
if let Some(label) = self.overview.window_labels.get(&id)
|
||||
&& label.revision == record.metadata_revision
|
||||
@@ -549,7 +563,7 @@ impl Ferese {
|
||||
}
|
||||
|
||||
let revision = record.metadata_revision;
|
||||
let buffer = self.overview.label(&text, scale, color)?;
|
||||
let buffer = self.overview.label_with_size(&text, scale, color, font_size)?;
|
||||
self.overview.window_labels.insert(
|
||||
id,
|
||||
WindowLabel {
|
||||
|
||||
@@ -40,7 +40,7 @@ pub(super) fn tab_elements(
|
||||
.material_radius
|
||||
.min(shell.height * 0.5)
|
||||
.min(shell.width * 0.5);
|
||||
let inset = 3.0_f64.min(shell.height * 0.25).min(width * 0.25);
|
||||
let inset = 2.0_f64.min(shell.height * 0.25).min(width * 0.25);
|
||||
let material = crate::effects::resolve_material(
|
||||
crate::effects::SemanticRole::Panel,
|
||||
state.theme_settings.material_style,
|
||||
@@ -68,7 +68,7 @@ pub(super) fn tab_elements(
|
||||
if !protected
|
||||
&& width > 20.0
|
||||
&& rect.height >= 16.0
|
||||
&& let Some((buffer, size)) = state.overview_window_label(id, scale, width)
|
||||
&& let Some((buffer, size)) = state.window_title_label(id, scale, width, 12.0)
|
||||
{
|
||||
let location = Point::<i32, Physical>::from((
|
||||
((rect.x - f64::from(output_geometry.loc.x)
|
||||
|
||||
Reference in new issue
Block a user