launcher: Use draw_text_individual_colors
This commit is contained in:
+1
-1
@@ -63,7 +63,7 @@ impl ModuleImpl for Clock {
|
|||||||
bg,
|
bg,
|
||||||
&Color::new(1.0, 1.0, 1.0, 1.0),
|
&Color::new(1.0, 1.0, 1.0, 1.0),
|
||||||
256.0,
|
256.0,
|
||||||
vec![120, 120, 64, 120, 120],
|
&[120, 120, 64, 120, 120],
|
||||||
&format!("{:02}:{:02}", time.hour(), time.minute()),
|
&format!("{:02}:{:02}", time.hour(), time.minute()),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
|||||||
+12
-25
@@ -1,6 +1,6 @@
|
|||||||
use crate::buffer::Buffer;
|
use crate::buffer::Buffer;
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
use crate::draw::{draw_text, ROBOTO_REGULAR};
|
use crate::draw::{draw_text, draw_text_individual_colors, ROBOTO_REGULAR};
|
||||||
use crate::module::{Input, ModuleImpl};
|
use crate::module::{Input, ModuleImpl};
|
||||||
|
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
@@ -69,34 +69,21 @@ impl ModuleImpl for Launcher {
|
|||||||
let size = if idx == self.offset && self.cur.len() > 0 {
|
let size = if idx == self.offset && self.cur.len() > 0 {
|
||||||
let l = self.cur.len();
|
let l = self.cur.len();
|
||||||
let off = m.to_lowercase().find(&self.cur.to_lowercase()).unwrap();
|
let off = m.to_lowercase().find(&self.cur.to_lowercase()).unwrap();
|
||||||
let s1 = draw_text(
|
let mut colors = Vec::with_capacity(m.len());
|
||||||
|
for pos in 0..m.len() {
|
||||||
|
if pos >= off && pos < off + l {
|
||||||
|
colors.push(Color::new(1.0, 1.0, 1.0, 1.0));
|
||||||
|
} else {
|
||||||
|
colors.push(Color::new(0.75, 0.75, 0.75, 1.0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
draw_text_individual_colors(
|
||||||
ROBOTO_REGULAR,
|
ROBOTO_REGULAR,
|
||||||
&mut b,
|
&mut b,
|
||||||
bg,
|
bg,
|
||||||
&Color::new(0.75, 0.75, 0.75, 1.0),
|
&colors,
|
||||||
32.0,
|
32.0,
|
||||||
&m[0..off],
|
&m)?
|
||||||
)?;
|
|
||||||
let mut b2 = b.subdimensions((s1.0+1, 0, width_remaining as u32 - s1.0-1, 32))?;
|
|
||||||
let s2 = draw_text(
|
|
||||||
ROBOTO_REGULAR,
|
|
||||||
&mut b2,
|
|
||||||
bg,
|
|
||||||
&Color::new(1.0, 1.0, 1.0, 1.0),
|
|
||||||
32.0,
|
|
||||||
&m[off..off+l],
|
|
||||||
)?;
|
|
||||||
let mut b3 = b.subdimensions((s1.0+s2.0+2, 0, width_remaining as u32 - s1.0- s2.0 - 2, 32))?;
|
|
||||||
let s3 = draw_text(
|
|
||||||
ROBOTO_REGULAR,
|
|
||||||
&mut b3,
|
|
||||||
bg,
|
|
||||||
&Color::new(0.75, 0.75, 0.75, 1.0),
|
|
||||||
32.0,
|
|
||||||
&m[off+l..],
|
|
||||||
)?;
|
|
||||||
|
|
||||||
(s1.0 + s2.0 + s3.0 + 3, s1.1 + s2.1 + s3.1)
|
|
||||||
} else {
|
} else {
|
||||||
draw_text(
|
draw_text(
|
||||||
ROBOTO_REGULAR,
|
ROBOTO_REGULAR,
|
||||||
|
|||||||
Reference in New Issue
Block a user