本文整理汇总了C++中SysStaff::y方法的典型用法代码示例。如果您正苦于以下问题:C++ SysStaff::y方法的具体用法?C++ SysStaff::y怎么用?C++ SysStaff::y使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SysStaff
的用法示例。
在下文中一共展示了SysStaff::y方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: move
void PositionCursor::move(int tick)
{
QRectF r(bbox());
//
// set mark height for whole system
//
if (_type == CursorType::LOOP_OUT)
tick --;
Score* score = _sv->score();
Measure* measure = score->tick2measureMM(tick);
if (measure == 0)
return;
qreal x;
int offset = 0;
Segment* s;
for (s = measure->first(Segment::Type::ChordRest); s;) {
int t1 = s->tick();
int x1 = s->canvasPos().x();
qreal x2;
int t2;
Segment* ns = s->next(Segment::Type::ChordRest);
if (ns) {
t2 = ns->tick();
x2 = ns->canvasPos().x();
}
else {
t2 = measure->endTick();
x2 = measure->canvasPos().x() + measure->width();
}
t1 += offset;
t2 += offset;
if (tick >= t1 && tick < t2) {
int dt = t2 - t1;
qreal dx = x2 - x1;
x = x1 + dx * (tick-t1) / dt;
break;
}
s = ns;
}
if (s == 0)
return;
System* system = measure->system();
if (system == 0)
return;
double y = system->staffYpage(0) + system->page()->pos().y();
double _spatium = score->spatium();
qreal mag = _spatium / (MScore::DPI * SPATIUM20);
double w = (_spatium * 2.0 + score->scoreFont()->width(SymId::noteheadBlack, mag))/3;
double h = 6 * _spatium;
//
// set cursor height for whole system
//
double y2 = 0.0;
for (int i = 0; i < score->nstaves(); ++i) {
SysStaff* ss = system->staff(i);
if (!ss->show() || !score->staff(i)->show())
continue;
y2 = ss->y() + ss->bbox().height();
}
h += y2;
y -= 3 * _spatium;
if (_type == CursorType::LOOP_IN) {
x = x - _spatium + w/1.5;
}
else {
x = x - _spatium * .5;
}
_tick = tick;
_rect = QRectF(x, y, w, h);
_sv->update(_sv->matrix().mapRect(r | bbox()).toRect().adjusted(-1,-1,1,1));
}
示例2: paint
void ContinuousPanel::paint(const QRect&, QPainter& painter)
{
qreal _offsetPanel = 0;
qreal _y = 0;
qreal _oldWidth = 0; // The last final panel width
qreal _newWidth = 0; // New panel width
qreal _height = 0;
qreal _leftMarginTotal = 0; // Sum of all elments left margin
qreal _panelRightPadding = 5; // Extra space for the panel after last element
Measure* measure = _score->firstMeasure();
if (!_active || !measure) {
_visible = false;
return;
}
if (measure->mmRest()) {
measure = measure->mmRest();
}
System* system = measure->system();
if (system == 0) {
_visible = false;
return;
}
Segment* s = measure->first();
double _spatium = _score->spatium();
if (_width <= 0)
_width = s->x();
//
// Set panel height for whole system
//
_height = 6 * _spatium;
_y = system->staffYpage(0) + system->page()->pos().y();
double y2 = 0.0;
for (int i = 0; i < _score->nstaves(); ++i) {
SysStaff* ss = system->staff(i);
if (!ss->show() || !_score->staff(i)->show())
continue;
y2 = ss->y() + ss->bbox().height();
}
_height += y2 + 6*_spatium;
_y -= 6 * _spatium;
//
// Check elements at current panel position
//
_offsetPanel = -(_sv->xoffset()) / _sv->mag();
_rect = QRect(_offsetPanel + _width, _y, 1, _height);
Page* page = _score->pages().front();
QList<Element*> el = page->items(_rect);
if (el.empty()) {
_visible = false;
return;
}
qStableSort(el.begin(), el.end(), elementLessThan);
const Measure*_currentMeasure = 0;
for (const Element* e : el) {
e->itemDiscovered = 0;
if (!e->visible() && !_score->showInvisible())
continue;
if (e->isMeasure()) {
_currentMeasure = toMeasure(e);
break;
}
}
if (!_currentMeasure)
return;
// Don't show panel if staff names are visible
if (_currentMeasure == _score->firstMeasure() && _sv->toPhysical(_currentMeasure->canvasPos()).x() > 0) {
_visible = false;
return;
}
qreal _xPosMeasure = _currentMeasure->canvasX();
qreal _measureWidth = _currentMeasure->width();
int tick = _currentMeasure->tick();
Fraction _currentTimeSig = _currentMeasure->timesig();
//qDebug() << "_sv->xoffset()=" <<_sv->xoffset() << " _sv->mag()="<< _sv->mag() <<" s->x=" << s->x() << " width=" << _width << " currentMeasure=" << _currentMeasure->x() << " _xPosMeasure=" << _xPosMeasure;
//---------------------------------------------------------
// findElementWidths
// determines the max width for each element types
//---------------------------------------------------------
// The first pass serves to get the maximum width for each elements
qreal lineWidthName = 0;
qreal _widthClef = 0;
qreal _widthKeySig = 0;
qreal _widthTimeSig = 0;
qreal _xPosTimeSig = 0;
for (const Element* e : el) {
//.........这里部分代码省略.........
示例3: paint
void ContinuousPanel::paint(const QRect& /*r*/, QPainter& p)
{
if (!_active) {
_visible = false;
return;
}
Measure* measure = _score->tick2measure(0);
if (measure == 0){
_visible = false;
return;
}
if (measure->mmRest()) {
measure = measure->mmRest();
_mmRestCount = measure->mmRestCount();
}
System* system = measure->system();
if (system == 0) {
_visible = false;
return;
}
Segment* s = _score->tick2segment(0);
double _spatium = _score->spatium();
_x = 0;
if (_width <= 0)
_width = s->x();
//
// Set panel height for whole system
//
_height = 6 * _spatium;
_y = system->staffYpage(0) + system->page()->pos().y();
double y2 = 0.0;
for (int i = 0; i < _score->nstaves(); ++i) {
SysStaff* ss = system->staff(i);
if (!ss->show() || !_score->staff(i)->show())
continue;
y2 = ss->y() + ss->bbox().height();
}
_height += y2 + 6*_spatium;
_y -= 6 * _spatium;
//
// Check elements at current panel position
//
_offsetPanel = -(_sv->xoffset()) / _sv->pmag();
_rect = QRect(_offsetPanel + _width, _y, 1, _height);
//qDebug() << "width=" << _width << "_y="<< _y << "_offsetPanel=" << _offsetPanel << "_sv->xoffset()" << _sv->xoffset() << "_sv->pmag()" << _sv->pmag() <<"_spatium" << _spatium << "s->canvasPos().x()" << s->canvasPos().x() << "s->x()" << s->x();
Page* page = _score->pages().front();
QList<Element*> elementsCurrent = page->items(_rect);
if (elementsCurrent.empty()) {
_visible = false;
return;
}
qStableSort(elementsCurrent.begin(), elementsCurrent.end(), elementLessThan);
_currentMeasure = nullptr;
for (const Element* e : elementsCurrent) {
e->itemDiscovered = 0;
if (!e->visible()) {
if (_score->printing() || !_score->showInvisible())
continue;
}
if (e->type() == Element::Type::MEASURE) {
_currentMeasure = static_cast<const Measure*>(e);
_currentTimeSig = _currentMeasure->timesig();
_currentMeasureTick = _currentMeasure->tick();
_currentMeasureNo = _currentMeasure->no();
// Find number of multi measure rests to display in the panel
if (_currentMeasure->isMMRest())
_mmRestCount = _currentMeasure->mmRestCount();
else if (_currentMeasure->mmRest())
_mmRestCount = _currentMeasure->mmRest()->mmRestCount();
else
_mmRestCount = 0;
_xPosMeasure = e->canvasX();
_measureWidth = e->width();
break;
}
}
if (_currentMeasure == nullptr)
return;
findElementWidths(elementsCurrent);
// Don't show panel if staff names are visible
if (_sv->xoffset() / _sv->pmag() + _xPosMeasure > 0) {
_visible = false;
return;
}
//qDebug() << "_sv->xoffset()=" <<_sv->xoffset() << " _sv->pmag()="<< _sv->pmag() <<" s->x=" << s->x() << " width=" << _width << " currentMeasue=" << _currentMeasure->x() << " _xPosMeasure=" << _xPosMeasure;
draw(p, elementsCurrent);
_visible = true;
}