Skip to content

Commit

Permalink
Toolbar: icons should not be selectable
Browse files Browse the repository at this point in the history
- Adding actions on the toolbar no longer makes them selectable
- New api in Widget :)
- In plasma theme - when an icon has no frame, it will keep background's
  color as the window, until its selected.
  • Loading branch information
diegoiast committed Jun 16, 2024
1 parent dc38a98 commit 4a8c873
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/button.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ struct Button : Widget {
auto set_auto_repeat(int64_t repeat_millies, int64_t repeat_start = 500) -> void;
auto disable_auto_repeat() -> void;

auto set_can_focus(bool new_state) -> std::shared_ptr<Button> {
this->can_focus = new_state;
return std::dynamic_pointer_cast<Button>(this->shared_from_this());
}

auto set_is_default(bool new_state) -> std::shared_ptr<Button> {
this->is_default = new_state;
this->needs_redraw = true;
Expand Down
2 changes: 1 addition & 1 deletion src/theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ auto ThemePlasma::draw_button(Bitmap &content, bool has_focus, bool is_default,
background2);
}

if (has_frame || state != ButtonStates::Normal) {
if (has_frame || state != ButtonStates::Normal || has_focus) {
content.draw_rounded_rectangle(0, 0, content.size.width, content.size.height - 1, 5, border,
border);
content.line(2, content.size.height - 1, content.size.width - 2, content.size.height - 1,
Expand Down
1 change: 1 addition & 0 deletions src/toolbar.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ auto Toolbar::add_shortcut(std::shared_ptr<Shortcut> s) -> std::shared_ptr<Toolb
}
})
->set_has_frame(false)
->set_can_focus(false)
->set_auto_shrink(true);
if ((icon = window->platform->image_loader->loadFile(s->icon_name))) {
b->set_icon(icon);
Expand Down

0 comments on commit 4a8c873

Please sign in to comment.