Add Label::weak for fainter text
This commit is contained in:
parent
953a652c29
commit
14e0963e50
2 changed files with 16 additions and 1 deletions
|
@ -170,6 +170,10 @@ impl Visuals {
|
|||
.unwrap_or_else(|| self.widgets.noninteractive.text_color())
|
||||
}
|
||||
|
||||
pub fn weak_text_color(&self) -> Color32 {
|
||||
self.widgets.disabled.text_color()
|
||||
}
|
||||
|
||||
pub fn strong_text_color(&self) -> Color32 {
|
||||
self.widgets.active.text_color()
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ pub struct Label {
|
|||
pub(crate) text_color: Option<Color32>,
|
||||
code: bool,
|
||||
strong: bool,
|
||||
weak: bool,
|
||||
strikethrough: bool,
|
||||
underline: bool,
|
||||
italics: bool,
|
||||
|
@ -26,6 +27,7 @@ impl Label {
|
|||
text_color: None,
|
||||
code: false,
|
||||
strong: false,
|
||||
weak: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
italics: false,
|
||||
|
@ -67,12 +69,18 @@ impl Label {
|
|||
self.text_style(TextStyle::Monospace)
|
||||
}
|
||||
|
||||
/// Extra white text
|
||||
/// Extra strong text (stronger color).
|
||||
pub fn strong(mut self) -> Self {
|
||||
self.strong = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// Extra weak text (fainter color).
|
||||
pub fn weak(mut self) -> Self {
|
||||
self.weak = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// draw a line under the text
|
||||
pub fn underline(mut self) -> Self {
|
||||
self.underline = true;
|
||||
|
@ -139,6 +147,7 @@ impl Label {
|
|||
mut background_color,
|
||||
code,
|
||||
strong,
|
||||
weak,
|
||||
strikethrough,
|
||||
underline,
|
||||
italics,
|
||||
|
@ -148,6 +157,8 @@ impl Label {
|
|||
let text_color = self.text_color.unwrap_or_else(|| {
|
||||
if strong {
|
||||
ui.style().visuals.strong_text_color()
|
||||
} else if weak {
|
||||
ui.style().visuals.weak_text_color()
|
||||
} else {
|
||||
ui.style().visuals.text_color()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue