-
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ pub fn view<'a>( | |
), | ||
), | ||
user.clone(), | ||
&config.font, | ||
) | ||
.map(scroll_view::Message::UserContext); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
use data::dashboard::DefaultAction; | ||
use data::{history, Buffer}; | ||
use iced::widget::text::LineHeight; | ||
use iced::widget::{ | ||
button, column, container, horizontal_space, pane_grid, row, scrollable, text, vertical_space, | ||
}; | ||
|
@@ -58,6 +59,7 @@ impl SideMenu { | |
panes: &pane_grid::State<Pane>, | ||
focus: Option<pane_grid::Pane>, | ||
config: data::config::dashboard::Sidebar, | ||
font: &data::config::Font, | ||
) -> Option<Element<'a, Message>> { | ||
if self.hidden { | ||
return None; | ||
|
@@ -75,6 +77,7 @@ impl SideMenu { | |
false, | ||
false, | ||
config.default_action, | ||
font, | ||
)); | ||
} | ||
data::client::State::Ready(connection) => { | ||
|
@@ -85,6 +88,7 @@ impl SideMenu { | |
true, | ||
false, | ||
config.default_action, | ||
font, | ||
)); | ||
|
||
for channel in connection.channels() { | ||
|
@@ -95,6 +99,7 @@ impl SideMenu { | |
true, | ||
history.has_unread(server, &history::Kind::Channel(channel.clone())), | ||
config.default_action, | ||
font, | ||
)); | ||
} | ||
|
||
|
@@ -107,6 +112,7 @@ impl SideMenu { | |
true, | ||
history.has_unread(server, &history::Kind::Query(user.clone())), | ||
config.default_action, | ||
font, | ||
)); | ||
} | ||
|
||
|
@@ -171,7 +177,9 @@ fn buffer_button<'a>( | |
connected: bool, | ||
has_unread: bool, | ||
default_action: DefaultAction, | ||
font: &data::config::Font, | ||
) -> Element<'a, Message> { | ||
let font = font.clone(); | ||
let open = panes | ||
.iter() | ||
.find_map(|(pane, state)| (state.buffer.data().as_ref() == Some(&buffer)).then_some(*pane)); | ||
|
@@ -238,9 +246,12 @@ fn buffer_button<'a>( | |
), | ||
}; | ||
|
||
// 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) | ||
Comment on lines
+249
to
+254
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
.style(theme::Button::Context) | ||
.on_press(message) | ||
.into() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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")]
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