Skip to content

Commit 9cb87d0

Browse files
committed
add setting for override_tab_width, mainly for video recording purpose
1 parent 73bceae commit 9cb87d0

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

crates/notation_bevy/src/settings/layout_settings.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub struct LayoutSettings {
4949
pub focus_bar_ease_ms: u64,
5050
pub focusing_bar_ordinal: usize,
5151
pub video_recording_mode: bool,
52+
pub override_tab_width: Option<f32>,
5253
pub override_focus_offset_y: Option<f32>,
5354
}
5455

@@ -60,6 +61,7 @@ impl Default for LayoutSettings {
6061
focus_bar_ease_ms: 250,
6162
focusing_bar_ordinal: usize::MAX,
6263
video_recording_mode: false,
64+
override_tab_width: None,
6365
override_focus_offset_y: None,
6466
}
6567
}

crates/notation_bevy/src/tab/tab_bars.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ impl<'a> GridView<NotationLayout<'a>, BarView> for TabBars {
5757
beat_size_range.0 * bar_beats,
5858
beat_size_range.1 * bar_beats,
5959
);
60+
let tab_width = match engine.settings.layout.override_tab_width {
61+
Some(width) => width,
62+
None => grid_size.width,
63+
};
6064
let (rows, cols, cell_width) = GridData::cals_fixed_rows_cols_by_width(
61-
grid_size.width - bar_margin * 2.0,
65+
tab_width - bar_margin * 2.0,
6266
bar_width_range,
6367
0.0,
6468
self.tab.bars.len(),
@@ -113,14 +117,24 @@ impl<'a> GridView<NotationLayout<'a>, BarView> for TabBars {
113117
let bar_layout = self.bar_layouts.get(row * cols).unwrap();
114118
row_sizes.push(LayoutSize::new(cell_width, bar_layout.height()));
115119
}
116-
GridData::new_rows(
120+
let grid_data = GridData::new_rows(
117121
rows,
118122
cols,
119123
row_sizes,
120124
cell_margin,
121125
LayoutAnchor::TOP_LEFT,
122126
grid_size,
123-
)
127+
);
128+
match engine.settings.layout.override_tab_width {
129+
None => grid_data,
130+
Some(_) => {
131+
let offset = grid_data.content_size.calc_offset(LayoutAnchor::TOP_LEFT, LayoutAnchor::TOP_LEFT) + Vec2::new(bar_margin, 0.0);
132+
GridData {
133+
offset,
134+
..grid_data
135+
}
136+
}
137+
}
124138
}
125139
}
126140
}

crates/notation_bevy/src/viewer/control_view.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,20 @@ impl ControlView {
9494
CollapsingHeader::new("Override Sizes")
9595
.default_open(true)
9696
.show(ui, |ui| {
97+
let mut override_tab_width = settings.layout.override_tab_width.is_some();
98+
ui.checkbox(&mut override_tab_width, "Override Tab Width");
99+
if override_tab_width {
100+
let mut tab_width = settings.layout.override_tab_width.unwrap_or(512.0);
101+
let last_tab_width = tab_width;
102+
ui.add(Slider::new(&mut tab_width, 256.0..=1024.0).text("Tab Width"));
103+
if settings.layout.override_tab_width.is_none() || float_ne!(tab_width, last_tab_width, abs <= 1.0) {
104+
settings.layout.override_tab_width = Some(tab_width);
105+
window_resized_evts.send(WindowResizedEvent());
106+
}
107+
} else if settings.layout.override_tab_width.is_some() {
108+
settings.layout.override_tab_width = None;
109+
window_resized_evts.send(WindowResizedEvent());
110+
}
97111
let mut override_beat_size = settings.override_beat_size.is_some();
98112
ui.checkbox(&mut override_beat_size, "Override Beat Size");
99113
if override_beat_size {

0 commit comments

Comments
 (0)