label_underlined_text for "link" buttons

This commit is contained in:
Michael Kirk 2021-02-26 10:26:54 -08:00 committed by Dustin Carlino
parent 7e3d8bded9
commit 143fdc3fd5
3 changed files with 14 additions and 2 deletions

View File

@ -360,7 +360,8 @@ impl Proposals {
if edits.proposal_link.is_some() {
current_tab.push(
ctx.style()
.btn_solid_text("Read detailed write-up")
.btn_plain()
.label_underlined_text("Read detailed write-up")
.build_def(ctx)
.margin_below(10),
);

View File

@ -592,7 +592,7 @@ fn trip_category_selector(ctx: &mut EventCtx, app: &App, tab: DashTab) -> Widget
button = button
.disabled(true)
.bg_color(ctx.style().btn_solid_floating.bg, ControlState::Disabled)
.label_styled_text(Text::from(Line(label).underlined()), ControlState::Default)
.label_underlined_text(label);
}
button.build_widget(ctx, action)
};

View File

@ -213,6 +213,17 @@ impl<'b, 'a: 'b> ButtonBuilder<'a> {
self
}
/// Set the text of the button's label. The text will be decorated with an underline.
///
/// See `label_styled_text` if you need something more customizable text styling.
pub fn label_underlined_text(mut self, text: &'a str) -> Self {
let mut label = self.default_style.label.take().unwrap_or_default();
label.text = Some(text);
label.styled_text = Some(Text::from(Line(text).underlined()));
self.default_style.label = Some(label);
self
}
/// Assign a pre-styled `Text` instance if your button need something more than uniformly
/// colored text.
pub fn label_styled_text(mut self, styled_text: Text, for_state: ControlState) -> Self {