|
From: Tapio V. <aa...@us...> - 2011-01-11 17:39:32
|
Module: editor
Branch: master
Commit: 21d02a728cbe8f78144d789057c9d2c116549ab5
Author: Tapio Vierros <tap...@gm...>
Date: Tue Jan 11 19:38:55 2011 +0200
Floating notes now use 90% note - 10% gap division.
Stretching now works both ways.
---
notegraphwidget.cc | 25 +++++++++----------------
1 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 988c7b3..3e05b09 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -129,35 +129,28 @@ void NoteGraphWidget::updateNotes()
} else {
// Fixed note encountered, handle the gap (divide notes evenly into it)
gap.end = child->x();
- int x = gap.begin;
- if (gap.width() >= gap.notesWidth()) {
- // Plenty of space - no resizing needed
- int step = (gap.width() - gap.notesWidth()) / (gap.notes.size() + 1);
- x += step;
- for (NoteLabels::iterator it2 = gap.notes.begin(); it2 != gap.notes.end(); ++it2) {
- (*it2)->move(x, (*it2)->y());
- x += step + (*it2)->width();
- }
-
- } else if (gap.width() <= gap.minWidth()) {
+ if (gap.width() <= gap.minWidth()) {
// We are at minimum width, enforce it
+ int x = gap.begin;
for (NoteLabels::iterator it2 = gap.notes.begin(); it2 != gap.notes.end(); ++it2) {
(*it2)->move(x, (*it2)->y());
(*it2)->resize(NoteLabel::min_width, (*it2)->height());
x += NoteLabel::min_width;
}
// FIXME: Enforcing fixed note position can be cheated by rapid mouse movement
- // Also, left & right side behaves differently
+ // Also, left & right side behave differently
child->move(gap.begin + gap.minWidth(), child->y());
} else {
- // Make the notes smaller so that they fit
- float sf = gap.width() / float(gap.notesWidth());
+ // Calculate position and size
+ int w = gap.width() / float(gap.notes.size()) * 0.9;
+ int step = (gap.width() - w * gap.notes.size()) / float(gap.notes.size() + 1);
+ int x = gap.begin + step;
for (NoteLabels::iterator it2 = gap.notes.begin(); it2 != gap.notes.end(); ++it2) {
(*it2)->move(x, (*it2)->y());
- (*it2)->resize((*it2)->width() * sf, (*it2)->height());
- x += (*it2)->width();
+ (*it2)->resize(w, (*it2)->height());
+ x += w + step;
}
}
|