Skip to content

Commit

Permalink
Use common DrawOptions for ListView
Browse files Browse the repository at this point in the history
  • Loading branch information
l4l committed Dec 25, 2020
1 parent 9d36ab0 commit aad94b1
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/draw/list_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,26 @@ where
&x[start..end]
}

let antialias = AntialiasMode::Gray;
let draw_opts = DrawOptions {
antialias,
..DrawOptions::new()
};

if let Some(match_color) = self.params.match_color {
let font = &self.params.font;
macro_rules! draw_substr {
($range:expr, $pos:expr, $color:expr) => {{
let s = substr(item.name, $range);
let measured = dt
.measure_text(&font, font_size, s, AntialiasMode::None)
.unwrap();
let measured = dt.measure_text(&font, font_size, s, antialias).unwrap();

dt.draw_text(
&font,
font_size,
s,
$pos,
&Source::Solid($color),
&DrawOptions::new(),
&draw_opts,
);
if item.name == "Firefox" {
dbg!(measured);
Expand Down Expand Up @@ -204,7 +208,7 @@ where
substr(item.name, &(idx..item.name.len())),
pos,
&Source::Solid(color),
&DrawOptions::new(),
&draw_opts,
);
} else {
dt.draw_text(
Expand All @@ -213,7 +217,7 @@ where
item.name,
pos,
&Source::Solid(color),
&DrawOptions::new(),
&draw_opts,
);
}
}
Expand Down

0 comments on commit aad94b1

Please sign in to comment.