diff options
-rw-r--r-- | engine.c | 58 |
1 files changed, 46 insertions, 12 deletions
@@ -22,10 +22,11 @@ static void highlight_line(int value, int y, int max_x, uint32_t color); | |||
22 | void | 22 | void |
23 | engine_redraw() | 23 | engine_redraw() |
24 | { | 24 | { |
25 | const char *config_hints[] = { "No", "Harfe", "File", "Edit" }; | ||
25 | char text[32]; | 26 | char text[32]; |
26 | char *config_hints[] = { "No", "Harfe", "File", "Edit" }; | 27 | const int tos1 = g_midi_three_octave_split_1, tos2 = g_midi_three_octave_split_2; |
27 | int i, MAX_X, MAX_Y, FONT_HEIGHT; | 28 | const int height = g_max_y - g_min_y; |
28 | int height = g_max_y - g_min_y; | 29 | int i, x2, MAX_X, MAX_Y, FONT_HEIGHT; |
29 | 30 | ||
30 | display_redraw(); | 31 | display_redraw(); |
31 | display_clear(); | 32 | display_clear(); |
@@ -36,7 +37,6 @@ engine_redraw() | |||
36 | 37 | ||
37 | if (height) { | 38 | if (height) { |
38 | int b = g_midi_three_octave_split_inverse; | 39 | int b = g_midi_three_octave_split_inverse; |
39 | int tos1 = g_midi_three_octave_split_1, tos2 = g_midi_three_octave_split_2; | ||
40 | display_text( b ? "+1" : "-1", 4, scale(g_min_y + tos1 * height / 200) + FONT_HEIGHT / 2, 0x007f7f7fff); | 40 | display_text( b ? "+1" : "-1", 4, scale(g_min_y + tos1 * height / 200) + FONT_HEIGHT / 2, 0x007f7f7fff); |
41 | display_text( " 0", 4, scale(g_min_y + (tos1 + tos2) * height / 200) + FONT_HEIGHT / 2, 0x007f7f7fff); | 41 | display_text( " 0", 4, scale(g_min_y + (tos1 + tos2) * height / 200) + FONT_HEIGHT / 2, 0x007f7f7fff); |
42 | display_text( b ? "-1" : "+1", 4, scale(g_min_y + (tos2 / 2 + 50 ) * height / 100) + FONT_HEIGHT / 2, 0x007f7f7fff); | 42 | display_text( b ? "-1" : "+1", 4, scale(g_min_y + (tos2 / 2 + 50 ) * height / 100) + FONT_HEIGHT / 2, 0x007f7f7fff); |
@@ -49,7 +49,6 @@ engine_redraw() | |||
49 | display_line_color(0, scale(g_min_y + tos1 * height / 100), MAX_X, scale(g_min_y + tos1 * height / 100), 0x00ff00ff); | 49 | display_line_color(0, scale(g_min_y + tos1 * height / 100), MAX_X, scale(g_min_y + tos1 * height / 100), 0x00ff00ff); |
50 | display_line_color(0, scale(g_min_y + tos2 * height / 100), MAX_X, scale(g_min_y + tos2 * height / 100), 0x00ff00ff); | 50 | display_line_color(0, scale(g_min_y + tos2 * height / 100), MAX_X, scale(g_min_y + tos2 * height / 100), 0x00ff00ff); |
51 | 51 | ||
52 | |||
53 | switch (g_selected_config) { | 52 | switch (g_selected_config) { |
54 | case sel_min_y: highlight_line(g_min_y, g_min_y, MAX_X, 0xff00ffff); break; | 53 | case sel_min_y: highlight_line(g_min_y, g_min_y, MAX_X, 0xff00ffff); break; |
55 | case sel_max_y: highlight_line(g_max_y, g_max_y, MAX_X, 0xff00ffff); break; | 54 | case sel_max_y: highlight_line(g_max_y, g_max_y, MAX_X, 0xff00ffff); break; |
@@ -61,17 +60,28 @@ engine_redraw() | |||
61 | 60 | ||
62 | for (i = 0; i < g_string_count; ++i) { | 61 | for (i = 0; i < g_string_count; ++i) { |
63 | LLine *l = &g_string_conf[i].line; | 62 | LLine *l = &g_string_conf[i].line; |
63 | LLine _l = g_string_conf[i].line; // Copy for extension | ||
64 | uint32_t color = ( ( i == g_selected_string ) ? 0xff00ffff : 0x00ffffffff ); | 64 | uint32_t color = ( ( i == g_selected_string ) ? 0xff00ffff : 0x00ffffffff ); |
65 | uint32_t text_color = ( ( i == g_selected_string ) ? 0xff00ffff : 0x007f7f7fff ); | 65 | uint32_t text_color = ( ( i == g_selected_string ) ? 0xff00ffff : 0x007f7f7fff ); |
66 | int extended = 0, center_y = g_min_y+height/2; | ||
66 | 67 | ||
67 | int center_y = g_min_y+height/2; | 68 | if (_l.p0.y > g_min_y) { |
68 | int x2 = l->p1.x; | 69 | _l.p0.x = get_x_for_y(&_l.p0, &_l.p1, g_min_y); |
69 | 70 | _l.p0.y = g_min_y; | |
70 | if (l->p1.x!=l->p0.x) { | 71 | extended = 1; |
71 | double m = (double)(l->p1.y-l->p0.y) / (double)(l->p1.x-l->p0.x); | 72 | } |
72 | double _x2 = ((double)center_y) - (double)l->p0.y + m * (double)l->p0.x; | 73 | if (_l.p1.y < g_max_y) { |
73 | x2 = (int)(_x2/m); | 74 | _l.p1.x = get_x_for_y(&l->p0 /* Using unmodified original! */, &_l.p1, g_max_y); |
75 | _l.p1.y = g_max_y; | ||
76 | extended = 1; | ||
74 | } | 77 | } |
78 | if (extended) { | ||
79 | display_line_color(scale(_l.p0.x), scale(_l.p0.y), scale(_l.p1.x), scale(_l.p1.y), 0x007f3f00); | ||
80 | display_circle_color(scale(_l.p0.x), scale(_l.p0.y), 4, 0x007f3f00); | ||
81 | display_circle_color(scale(_l.p1.x), scale(_l.p1.y), 4, 0x007f3f00); | ||
82 | } | ||
83 | |||
84 | x2 = get_x_for_y(&l->p0,&l->p1,center_y); | ||
75 | 85 | ||
76 | if (g_string_conf[i].playing) | 86 | if (g_string_conf[i].playing) |
77 | display_text(config_midi_note_to_string(g_string_conf[i].note+12*g_string_conf[i].octave), scale(x2-20), scale(center_y) + FONT_HEIGHT, text_color ); | 87 | display_text(config_midi_note_to_string(g_string_conf[i].note+12*g_string_conf[i].octave), scale(x2-20), scale(center_y) + FONT_HEIGHT, text_color ); |
@@ -100,11 +110,29 @@ highlight_line(int value, int y, int max_x, uint32_t color) { | |||
100 | display_line_color(max_x, scale(y+10), max_x-10, scale(y), color); | 110 | display_line_color(max_x, scale(y+10), max_x-10, scale(y), color); |
101 | 111 | ||
102 | display_rect_color(max_x/2-40, scale(y+20), 80, 40, 0xffffffff); | 112 | display_rect_color(max_x/2-40, scale(y+20), 80, 40, 0xffffffff); |
113 | snprintf(text, sizeof(text), "%d", value); | ||
103 | display_text(text, max_x/2-20, scale(y+20), 0); | 114 | display_text(text, max_x/2-20, scale(y+20), 0); |
104 | } | 115 | } |
105 | 116 | ||
106 | void | 117 | void |
107 | engine_select_config(ConfigSelect sel) { | 118 | engine_select_config(ConfigSelect sel) { |
119 | // test if we have moved g_min_y or g_max_y and resize lines accordingly | ||
120 | if (sel == sel_none) { | ||
121 | int i; | ||
122 | for (i=0; i<g_string_count; ++i) { | ||
123 | LLine *l = &g_string_conf[i].line; | ||
124 | LLine _l = g_string_conf[i].line; // Copy for extension | ||
125 | |||
126 | if (l->p0.y > g_min_y) { | ||
127 | l->p0.x = get_x_for_y(&l->p0, &l->p1, g_min_y); | ||
128 | l->p0.y = g_min_y; | ||
129 | } | ||
130 | if (l->p1.y < g_max_y) { | ||
131 | l->p1.x = get_x_for_y(&_l.p0 /* Using unmodified original! */, &l->p1, g_max_y); | ||
132 | l->p1.y = g_max_y; | ||
133 | } | ||
134 | } | ||
135 | } | ||
108 | g_selected_config = sel; | 136 | g_selected_config = sel; |
109 | } | 137 | } |
110 | 138 | ||
@@ -112,6 +140,12 @@ ConfigSelect | |||
112 | engine_change_selected(int off) | 140 | engine_change_selected(int off) |
113 | { | 141 | { |
114 | switch(g_selected_config) { | 142 | switch(g_selected_config) { |
143 | case sel_min_y: | ||
144 | g_min_y += off; | ||
145 | break; | ||
146 | case sel_max_y: | ||
147 | g_max_y += off; | ||
148 | break; | ||
115 | case sel_3_oct_top: | 149 | case sel_3_oct_top: |
116 | g_midi_three_octave_split_2 += off; | 150 | g_midi_three_octave_split_2 += off; |
117 | if (g_midi_three_octave_split_2<0) g_midi_three_octave_split_2 = 0; | 151 | if (g_midi_three_octave_split_2<0) g_midi_three_octave_split_2 = 0; |