Skip to content

Commit f18d72e

Browse files
committed
adjust sizes, cleanup theme a bit
1 parent 39f3937 commit f18d72e

File tree

17 files changed

+89
-128
lines changed

17 files changed

+89
-128
lines changed

crates/bevy_utils/src/layout/grid.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,10 @@ impl GridData {
188188
total: usize,
189189
) -> (usize, f32) {
190190
let content_size = side_size - margin * 2.0;
191-
if total == 0 || content_size <= cell_size_range.0 {
191+
if total == 0 {
192192
return (0, 0.0);
193+
} else if content_size <= cell_size_range.0 {
194+
return (1, side_size);
193195
}
194196
let cell_size_with_margin =
195197
BevyUtil::in_range_with_margin(content_size / total as f32, cell_size_range, margin);

crates/notation_bevy/src/bar/bar_beat.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl BarBeatValue {
3636
beat: u8,
3737
) -> Option<Self> {
3838
theme
39-
.core
39+
.colors.bar
4040
.get_beat_color(signature, beat)
4141
.map(|_color| Self::new(tab_bar, signature, beat))
4242
}
@@ -59,15 +59,15 @@ impl<'a> LyonShape<shapes::Rectangle> for BarBeat<'a> {
5959
fn get_shape(&self) -> shapes::Rectangle {
6060
shapes::Rectangle {
6161
width: self.data.value.bar_size.width / self.data.value.bar_beats as f32,
62-
height: (self.data.value.bar_size.height + self.theme.grid.bar_beat_extra * 2.0),
62+
height: (self.data.value.bar_size.height + self.theme.sizes.bar.bar_beat_extra * 2.0),
6363
origin: shapes::RectangleOrigin::TopLeft,
6464
}
6565
}
6666
fn get_colors(&self) -> ShapeColors {
6767
let signature = self.data.value.signature;
6868
let color = self
6969
.theme
70-
.core
70+
.colors.bar
7171
.get_beat_color(&signature, self.data.value.beat);
7272
ShapeColors::new(color.unwrap_or(self.theme.core.background_color))
7373
}
@@ -77,7 +77,7 @@ impl<'a> LyonShape<shapes::Rectangle> for BarBeat<'a> {
7777
fn get_transform(&self) -> Transform {
7878
let x = self.data.value.bar_size.width / self.data.value.bar_beats as f32
7979
* self.data.value.beat as f32;
80-
Transform::from_xyz(x, self.theme.grid.bar_beat_extra, self.theme.core.beat_z)
80+
Transform::from_xyz(x, self.theme.sizes.bar.bar_beat_extra, self.theme.core.beat_z)
8181
}
8282
}
8383

crates/notation_bevy/src/bar/bar_separator.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ impl<'a> LyonShape<shapes::Line> for BarSeparator<'a> {
3434
}
3535
fn get_shape(&self) -> shapes::Line {
3636
shapes::Line(
37-
Vec2::new(0.0, self.theme.grid.bar_separator_extra),
37+
Vec2::new(0.0, self.theme.sizes.bar.bar_separator_extra),
3838
Vec2::new(
3939
0.0,
40-
-self.data.value.bar_size.height - self.theme.grid.bar_separator_extra,
40+
-self.data.value.bar_size.height - self.theme.sizes.bar.bar_separator_extra,
4141
),
4242
)
4343
}
4444
fn get_colors(&self) -> ShapeColors {
45-
ShapeColors::new(self.theme.core.bar_separator_color)
45+
ShapeColors::new(self.theme.colors.bar.bar_separator_color)
4646
}
4747
fn get_draw_mode(&self) -> DrawMode {
48-
let line_width = self.theme.grid.bar_separator_size;
48+
let line_width = self.theme.sizes.bar.bar_separator_size;
4949
DrawMode::Stroke(StrokeOptions::default().with_line_width(line_width))
5050
}
5151
fn get_transform(&self) -> Transform {

crates/notation_bevy/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ pub mod prelude {
115115
#[doc(hidden)]
116116
pub use crate::theme::core_theme::CoreTheme;
117117
#[doc(hidden)]
118-
pub use crate::theme::grid_theme::GridTheme;
119-
#[doc(hidden)]
120118
pub use crate::theme::guitar_theme::GuitarTheme;
121119
#[doc(hidden)]
122120
pub use crate::theme::notation_theme::NotationTheme;

crates/notation_bevy/src/play/bar_indicator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,23 @@ impl<'a> LyonShape<shapes::Rectangle> for BarIndicator<'a> {
3232
fn get_shape(&self) -> shapes::Rectangle {
3333
shapes::Rectangle {
3434
width: self.data.bar_layout.size.width,
35-
height: self.data.bar_layout.size.height + self.theme.grid.bar_separator_extra * 2.0,
35+
height: self.data.bar_layout.size.height + self.theme.sizes.bar.bar_separator_extra * 2.0,
3636
origin: shapes::RectangleOrigin::TopLeft,
3737
}
3838
}
3939
fn get_colors(&self) -> ShapeColors {
4040
ShapeColors::new(self.theme.colors.bar.bar_indicator)
4141
}
4242
fn get_draw_mode(&self) -> DrawMode {
43-
let line_width = self.theme.grid.pos_indicator_size;
43+
let line_width = self.theme.sizes.bar.pos_indicator_size;
4444
DrawMode::Stroke(StrokeOptions::default().with_line_width(line_width))
4545
}
4646
fn get_transform(&self) -> Transform {
4747
if self.data.bar_layout.size.width <= 0.0 {
4848
return BevyUtil::offscreen_transform();
4949
}
5050
let x = self.data.bar_layout.offset.x;
51-
let y = self.data.bar_layout.offset.y + self.theme.grid.bar_separator_extra;
51+
let y = self.data.bar_layout.offset.y + self.theme.sizes.bar.bar_separator_extra;
5252
Transform::from_xyz(x, y, self.theme.core.bar_indicator_z)
5353
}
5454
}

crates/notation_bevy/src/play/pos_indicator.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ impl<'a> LyonShape<shapes::Rectangle> for PosIndicator<'a> {
4242
"Current Pos".to_string()
4343
}
4444
fn get_shape(&self) -> shapes::Rectangle {
45-
let width = self.theme.grid.pos_indicator_size;
46-
let height = self.data.bar_layout.size.height + self.theme.grid.bar_separator_extra * 2.0;
45+
let width = self.theme.sizes.bar.pos_indicator_size;
46+
let height = self.data.bar_layout.size.height + self.theme.sizes.bar.bar_separator_extra * 2.0;
4747
shapes::Rectangle {
4848
width,
4949
height,
@@ -55,13 +55,13 @@ impl<'a> LyonShape<shapes::Rectangle> for PosIndicator<'a> {
5555
self.theme
5656
.colors
5757
.of_section(self.data.bar_props.section_index),
58-
self.theme.core.pos_indicator_color,
58+
self.theme.colors.bar.pos_indicator_color,
5959
)
6060
}
6161
fn get_draw_mode(&self) -> DrawMode {
6262
DrawMode::Outlined {
6363
fill_options: FillOptions::default(),
64-
outline_options: StrokeOptions::default().with_line_width(self.theme.grid.pos_indicator_outline),
64+
outline_options: StrokeOptions::default().with_line_width(self.theme.sizes.bar.pos_indicator_outline),
6565
}
6666
}
6767
fn get_transform(&self) -> Transform {
@@ -71,7 +71,7 @@ impl<'a> LyonShape<shapes::Rectangle> for PosIndicator<'a> {
7171
let y = self.data.bar_layout.offset.y;
7272
Transform::from_xyz(
7373
self.data.offset_x(),
74-
y + self.theme.grid.bar_separator_extra,
74+
y + self.theme.sizes.bar.bar_separator_extra,
7575
self.theme.core.pos_indicator_z,
7676
)
7777
}

crates/notation_bevy/src/settings/layout_settings.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ impl LayoutSettings {
140140
if last_row_height + pos_data.bar_layout.size.height <= grid_size.height / 2.0 {
141141
y = grid_data.calc_cell_offset(row - 1, col).y;
142142
}
143-
let min_y = grid_size.height - content_size.height - theme.grid.margin * 2.0;
143+
let min_y = grid_size.height - content_size.height - theme.sizes.layout.margin * 2.0;
144144
if y < min_y {
145145
y = min_y;
146146
}
147147
}
148-
y - layout.offset.y - grid_data.offset.y + theme.grid.margin
148+
y - layout.offset.y - grid_data.offset.y + theme.sizes.layout.margin
149149
}
150150
fn calc_line_focus_xy(
151151
&self,
@@ -176,7 +176,7 @@ impl LayoutSettings {
176176
let content_size = grid_data.content_size;
177177
let y = pos_data.bar_layout.offset.y + grid_size.height
178178
- content_size.height
179-
- theme.grid.margin;
179+
- theme.sizes.layout.margin;
180180
(
181181
x - layout.offset.x - grid_data.offset.x,
182182
y - layout.offset.y,

crates/notation_bevy/src/strings/pick_note.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ impl PickNoteData {
3535
.of_state(&self.value.playing_state)
3636
}
3737
pub fn calc_width_height(&self, theme: &NotationTheme) -> (f32, f32) {
38-
let outline = self.calc_outline(theme);
3938
let width =
4039
self.value.bar_size / self.bar_props.bar_units.0 * self.entry_props.tied_units.0;
4140
let mut height = theme.sizes.strings.note_height;
4241
if self.value.playing_state.is_current() {
43-
height += outline;
42+
let outline = self.calc_outline(theme);
43+
height += outline * 2.0;
4444
}
4545
(width, height)
4646
}
@@ -105,7 +105,7 @@ impl<'a> LyonShape<shapes::Rectangle> for PickNoteShape<'a> {
105105
let x = self.data.value.bar_size / self.data.bar_props.bar_units.0
106106
* self.data.entry_props.in_bar_pos.0;
107107
let y = -1.0
108-
* self.theme.strings.string_space
108+
* self.theme.sizes.strings.string_space
109109
* (self.data.value.pick_note.string as f32 - 1.0);
110110
let (_width, height) = self.calc_width_height();
111111
let extra_z = if self.data.value.playing_state.is_current() {

crates/notation_bevy/src/strings/single_string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl<'a> LyonShape<shapes::Line> for SingleString<'a> {
3434
DrawMode::Stroke(StrokeOptions::default().with_line_width(line_width))
3535
}
3636
fn get_transform(&self) -> Transform {
37-
let y = -1.0 * (self.data.value.string as f32 - 0.5) * self.theme.strings.string_space;
37+
let y = -1.0 * (self.data.value.string as f32 - 1.0) * self.theme.sizes.strings.string_space;
3838
Transform::from_xyz(0.0, y, self.theme.strings.string_z)
3939
}
4040
}

crates/notation_bevy/src/tab/tab_bars.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,15 @@ impl<'a> GridView<NotationLayout<'a>, BarView> for TabBars {
4646
if self.tab.bars.len() == 0 {
4747
return GridData::ZERO;
4848
}
49-
let sizes = engine.theme.sizes.bar;
49+
let bar_margin = engine.theme.sizes.layout.bar_margin;
50+
let bar_sizes = engine.theme.sizes.bar;
5051
let bar_beats = self.tab.bar_beats() as f32;
5152
let bar_width_range = (
52-
sizes.beat_size_range.0 * bar_beats,
53-
sizes.beat_size_range.1 * bar_beats,
53+
bar_sizes.beat_size_range.0 * bar_beats,
54+
bar_sizes.beat_size_range.1 * bar_beats,
5455
);
5556
let (rows, cols, cell_width) = GridData::cals_fixed_rows_cols_by_width(
56-
grid_size.width - sizes.row_margin * 2.0,
57+
grid_size.width - bar_margin * 2.0,
5758
bar_width_range,
5859
0.0,
5960
self.tab.bars.len(),
@@ -79,7 +80,7 @@ impl<'a> GridView<NotationLayout<'a>, BarView> for TabBars {
7980
grid_size,
8081
);
8182
GridData {
82-
offset: grid_data.offset + Vec2::new(sizes.row_margin, 0.0),
83+
offset: grid_data.offset + Vec2::new(bar_margin, 0.0),
8384
..grid_data
8485
}
8586
} else {
@@ -191,7 +192,7 @@ impl TabBars {
191192
.enumerate()
192193
.filter_map(|(index, bar)| {
193194
view.bar_layouts.get(index).map(|bar_layout| {
194-
//let transform = theme.grid.calc_bar_transform(&bar_layout);
195+
//let transform = theme.sizes.bar.calc_bar_transform(&bar_layout);
195196
(bar, bar_layout)
196197
})
197198
})

0 commit comments

Comments
 (0)