Switched-on toggles draw in your own hue
Browse files at this commitaa7ff93078c6fe03ab9869800d21fb3918a2e9feParent: c991329- feat
- switched-on toggles draw in your own hue
3 changed files +11 -1
- crates/client/src/gui.rs +1 -0
- crates/client/src/gui/parts.rs +1 -1
- crates/client/src/gui/style.rs +9 -0
crates/client/src/gui.rsmodified+1 -0
| @@ -656,6 +656,7 @@ impl Yumush { | |||
| 656 | self.request_user_avatar(&user, cx); | 656 | self.request_user_avatar(&user, cx); |
| 657 | self.chat.muted = mutes::load(user.id); | 657 | self.chat.muted = mutes::load(user.id); |
| 658 | style::remember(&[&user]); | 658 | style::remember(&[&user]); |
| 659 | + style::remember_me(user.id); | ||
| 659 | self.user = Some(user); | 660 | self.user = Some(user); |
| 660 | self.change_page(Route::Chat, window, cx); | 661 | self.change_page(Route::Chat, window, cx); |
| 661 | self.load_communities(window, cx); | 662 | self.load_communities(window, cx); |
crates/client/src/gui/parts.rsmodified+1 -1
| @@ -148,7 +148,7 @@ pub fn toggle( | |||
| 148 | flip: impl Fn(&mut Window, &mut App) + 'static, | 148 | flip: impl Fn(&mut Window, &mut App) + 'static, |
| 149 | ) -> Stateful<Div> { | 149 | ) -> Stateful<Div> { |
| 150 | let (bar, knob, left) = if on { | 150 | let (bar, knob, left) = if on { |
| 151 | - (t.hue(common::model::Hue::Amber), t.paper(), 20.) | 151 | + (t.hue(super::style::my_hue()), t.paper(), 20.) |
| 152 | } else { | 152 | } else { |
| 153 | (t.faint(), t.faint(), 0.) | 153 | (t.faint(), t.faint(), 0.) |
| 154 | }; | 154 | }; |
crates/client/src/gui/style.rsmodified+9 -0
| @@ -113,6 +113,15 @@ thread_local! { | |||
| 113 | static CHOSEN: RefCell<HashMap<Id, Hue>> = RefCell::default(); | 113 | static CHOSEN: RefCell<HashMap<Id, Hue>> = RefCell::default(); |
| 114 | static AVATAR: RefCell<HashMap<Id, Id>> = RefCell::default(); | 114 | static AVATAR: RefCell<HashMap<Id, Id>> = RefCell::default(); |
| 115 | static PICTURED: RefCell<HashMap<Id, Hue>> = RefCell::default(); | 115 | static PICTURED: RefCell<HashMap<Id, Hue>> = RefCell::default(); |
| 116 | + static ME: std::cell::Cell<Option<Id>> = const { std::cell::Cell::new(None) }; | ||
| 117 | +} | ||
| 118 | + | ||
| 119 | +pub fn remember_me(id: Id) { | ||
| 120 | + ME.set(Some(id)); | ||
| 121 | +} | ||
| 122 | + | ||
| 123 | +pub fn my_hue() -> Hue { | ||
| 124 | + ME.get().map(hue_of).unwrap_or(Hue::Amber) | ||
| 116 | } | 125 | } |
| 117 | 126 | ||
| 118 | pub fn remember(users: &[&User]) { | 127 | pub fn remember(users: &[&User]) { |