Skip to content

Commit

Permalink
Pass &TabState to all relevant functions in Behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Jun 25, 2024
1 parent 6e88ea9 commit ee1286a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/behavior.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub trait Behavior<Pane> {
ui: &mut Ui,
id: Id,
tile_id: TileId,
state: TabState,
state: &TabState,
) -> Response {
let text = self.tab_title_for_tile(tiles, tile_id);
let close_btn_size = Vec2::splat(self.close_button_outer_size());
Expand All @@ -119,8 +119,8 @@ pub trait Behavior<Pane> {

// Show a gap when dragged
if ui.is_rect_visible(tab_rect) && !state.is_being_dragged {
let bg_color = self.tab_bg_color(ui.visuals(), tiles, tile_id, &state);
let stroke = self.tab_outline_stroke(ui.visuals(), tiles, tile_id, &state);
let bg_color = self.tab_bg_color(ui.visuals(), tiles, tile_id, state);
let stroke = self.tab_outline_stroke(ui.visuals(), tiles, tile_id, state);
ui.painter()
.rect(tab_rect.shrink(0.5), 0.0, bg_color, stroke);

Expand All @@ -134,7 +134,7 @@ pub trait Behavior<Pane> {
}

// Prepare title's text for rendering
let text_color = self.tab_text_color(ui.visuals(), tiles, tile_id, state.active);
let text_color = self.tab_text_color(ui.visuals(), tiles, tile_id, state);
let text_position = egui::Align2::LEFT_CENTER
.align_size_within_rect(galley.size(), tab_rect.shrink(x_margin))
.min;
Expand Down Expand Up @@ -344,9 +344,9 @@ pub trait Behavior<Pane> {
visuals: &Visuals,
_tiles: &Tiles<Pane>,
_tile_id: TileId,
active: bool,
state: &TabState,
) -> Color32 {
if active {
if state.active {
visuals.widgets.active.text_color()
} else {
visuals.widgets.noninteractive.text_color()
Expand Down
2 changes: 1 addition & 1 deletion src/container/tabs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ impl Tabs {
};

let response =
behavior.tab_ui(&mut tree.tiles, ui, id, child_id, tab_state);
behavior.tab_ui(&mut tree.tiles, ui, id, child_id, &tab_state);

if response.clicked() {
behavior.on_edit(EditAction::TabSelected);
Expand Down

0 comments on commit ee1286a

Please sign in to comment.