Scale diagnostic headers icons with editor font and right align w/ line numbers
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
co-authored by
Max Brunsfeld
parent
121b45e249
commit
0c6fd157ee
@@ -69,7 +69,9 @@ where
|
||||
pub struct BlockContext<'a> {
|
||||
pub cx: &'a AppContext,
|
||||
pub anchor_x: f32,
|
||||
pub line_number_x: f32,
|
||||
pub gutter_width: f32,
|
||||
pub gutter_padding: f32,
|
||||
pub em_width: f32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
@@ -947,7 +949,9 @@ mod tests {
|
||||
.render(&BlockContext {
|
||||
cx,
|
||||
anchor_x: 0.,
|
||||
line_number_x: 0.,
|
||||
gutter_padding: 0.,
|
||||
gutter_width: 0.,
|
||||
em_width: 0.,
|
||||
})
|
||||
.name()
|
||||
.unwrap()
|
||||
|
||||
@@ -3834,6 +3834,7 @@ impl EditorSettings {
|
||||
placeholder_text: None,
|
||||
background: Default::default(),
|
||||
gutter_background: Default::default(),
|
||||
gutter_padding_factor: 2.,
|
||||
active_line_background: Default::default(),
|
||||
highlighted_line_background: Default::default(),
|
||||
line_number: Default::default(),
|
||||
@@ -3862,7 +3863,7 @@ impl EditorSettings {
|
||||
container: Default::default(),
|
||||
text: text.clone(),
|
||||
},
|
||||
icon: Default::default(),
|
||||
icon_width_factor: Default::default(),
|
||||
},
|
||||
error_diagnostic: default_diagnostic_style.clone(),
|
||||
invalid_error_diagnostic: default_diagnostic_style.clone(),
|
||||
|
||||
@@ -586,7 +586,9 @@ impl EditorElement {
|
||||
rows: Range<u32>,
|
||||
snapshot: &EditorSnapshot,
|
||||
width: f32,
|
||||
line_number_x: f32,
|
||||
gutter_padding: f32,
|
||||
gutter_width: f32,
|
||||
em_width: f32,
|
||||
text_x: f32,
|
||||
line_height: f32,
|
||||
style: &EditorStyle,
|
||||
@@ -614,7 +616,9 @@ impl EditorElement {
|
||||
let mut element = block.render(&BlockContext {
|
||||
cx,
|
||||
anchor_x,
|
||||
line_number_x,
|
||||
gutter_padding,
|
||||
gutter_width,
|
||||
em_width,
|
||||
});
|
||||
element.layout(
|
||||
SizeConstraint {
|
||||
@@ -645,12 +649,12 @@ impl Element for EditorElement {
|
||||
|
||||
let snapshot = self.snapshot(cx.app);
|
||||
let style = self.settings.style.clone();
|
||||
let line_height = style.text.line_height(cx.font_cache);
|
||||
let line_height = dbg!(style.text.line_height(cx.font_cache));
|
||||
|
||||
let gutter_padding;
|
||||
let gutter_width;
|
||||
if snapshot.mode == EditorMode::Full {
|
||||
gutter_padding = style.text.em_width(cx.font_cache);
|
||||
gutter_padding = style.text.em_width(cx.font_cache) * style.gutter_padding_factor;
|
||||
gutter_width = self.max_line_number_width(&snapshot, cx) + gutter_padding * 2.0;
|
||||
} else {
|
||||
gutter_padding = 0.0;
|
||||
@@ -781,6 +785,8 @@ impl Element for EditorElement {
|
||||
&snapshot,
|
||||
size.x(),
|
||||
gutter_padding,
|
||||
gutter_width,
|
||||
em_width,
|
||||
gutter_width + text_offset.x(),
|
||||
line_height,
|
||||
&style,
|
||||
|
||||
Reference in New Issue
Block a user