Skip to content

Commit 39f3937

Browse files
committed
use linear color space, tweak colors
1 parent 84e319c commit 39f3937

File tree

16 files changed

+162
-123
lines changed

16 files changed

+162
-123
lines changed

crates/bevy_utils/src/dev/theme.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ use bevy::prelude::*;
77
use bevy_inspector_egui::Inspectable;
88

99
pub fn color_of_hex(hex: &str) -> Color {
10-
Color::hex(hex).unwrap()
10+
let color = Color::hex(hex).unwrap();
11+
color.as_rgba_linear()
1112
}
1213

1314
#[derive(Copy, Clone, PartialEq, Serialize, Deserialize, Debug, Default)]

crates/bevy_utils/src/util/text.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,22 @@ impl BevyUtil {
3535
commands.entity(entity).push_children(&[text_entity]);
3636
text_entity
3737
}
38+
pub fn set_text_size(text: &mut Text, font_size: f32) {
39+
for section in text.sections.iter_mut() {
40+
section.style.font_size = font_size;
41+
}
42+
}
3843
pub fn set_text_color(text: &mut Text, color: Color) {
3944
for section in text.sections.iter_mut() {
4045
section.style.color = color;
4146
}
4247
}
48+
pub fn set_text_size_color(text: &mut Text, font_size: f32, color: Color) {
49+
for section in text.sections.iter_mut() {
50+
section.style.font_size = font_size;
51+
section.style.color = color;
52+
}
53+
}
4354
pub fn set_text_value(text: &mut Text, v: String) {
4455
for section in text.sections.iter_mut() {
4556
section.value = v;

crates/notation_bevy/src/mini/mini_bar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<'a> LyonShape<shapes::Rectangle> for MiniBarShape<'a> {
9898
}
9999
let mut z = self.theme.core.mini_bar_z;
100100
if self.data.value.playing_state.is_current() {
101-
z += 2.0;
101+
z += 1.0;
102102
}
103103
Transform::from_xyz(0.0, 0.0, z)
104104
}

crates/notation_bevy/src/mini/mini_section_separator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl<'a> LyonShape<shapes::Line> for MiniSectionSeparator<'a> {
6363
let line_width = self.theme.sizes.mini_map.section_separator;
6464
let x_offset = -self.data.value.width / 2.0;
6565

66-
Transform::from_xyz(line_width + x_offset, 0.0, self.theme.core.mini_bar_z + 1.0)
66+
Transform::from_xyz(line_width + x_offset, 0.0, self.theme.core.mini_bar_z + 2.0)
6767
}
6868
}
6969

crates/notation_bevy/src/play/pos_indicator.rs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,32 @@ pub struct PosIndicator<'a> {
3737
pub data: PosIndicatorData,
3838
}
3939

40-
impl<'a> LyonShape<shapes::Line> for PosIndicator<'a> {
40+
impl<'a> LyonShape<shapes::Rectangle> for PosIndicator<'a> {
4141
fn get_name(&self) -> String {
4242
"Current Pos".to_string()
4343
}
44-
fn get_shape(&self) -> shapes::Line {
45-
shapes::Line(
46-
Vec2::ZERO,
47-
Vec2::new(
48-
0.0,
49-
-self.data.bar_layout.size.height - self.theme.grid.bar_separator_extra * 2.0,
50-
),
51-
)
44+
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;
47+
shapes::Rectangle {
48+
width,
49+
height,
50+
origin: shapes::RectangleOrigin::TopLeft,
51+
}
5252
}
5353
fn get_colors(&self) -> ShapeColors {
54-
ShapeColors::new(self.theme.core.pos_indicator_color)
54+
ShapeColors::outlined(
55+
self.theme
56+
.colors
57+
.of_section(self.data.bar_props.section_index),
58+
self.theme.core.pos_indicator_color,
59+
)
5560
}
5661
fn get_draw_mode(&self) -> DrawMode {
57-
let line_width = self.theme.grid.pos_indicator_size;
58-
DrawMode::Stroke(StrokeOptions::default().with_line_width(line_width))
62+
DrawMode::Outlined {
63+
fill_options: FillOptions::default(),
64+
outline_options: StrokeOptions::default().with_line_width(self.theme.grid.pos_indicator_outline),
65+
}
5966
}
6067
fn get_transform(&self) -> Transform {
6168
if self.data.bar_layout.size.width <= 0.0 {
@@ -70,7 +77,7 @@ impl<'a> LyonShape<shapes::Line> for PosIndicator<'a> {
7077
}
7178
}
7279

73-
impl<'a> LyonShapeOp<'a, NotationTheme, PosIndicatorData, shapes::Line, PosIndicator<'a>>
80+
impl<'a> LyonShapeOp<'a, NotationTheme, PosIndicatorData, shapes::Rectangle, PosIndicator<'a>>
7481
for PosIndicator<'a>
7582
{
7683
fn new_shape(theme: &'a NotationTheme, data: PosIndicatorData) -> PosIndicator<'a> {

crates/notation_bevy/src/rhythm/rhythm_indicator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ impl<'a> LyonShape<shapes::SvgPathShape> for RhythmIndicator<'a> {
5858
self.data.shape(self.theme)
5959
}
6060
fn get_colors(&self) -> ShapeColors {
61-
/*
6261
ShapeColors::new(
6362
self.theme
6463
.colors
6564
.of_section(self.data.bar_props.section_index),
6665
)
67-
*/
66+
/*
6867
ShapeColors::new(self.theme.colors.rhythm.indicator)
68+
*/
6969
}
7070
fn get_draw_mode(&self) -> DrawMode {
7171
let line_width = self.theme.sizes.tab_control.rhythm_indicator_line_width;

crates/notation_bevy/src/strings/pick_note.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,20 @@ impl PickNoteValue {
2727
}
2828

2929
impl PickNoteData {
30-
pub fn calc_width_height(&self, theme: &NotationTheme) -> (f32, f32) {
31-
let outline = theme
30+
pub fn calc_outline(&self, theme: &NotationTheme) -> f32 {
31+
theme
3232
.sizes
3333
.strings
3434
.note_outline
35-
.of_state(&self.value.playing_state);
36-
let mut width =
35+
.of_state(&self.value.playing_state)
36+
}
37+
pub fn calc_width_height(&self, theme: &NotationTheme) -> (f32, f32) {
38+
let outline = self.calc_outline(theme);
39+
let width =
3740
self.value.bar_size / self.bar_props.bar_units.0 * self.entry_props.tied_units.0;
3841
let mut height = theme.sizes.strings.note_height;
3942
if self.value.playing_state.is_current() {
4043
height += outline;
41-
} else {
42-
width -= outline * 2.0;
4344
}
4445
(width, height)
4546
}
@@ -91,12 +92,7 @@ impl<'a> LyonShape<shapes::Rectangle> for PickNoteShape<'a> {
9192
)
9293
}
9394
fn get_draw_mode(&self) -> DrawMode {
94-
let outline = self
95-
.theme
96-
.sizes
97-
.strings
98-
.note_outline
99-
.of_state(&self.data.value.playing_state);
95+
let outline = self.data.calc_outline(self.theme);
10096
DrawMode::Outlined {
10197
fill_options: FillOptions::default(),
10298
outline_options: StrokeOptions::default().with_line_width(outline),
@@ -110,9 +106,14 @@ impl<'a> LyonShape<shapes::Rectangle> for PickNoteShape<'a> {
110106
* self.data.entry_props.in_bar_pos.0;
111107
let y = -1.0
112108
* self.theme.strings.string_space
113-
* (self.data.value.pick_note.string as f32 - 1.0)
114-
- self.theme.strings.note_height / 2.0;
115-
Transform::from_xyz(x, y, self.theme.strings.pick_z)
109+
* (self.data.value.pick_note.string as f32 - 1.0);
110+
let (_width, height) = self.calc_width_height();
111+
let extra_z = if self.data.value.playing_state.is_current() {
112+
1.0
113+
} else {
114+
0.0
115+
};
116+
Transform::from_xyz(x, y + height / 2.0, self.theme.strings.pick_z + extra_z)
116117
}
117118
}
118119

crates/notation_bevy/src/theme/core_theme.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use notation_model::prelude::Signature;
77
#[cfg(feature = "inspector")]
88
use bevy_inspector_egui::Inspectable;
99

10+
use crate::prelude::ThemeColors;
11+
1012
#[derive(Copy, Clone, PartialEq, Serialize, Deserialize, Debug)]
1113
#[cfg_attr(feature = "inspector", derive(Inspectable))]
1214
pub struct CoreTheme {
@@ -27,15 +29,15 @@ pub struct CoreTheme {
2729
impl Default for CoreTheme {
2830
fn default() -> Self {
2931
Self {
30-
background_color: Color::hex("FFF9F2").unwrap(),
31-
bar_separator_color: Color::hex("D3B59C").unwrap(),
32+
background_color: ThemeColors::hex_linear("FFF9F2"),
33+
bar_separator_color: ThemeColors::hex_linear("D3B59C"),
3234
bar_separator_z: 2.0,
3335
beat_color0: None,
34-
beat_color1: Some(Color::hex("00000010").unwrap()),
36+
beat_color1: Some(ThemeColors::hex_linear("00000010")),
3537
beat_color2: None,
3638
beat_z: 0.0,
3739
bar_indicator_z: 19.0,
38-
pos_indicator_color: Color::hex("00FF00").unwrap(),
40+
pos_indicator_color: ThemeColors::hex_linear("00000077"),
3941
pos_indicator_z: 20.0,
4042
mini_map_z: 22.0,
4143
mini_bar_z: 24.0,

crates/notation_bevy/src/theme/grid_theme.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub struct GridTheme {
1717
pub bar_separator_extra: f32,
1818
pub bar_beat_extra: f32,
1919
pub pos_indicator_size: f32,
20+
pub pos_indicator_outline: f32,
2021
pub pos_indicator_extra: f32,
2122
}
2223

@@ -32,6 +33,7 @@ impl Default for GridTheme {
3233
bar_separator_extra: 8.0,
3334
bar_beat_extra: 0.0,
3435
pos_indicator_size: 2.0,
36+
pos_indicator_outline: 0.5,
3537
pos_indicator_extra: 8.0,
3638
}
3739
}

crates/notation_bevy/src/theme/lyrics_theme.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
use bevy::prelude::*;
22
use bevy_utils::prelude::BevyUtil;
3+
use notation_model::prelude::PlayingState;
34
use serde::{Deserialize, Serialize};
45

56
use crate::prelude::NotationAssets;
67

78
#[cfg(feature = "inspector")]
89
use bevy_inspector_egui::Inspectable;
910

11+
use super::theme_sizes::PlayingSize;
12+
1013
#[derive(Copy, Clone, PartialEq, Serialize, Deserialize, Debug)]
1114
#[cfg_attr(feature = "inspector", derive(Inspectable))]
1215
pub struct LyricsTheme {
@@ -16,20 +19,20 @@ pub struct LyricsTheme {
1619
pub line_size: f32,
1720
pub line_color: Color,
1821
pub word_gap: f32,
19-
pub word_font_size: f32,
22+
pub word_font_size: PlayingSize,
2023
pub word_font_color: Color,
2124
}
2225

2326
impl Default for LyricsTheme {
2427
fn default() -> Self {
2528
Self {
2629
text_x: 4.0,
27-
text_y: -8.0,
30+
text_y: -10.0,
2831
text_z: 1.0,
2932
line_size: 2.0,
3033
line_color: Color::hex("555555").unwrap(),
3134
word_gap: 1.0,
32-
word_font_size: 20.0,
35+
word_font_size: PlayingSize::new(20.0, 22.0, 20.0),
3336
word_font_color: Color::hex("000000").unwrap(),
3437
}
3538
}
@@ -49,7 +52,7 @@ impl LyricsTheme {
4952
entity,
5053
text,
5154
assets.cn_font.clone(),
52-
self.word_font_size,
55+
self.word_font_size.of_state(&PlayingState::Idle),
5356
self.word_font_color,
5457
HorizontalAlign::Right,
5558
VerticalAlign::Center,

0 commit comments

Comments
 (0)