-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: use height of text as button height in context menu #254
Conversation
@andymandias do you mind testing this if context menus works on linux? |
Confirmed on IRC but will also confirm here for posterity, it works perfectly. Thank you! |
pub family: String, | ||
pub size: f32, | ||
} | ||
|
||
impl Default for Font { | ||
fn default() -> Self { | ||
Self { | ||
family: String::from("Iosevka Term"), | ||
size: 13.0 | ||
} | ||
} | ||
} | ||
|
||
impl Font { | ||
fn deserialize<'de, D>(deserializer: D) -> Result<Self, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
{ | ||
#[derive(Deserialize)] | ||
struct MaybeFont { | ||
family: Option<String>, | ||
size: Option<f32>, | ||
} | ||
|
||
let MaybeFont { family, size } = MaybeFont::deserialize(deserializer)?; | ||
let Font { family: default_family, size: default_size } = Font::default(); | ||
|
||
Ok(Font { | ||
family: family.unwrap_or(default_family), | ||
size: size.unwrap_or(default_size), | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[serde(default_with = "default_font_size")]
fn default_font_size() -> f32 {
13.0
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then you can keep default
below on Font
// Height based on font size, with some margin added. | ||
let height = LineHeight::default().to_absolute((font.size + 8.0).into()); | ||
|
||
button(text(content).style(theme::Text::Primary)) | ||
.width(length) | ||
.height(length) | ||
.height(height) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems super hacky. Let me play around. We should just be able to use Shrink
height and have it work when font size increases....
Supeceded by #255 |
WIP to fix #238