theme: Add colors for minimap thumb and border (#30785)
A user on Discord reported an issue where the minimap thumb was fully opaque: <img src="https://github.com/user-attachments/assets/5049c6a3-f89a-4ceb-9d1b-ec06e7fe9151" height="300"> This can happen because the scrollbar and its thumb might not neccessarily be transparent at all. Thus, this PR adds the`minimap.thumb.background` and `minimap.thumb.border` colors to themes so theme authors can specify custom colors for both here. Furthermore, I ensured that the minimap thumb background fallback value can never be entirely opaque. The values were arbitrarily chosen to avoid the issue from occuring whilst keeping currently working setups working. With the new properties added, authors (and users) should be able to avoid running into this issue altogether so I would argue for this special casing to be fine. However, open to change it should a different approach be preferrred. Release Notes: - Added `minimap.thumb.background` and `minimap.thumb.border` to themes to customize the thumb color and background of the minimap. - Fixed an issue where the minimap thumb could be opaque if the theme did not specify a color for the thumb.
This commit is contained in:
parent
8a24f9f280
commit
4c396bcc91
7 changed files with 194 additions and 67 deletions
|
@ -123,8 +123,9 @@ impl OngoingScroll {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
#[derive(Copy, Clone, Default, PartialEq, Eq)]
|
||||
pub enum ScrollbarThumbState {
|
||||
#[default]
|
||||
Idle,
|
||||
Hovered,
|
||||
Dragging,
|
||||
|
@ -157,8 +158,7 @@ pub struct ScrollManager {
|
|||
active_scrollbar: Option<ActiveScrollbarState>,
|
||||
visible_line_count: Option<f32>,
|
||||
forbid_vertical_scroll: bool,
|
||||
dragging_minimap: bool,
|
||||
show_minimap_thumb: bool,
|
||||
minimap_thumb_state: Option<ScrollbarThumbState>,
|
||||
}
|
||||
|
||||
impl ScrollManager {
|
||||
|
@ -174,8 +174,7 @@ impl ScrollManager {
|
|||
last_autoscroll: None,
|
||||
visible_line_count: None,
|
||||
forbid_vertical_scroll: false,
|
||||
dragging_minimap: false,
|
||||
show_minimap_thumb: false,
|
||||
minimap_thumb_state: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -345,24 +344,6 @@ impl ScrollManager {
|
|||
self.show_scrollbars
|
||||
}
|
||||
|
||||
pub fn show_minimap_thumb(&mut self, cx: &mut Context<Editor>) {
|
||||
if !self.show_minimap_thumb {
|
||||
self.show_minimap_thumb = true;
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hide_minimap_thumb(&mut self, cx: &mut Context<Editor>) {
|
||||
if self.show_minimap_thumb {
|
||||
self.show_minimap_thumb = false;
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn minimap_thumb_visible(&mut self) -> bool {
|
||||
self.show_minimap_thumb
|
||||
}
|
||||
|
||||
pub fn autoscroll_request(&self) -> Option<Autoscroll> {
|
||||
self.autoscroll_request.map(|(autoscroll, _)| autoscroll)
|
||||
}
|
||||
|
@ -419,13 +400,43 @@ impl ScrollManager {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_dragging_minimap(&self) -> bool {
|
||||
self.dragging_minimap
|
||||
pub fn set_is_hovering_minimap_thumb(&mut self, hovered: bool, cx: &mut Context<Editor>) {
|
||||
self.update_minimap_thumb_state(
|
||||
Some(if hovered {
|
||||
ScrollbarThumbState::Hovered
|
||||
} else {
|
||||
ScrollbarThumbState::Idle
|
||||
}),
|
||||
cx,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn set_is_dragging_minimap(&mut self, dragging: bool, cx: &mut Context<Editor>) {
|
||||
self.dragging_minimap = dragging;
|
||||
cx.notify();
|
||||
pub fn set_is_dragging_minimap(&mut self, cx: &mut Context<Editor>) {
|
||||
self.update_minimap_thumb_state(Some(ScrollbarThumbState::Dragging), cx);
|
||||
}
|
||||
|
||||
pub fn hide_minimap_thumb(&mut self, cx: &mut Context<Editor>) {
|
||||
self.update_minimap_thumb_state(None, cx);
|
||||
}
|
||||
|
||||
pub fn is_dragging_minimap(&self) -> bool {
|
||||
self.minimap_thumb_state
|
||||
.is_some_and(|state| state == ScrollbarThumbState::Dragging)
|
||||
}
|
||||
|
||||
fn update_minimap_thumb_state(
|
||||
&mut self,
|
||||
thumb_state: Option<ScrollbarThumbState>,
|
||||
cx: &mut Context<Editor>,
|
||||
) {
|
||||
if self.minimap_thumb_state != thumb_state {
|
||||
self.minimap_thumb_state = thumb_state;
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn minimap_thumb_state(&self) -> Option<ScrollbarThumbState> {
|
||||
self.minimap_thumb_state
|
||||
}
|
||||
|
||||
pub fn clamp_scroll_left(&mut self, max: f32) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue