Paint code-action/fold buttons above the gutter
This commit is contained in:
parent
188d727d31
commit
7b722c326f
1 changed files with 36 additions and 33 deletions
|
@ -749,44 +749,47 @@ impl EditorElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ix, fold_indicator) in layout.fold_indicators.drain(..).enumerate() {
|
cx.with_z_index(1, |cx| {
|
||||||
if let Some(mut fold_indicator) = fold_indicator {
|
for (ix, fold_indicator) in layout.fold_indicators.drain(..).enumerate() {
|
||||||
let mut fold_indicator = fold_indicator.into_any_element();
|
if let Some(mut fold_indicator) = fold_indicator {
|
||||||
|
let mut fold_indicator = fold_indicator.into_any_element();
|
||||||
|
let available_space = size(
|
||||||
|
AvailableSpace::MinContent,
|
||||||
|
AvailableSpace::Definite(line_height * 0.55),
|
||||||
|
);
|
||||||
|
let fold_indicator_size = fold_indicator.measure(available_space, cx);
|
||||||
|
|
||||||
|
let position = point(
|
||||||
|
bounds.size.width - layout.gutter_padding,
|
||||||
|
ix as f32 * line_height - (scroll_top % line_height),
|
||||||
|
);
|
||||||
|
let centering_offset = point(
|
||||||
|
(layout.gutter_padding + layout.gutter_margin - fold_indicator_size.width)
|
||||||
|
/ 2.,
|
||||||
|
(line_height - fold_indicator_size.height) / 2.,
|
||||||
|
);
|
||||||
|
let origin = bounds.origin + position + centering_offset;
|
||||||
|
fold_indicator.draw(origin, available_space, cx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(indicator) = layout.code_actions_indicator.take() {
|
||||||
|
let mut button = indicator.button.into_any_element();
|
||||||
let available_space = size(
|
let available_space = size(
|
||||||
AvailableSpace::MinContent,
|
AvailableSpace::MinContent,
|
||||||
AvailableSpace::Definite(line_height * 0.55),
|
AvailableSpace::Definite(line_height),
|
||||||
);
|
);
|
||||||
let fold_indicator_size = fold_indicator.measure(available_space, cx);
|
let indicator_size = button.measure(available_space, cx);
|
||||||
|
|
||||||
let position = point(
|
let mut x = Pixels::ZERO;
|
||||||
bounds.size.width - layout.gutter_padding,
|
let mut y = indicator.row as f32 * line_height - scroll_top;
|
||||||
ix as f32 * line_height - (scroll_top % line_height),
|
// Center indicator.
|
||||||
);
|
x += ((layout.gutter_padding + layout.gutter_margin) - indicator_size.width) / 2.;
|
||||||
let centering_offset = point(
|
y += (line_height - indicator_size.height) / 2.;
|
||||||
(layout.gutter_padding + layout.gutter_margin - fold_indicator_size.width) / 2.,
|
|
||||||
(line_height - fold_indicator_size.height) / 2.,
|
button.draw(bounds.origin + point(x, y), available_space, cx);
|
||||||
);
|
|
||||||
let origin = bounds.origin + position + centering_offset;
|
|
||||||
fold_indicator.draw(origin, available_space, cx);
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
if let Some(indicator) = layout.code_actions_indicator.take() {
|
|
||||||
let mut button = indicator.button.into_any_element();
|
|
||||||
let available_space = size(
|
|
||||||
AvailableSpace::MinContent,
|
|
||||||
AvailableSpace::Definite(line_height),
|
|
||||||
);
|
|
||||||
let indicator_size = button.measure(available_space, cx);
|
|
||||||
|
|
||||||
let mut x = Pixels::ZERO;
|
|
||||||
let mut y = indicator.row as f32 * line_height - scroll_top;
|
|
||||||
// Center indicator.
|
|
||||||
x += ((layout.gutter_padding + layout.gutter_margin) - indicator_size.width) / 2.;
|
|
||||||
y += (line_height - indicator_size.height) / 2.;
|
|
||||||
|
|
||||||
button.draw(bounds.origin + point(x, y), available_space, cx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn paint_diff_hunks(bounds: Bounds<Pixels>, layout: &LayoutState, cx: &mut WindowContext) {
|
fn paint_diff_hunks(bounds: Bounds<Pixels>, layout: &LayoutState, cx: &mut WindowContext) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue