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())
|
.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 {
|
pub fn strong_text_color(&self) -> Color32 {
|
||||||
self.widgets.active.text_color()
|
self.widgets.active.text_color()
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ pub struct Label {
|
||||||
pub(crate) text_color: Option<Color32>,
|
pub(crate) text_color: Option<Color32>,
|
||||||
code: bool,
|
code: bool,
|
||||||
strong: bool,
|
strong: bool,
|
||||||
|
weak: bool,
|
||||||
strikethrough: bool,
|
strikethrough: bool,
|
||||||
underline: bool,
|
underline: bool,
|
||||||
italics: bool,
|
italics: bool,
|
||||||
|
@ -26,6 +27,7 @@ impl Label {
|
||||||
text_color: None,
|
text_color: None,
|
||||||
code: false,
|
code: false,
|
||||||
strong: false,
|
strong: false,
|
||||||
|
weak: false,
|
||||||
strikethrough: false,
|
strikethrough: false,
|
||||||
underline: false,
|
underline: false,
|
||||||
italics: false,
|
italics: false,
|
||||||
|
@ -67,12 +69,18 @@ impl Label {
|
||||||
self.text_style(TextStyle::Monospace)
|
self.text_style(TextStyle::Monospace)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extra white text
|
/// Extra strong text (stronger color).
|
||||||
pub fn strong(mut self) -> Self {
|
pub fn strong(mut self) -> Self {
|
||||||
self.strong = true;
|
self.strong = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Extra weak text (fainter color).
|
||||||
|
pub fn weak(mut self) -> Self {
|
||||||
|
self.weak = true;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// draw a line under the text
|
/// draw a line under the text
|
||||||
pub fn underline(mut self) -> Self {
|
pub fn underline(mut self) -> Self {
|
||||||
self.underline = true;
|
self.underline = true;
|
||||||
|
@ -139,6 +147,7 @@ impl Label {
|
||||||
mut background_color,
|
mut background_color,
|
||||||
code,
|
code,
|
||||||
strong,
|
strong,
|
||||||
|
weak,
|
||||||
strikethrough,
|
strikethrough,
|
||||||
underline,
|
underline,
|
||||||
italics,
|
italics,
|
||||||
|
@ -148,6 +157,8 @@ impl Label {
|
||||||
let text_color = self.text_color.unwrap_or_else(|| {
|
let text_color = self.text_color.unwrap_or_else(|| {
|
||||||
if strong {
|
if strong {
|
||||||
ui.style().visuals.strong_text_color()
|
ui.style().visuals.strong_text_color()
|
||||||
|
} else if weak {
|
||||||
|
ui.style().visuals.weak_text_color()
|
||||||
} else {
|
} else {
|
||||||
ui.style().visuals.text_color()
|
ui.style().visuals.text_color()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue