mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-22 09:26:19 +04:00
Fix Component implementations for Picker (#7382)
This commit is contained in:
parent
06d63d6ac1
commit
9690e0b733
@ -750,6 +750,33 @@ fn render_preview(&mut self, area: Rect, surface: &mut Surface, cx: &mut Context
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Item + 'static> Component for Picker<T> {
|
||||||
|
fn render(&mut self, area: Rect, surface: &mut Surface, cx: &mut Context) {
|
||||||
|
// +---------+ +---------+
|
||||||
|
// |prompt | |preview |
|
||||||
|
// +---------+ | |
|
||||||
|
// |picker | | |
|
||||||
|
// | | | |
|
||||||
|
// +---------+ +---------+
|
||||||
|
|
||||||
|
let render_preview = self.show_preview && area.width > MIN_AREA_WIDTH_FOR_PREVIEW;
|
||||||
|
|
||||||
|
let picker_width = if render_preview {
|
||||||
|
area.width / 2
|
||||||
|
} else {
|
||||||
|
area.width
|
||||||
|
};
|
||||||
|
|
||||||
|
let picker_area = area.with_width(picker_width);
|
||||||
|
self.render_picker(picker_area, surface, cx);
|
||||||
|
|
||||||
|
if render_preview {
|
||||||
|
let preview_area = area.clip_left(picker_width);
|
||||||
|
self.render_preview(preview_area, surface, cx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn handle_event(&mut self, event: &Event, ctx: &mut Context) -> EventResult {
|
fn handle_event(&mut self, event: &Event, ctx: &mut Context) -> EventResult {
|
||||||
if let Event::IdleTimeout = event {
|
if let Event::IdleTimeout = event {
|
||||||
@ -846,33 +873,6 @@ fn required_size(&mut self, (width, height): (u16, u16)) -> Option<(u16, u16)> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Item + 'static> Component for Picker<T> {
|
|
||||||
fn render(&mut self, area: Rect, surface: &mut Surface, cx: &mut Context) {
|
|
||||||
// +---------+ +---------+
|
|
||||||
// |prompt | |preview |
|
|
||||||
// +---------+ | |
|
|
||||||
// |picker | | |
|
|
||||||
// | | | |
|
|
||||||
// +---------+ +---------+
|
|
||||||
|
|
||||||
let render_preview = self.show_preview && area.width > MIN_AREA_WIDTH_FOR_PREVIEW;
|
|
||||||
|
|
||||||
let picker_width = if render_preview {
|
|
||||||
area.width / 2
|
|
||||||
} else {
|
|
||||||
area.width
|
|
||||||
};
|
|
||||||
|
|
||||||
let picker_area = area.with_width(picker_width);
|
|
||||||
self.render_picker(picker_area, surface, cx);
|
|
||||||
|
|
||||||
if render_preview {
|
|
||||||
let preview_area = area.clip_left(picker_width);
|
|
||||||
self.render_preview(preview_area, surface, cx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Debug)]
|
#[derive(PartialEq, Eq, Debug)]
|
||||||
struct PickerMatch {
|
struct PickerMatch {
|
||||||
score: i64,
|
score: i64,
|
||||||
|
Loading…
Reference in New Issue
Block a user