Integral Types
This commit is contained in:
+21
-21
@@ -158,7 +158,7 @@ auto music_font(std::float32_t size) -> Font {
|
||||
|
||||
auto glyph_box(std::int32_t codepoint) -> smufl_box {
|
||||
auto const& glyphs = vamp_zero::font_data::glyphs;
|
||||
auto found = std::lower_bound(glyphs.begin(), glyphs.end(), codepoint, [](auto const& g, int value) { return g.codepoint < value; });
|
||||
auto found = std::lower_bound(glyphs.begin(), glyphs.end(), codepoint, [](auto const& g, std::int32_t value) { return g.codepoint < value; });
|
||||
if (found == glyphs.end() || found->codepoint != codepoint) return {};
|
||||
return {found->bounds[0], found->bounds[1], found->bounds[2], found->bounds[3]};
|
||||
}
|
||||
@@ -444,8 +444,8 @@ auto duration_for(vamp_zero::score_written_duration const& written, double fallb
|
||||
if (found != names.end()) return {.base = static_cast<duration_base>(found - names.begin()), .dots = written.dots};
|
||||
// Directly constructed layout documents use the same exact written-value lookup.
|
||||
for (auto index = std::size_t{}; index < names.size(); ++index)
|
||||
for (auto dots = 0; dots <= 16; ++dots)
|
||||
if (std::abs(fallback_ticks - std::ldexp(131072.0, -static_cast<int>(index)) * (2.0 - std::ldexp(1.0, -dots))) < 0.00001)
|
||||
for (auto dots = std::int32_t{}; dots <= 16; ++dots)
|
||||
if (std::abs(fallback_ticks - std::ldexp(131072.0, -static_cast<std::int32_t>(index)) * (2.0 - std::ldexp(1.0, -dots))) < 0.00001)
|
||||
return {.base = static_cast<duration_base>(index), .dots = dots};
|
||||
return {};
|
||||
}
|
||||
@@ -457,13 +457,13 @@ auto measure_ticks(vamp_zero::score_measure const& measure) -> double {
|
||||
for (auto const& note : measure.notes) total += spacing_ticks(note);
|
||||
return std::max(1.0, total);
|
||||
}
|
||||
auto has_stem(duration_shape duration) -> bool {
|
||||
auto has_stem(duration_shape duration) -> std::bool_t {
|
||||
return duration.base == duration_base::LONG || duration.base == duration_base::MAXIMA || duration.base >= duration_base::HALF;
|
||||
}
|
||||
auto flag_count(duration_shape duration) -> int {
|
||||
return std::max(0, static_cast<int>(duration.base) - static_cast<int>(duration_base::QUARTER));
|
||||
auto flag_count(duration_shape duration) -> std::int32_t {
|
||||
return std::max(std::int32_t{}, static_cast<std::int32_t>(duration.base) - static_cast<std::int32_t>(duration_base::QUARTER));
|
||||
}
|
||||
auto has_flag(duration_shape duration) -> bool { return flag_count(duration) > 0; }
|
||||
auto has_flag(duration_shape duration) -> std::bool_t { return flag_count(duration) > 0; }
|
||||
|
||||
auto letter_index(std::char_t letter) -> std::int32_t {
|
||||
switch (letter) {
|
||||
@@ -733,7 +733,7 @@ auto event_width(vamp_zero::score_note const& note) -> float {
|
||||
|
||||
auto attribute_width(vamp_zero::score_attribute const& a) -> float {
|
||||
auto result = a.clef.empty() ? 0.0F : 45.0F;
|
||||
if (a.key_alterations) result += 35.0F + 22.0F*std::count_if(a.key_alterations->begin(), a.key_alterations->end(), [](int v) { return v!=0; });
|
||||
if (a.key_alterations) result += 35.0F + 22.0F*std::count_if(a.key_alterations->begin(), a.key_alterations->end(), [](std::int32_t v) { return v!=0; });
|
||||
if (!a.time_signature.empty()) result += 50.0F;
|
||||
return result;
|
||||
}
|
||||
@@ -811,7 +811,7 @@ auto metrics_for(vamp_zero::score_document const& score, vamp_zero::score_system
|
||||
auto const& measure = score.measures[mi];
|
||||
if (!measure.section_label.empty()) result.above = std::max(result.above, 9.0F);
|
||||
auto end = range.first_note + std::min(range.note_count, measure.notes.size()-range.first_note);
|
||||
auto depth = 0;
|
||||
auto depth = std::int32_t{};
|
||||
for (auto const& t : measure.tuplets) depth = std::max(depth, t.depth+1);
|
||||
for (auto ni = range.first_note; ni < end; ++ni) {
|
||||
auto const& n = measure.notes[ni];
|
||||
@@ -1046,7 +1046,7 @@ auto layout_structured_key(vamp_zero::score_page_layout& layout, std::string_vie
|
||||
std::array<std::int32_t, 7> const& alterations, std::float32_t x, std::float32_t top,
|
||||
std::float32_t spacing, std::size_t system, std::array<std::int32_t, 7> const* previous = nullptr) -> std::float32_t {
|
||||
auto start = x;
|
||||
auto paint = [&](int letter, int alteration) {
|
||||
auto paint = [&](std::int32_t letter, std::int32_t alteration) {
|
||||
auto glyph = accidental_glyph(alteration_mark(alteration));
|
||||
if (!glyph) return;
|
||||
auto pitch = vamp_zero::score_pitch{.letter = "cdefgab"[letter], .octave = 4};
|
||||
@@ -1056,9 +1056,9 @@ auto layout_structured_key(vamp_zero::score_page_layout& layout, std::string_vie
|
||||
origin_for_left_baseline(*glyph, x, pitch_y(pitch, top, spacing, clef), spacing), spacing, score_ink(), system);
|
||||
x += glyph_width(*glyph, spacing) + spacing * 0.15F;
|
||||
};
|
||||
if (previous) for (int i = 0; i < 7; ++i)
|
||||
if (previous) for (auto i = std::int32_t{}; i < 7; ++i)
|
||||
if ((*previous)[i] && (*previous)[i] != alterations[i]) paint(i, 0);
|
||||
auto flats = std::any_of(alterations.begin(), alterations.end(), [](int a) { return a < 0; });
|
||||
auto flats = std::any_of(alterations.begin(), alterations.end(), [](std::int32_t a) { return a < 0; });
|
||||
for (auto letter : std::string_view{flats ? "beadgcf" : "fcgdaeb"}) {
|
||||
auto index = letter_index(letter);
|
||||
if (alterations[index]) paint(index, alterations[index]);
|
||||
@@ -1375,9 +1375,9 @@ auto estimate_accidental_columns(note_layout const& note, std::float32_t spacing
|
||||
return left.top < right.top;
|
||||
});
|
||||
for (auto const& candidate : candidates) {
|
||||
auto placed = false;
|
||||
auto placed = std::bool_t{false};
|
||||
for (auto& column : columns) {
|
||||
auto fits = true;
|
||||
auto fits = std::bool_t{true};
|
||||
for (auto const& range : column) {
|
||||
if (candidate.top < range.bottom + spacing * 0.15F && candidate.bottom + spacing * 0.15F > range.top) {
|
||||
fits = false;
|
||||
@@ -1532,7 +1532,7 @@ auto build_note_layout(
|
||||
auto displaced_by_pitch = std::vector<std::bool_t>(raw_heads.size(), false);
|
||||
auto right_column_x = x + glyph_width(result.notehead, spacing) * 0.72F;
|
||||
auto previous_y = std::optional<std::float32_t>{};
|
||||
auto use_right_column = false;
|
||||
auto use_right_column = std::bool_t{false};
|
||||
for (auto const& head : ordered) {
|
||||
if (previous_y && std::abs(*previous_y - head.center_y) <= spacing * 0.55F) {
|
||||
use_right_column = !use_right_column;
|
||||
@@ -1654,7 +1654,7 @@ auto update_beam_group_geometry(std::vector<note_layout>& notes, beam_group_layo
|
||||
}
|
||||
}
|
||||
|
||||
auto beam_type(note_layout const& note, int level) -> std::string_view {
|
||||
auto beam_type(note_layout const& note, std::int32_t level) -> std::string_view {
|
||||
for (auto const& beam : note.source->beams) if (beam.level == level) return beam.type;
|
||||
return {};
|
||||
}
|
||||
@@ -1761,7 +1761,7 @@ auto accidental_layouts(note_layout const& note, std::float32_t spacing) -> std:
|
||||
auto raw_bounds = glyph_bounds(glyph, {.x = 0.0F, .y = head.center_y}, spacing);
|
||||
auto column_index = std::size_t{};
|
||||
for (; column_index < column_ranges.size(); ++column_index) {
|
||||
auto fits = true;
|
||||
auto fits = std::bool_t{true};
|
||||
for (auto const& range : column_ranges[column_index]) {
|
||||
if (raw_bounds.y < range.y + range.height + spacing * 0.15F && raw_bounds.y + raw_bounds.height + spacing * 0.15F > range.y) {
|
||||
fits = false;
|
||||
@@ -1880,7 +1880,7 @@ auto layout_rest(
|
||||
auto y = note.source->rest_position ? pitch_y(*note.source->rest_position, staff_top, spacing, note.source->clef) : rest_baseline_y(note.duration, staff_top, spacing);
|
||||
auto origin = origin_for_centered_baseline(codepoint, note.x, y, spacing);
|
||||
add_glyph(layout, vamp_zero::score_layout_item_role::REST, codepoint, origin, spacing, score_ink(), system_index, measure_index, note.note_index);
|
||||
for (auto dot = 0; dot < note.duration.dots; ++dot) {
|
||||
for (auto dot = std::int32_t{}; dot < note.duration.dots; ++dot) {
|
||||
auto bounds = glyph_bounds(codepoint, origin, spacing);
|
||||
add_glyph(
|
||||
layout,
|
||||
@@ -1929,7 +1929,7 @@ auto layout_note_symbols(
|
||||
auto dot_x = note.visual_right - spacing * 0.65F;
|
||||
for (auto const& head : note.heads) {
|
||||
auto dots = note.source != nullptr && head.source_pitch_index < note.source->pitches.size() && !note.source->pitches[head.source_pitch_index].written.type.empty() ? note.source->pitches[head.source_pitch_index].written.dots : note.duration.dots;
|
||||
for (auto dot = 0; dot < dots; ++dot) add_glyph(
|
||||
for (auto dot = std::int32_t{}; dot < dots; ++dot) add_glyph(
|
||||
layout,
|
||||
vamp_zero::score_layout_item_role::DOT,
|
||||
glyph_augmentation_dot,
|
||||
@@ -2433,7 +2433,7 @@ auto layout_measure(
|
||||
for (auto const& group : beam_groups) {
|
||||
for (auto index = group.first_note; index <= group.last_note; ++index) {
|
||||
auto const& n = notes[index];
|
||||
for (int level = 2; level <= flag_count(n.duration); ++level) {
|
||||
for (auto level = std::int32_t{2}; level <= flag_count(n.duration); ++level) {
|
||||
auto type = beam_type(n, level);
|
||||
auto next = index < group.last_note && flag_count(notes[index+1].duration) >= level;
|
||||
auto previous = index > group.first_note && flag_count(notes[index-1].duration) >= level;
|
||||
@@ -2468,7 +2468,7 @@ auto layout_measure(
|
||||
auto x1 = partner == notes.end() ? n.stem_x+spacing*0.7F : partner->stem_x;
|
||||
if (partner == notes.end() && n.source->tremolo_type == "start") x1 = notation_right_x;
|
||||
if (n.source->tremolo_type == "stop") { x0 = notation_x; x1 = n.stem_x; }
|
||||
for (int mark = 0; mark < n.source->tremolo_marks; ++mark) {
|
||||
for (auto mark = std::int32_t{}; mark < n.source->tremolo_marks; ++mark) {
|
||||
auto y = n.stem_tip_y + (n.stem_up ? 1.0F : -1.0F) * spacing * (1.0F + mark*0.8F);
|
||||
add_stroke_line(layout, vamp_zero::score_layout_item_role::TREMOLO, {.x=x0,.y=y+spacing*0.3F},
|
||||
{.x=x1,.y=y-spacing*0.3F}, spacing*0.45F, score_ink(), system_index, measure_index, n.note_index);
|
||||
|
||||
Reference in New Issue
Block a user