コード例 #1
1
ファイル: text.cpp プロジェクト: aeliot/MuseScore
void Text::layout1()
      {
      if (styled() && !_editMode)
            SimpleText::layout();
      else {
            _doc->setDefaultFont(textStyle().font(spatium()));
            qreal w = -1.0;
            QPointF o(textStyle().offset(spatium()));

            if (parent() && layoutToParentWidth()) {
                  Element* e = parent();
                  w = e->width();
                  if (e->type() == HBOX || e->type() == VBOX || e->type() == TBOX) {
                        Box* b = static_cast<Box*>(e);
                        w -= ((b->leftMargin() + b->rightMargin()) * MScore::DPMM);
                        }
                  }

            QTextOption to = _doc->defaultTextOption();
            to.setUseDesignMetrics(true);
            to.setWrapMode(w <= 0.0 ? QTextOption::NoWrap : QTextOption::WrapAtWordBoundaryOrAnywhere);
            _doc->setDefaultTextOption(to);

            if (w <= 0.0)
                  w = _doc->idealWidth();
            _doc->setTextWidth(w);

            QSizeF size(_doc->size());

            if (align() & ALIGN_BOTTOM)
                  o.ry() -= size.height();
            else if (align() & ALIGN_VCENTER)
                  o.ry() -= (size.height() * .5);
            else if (align() & ALIGN_BASELINE)
                  o.ry() -= baseLine();

            if (align() & ALIGN_RIGHT)
                  o.rx() -= size.width();
            else if (align() & ALIGN_HCENTER)
                  o.rx() -= (size.width() * .5);

            setbbox(QRectF(QPointF(0.0, 0.0), size));
            _doc->setModified(false);
            setPos(o);
            }
      if (parent()) {
            Element* e = parent();
            qreal w, h, xo, yo;
            if (layoutToParentWidth()) {
                  if (e->type() == HBOX || e->type() == VBOX || e->type() == TBOX) {
                        // consider inner margins of frame
                        Box* b = static_cast<Box*>(e);
                        xo = b->leftMargin() * MScore::DPMM;
                        yo = b->topMargin()  * MScore::DPMM;
                        w  = b->width()  - xo - b->rightMargin() * MScore::DPMM;
                        h  = b->height() - yo - b->bottomMargin()   * MScore::DPMM;
                        }
                  else {
                        w  = e->width();
                        h  = e->height();
                        xo = 0.0;
                        yo = 0.0;
                        }
                  QPointF ro(_textStyle.reloff() * .01);
                  rxpos() += xo + ro.x() * w;
                  rypos() += yo + ro.y() * h;
                  }
            if (e->type() == SEGMENT) {
                  Segment* s = static_cast<Segment*>(e);
                  rypos() += s->measure()->system()->staff(staffIdx())->y();
                  }
            }

      if (hasFrame())
            layoutFrame();
      }
コード例 #2
0
ファイル: SquareRootElement.cpp プロジェクト: KDE/calligra
void SquareRootElement::layout( const AttributeManager* am )
{
    RowElement::layout( am );

    qreal thinSpace = am->layoutSpacing( this );
    qreal symbolHeight = baseLine();
    if( height() > symbolHeight*1.3 ) symbolHeight = height();
    symbolHeight += thinSpace;
    qreal tickWidth = symbolHeight / 3.0;

    m_lineThickness = am->lineThickness(this);

    // Set the sqrt dimensions 
    QPointF childOffset( tickWidth + thinSpace, thinSpace + m_lineThickness );

    setWidth( width() + childOffset.x());
    setHeight( height() + childOffset.y());
    setBaseLine( baseLine() + childOffset.y());

    // Adapt the children's positions to the new offset
    foreach( BasicElement* element, childElements() )
        element->setOrigin( element->origin() + childOffset );

    QRectF rect = childrenBoundingRect();
    rect.translate(childOffset);
    setChildrenBoundingRect(rect);

    // Draw the sqrt symbol into a QPainterPath as buffer
    m_rootSymbol = QPainterPath();
    m_rootSymbol.moveTo( m_lineThickness, 2.0 * symbolHeight / 3.0 );
    m_rootSymbol.lineTo( 0 + tickWidth/2.0, symbolHeight-m_lineThickness/2 );
    m_rootSymbol.lineTo( 0 + tickWidth, m_lineThickness/2 );
    m_rootSymbol.lineTo( width() - m_lineThickness/2, m_lineThickness/2 );

}
コード例 #3
0
void SquareRootElement::layout( const AttributeManager* am )
{
    RowElement::layout( am );

    kDebug(39001) << "Width: " << width();
    kDebug(39001) << "Height: " << height();

    double thinSpace = am->layoutSpacing( this );
    double linethickness = 1;
    double symbolHeight = baseLine();
    if( height() > symbolHeight*1.3 ) symbolHeight = height();
    symbolHeight += thinSpace;
    double tickWidth = symbolHeight / 3.0;

    // Set the sqrt dimensions 
    setWidth( tickWidth + width() + thinSpace );
    setHeight( height() + thinSpace );
    setBaseLine( baseLine() + thinSpace );
   
    // Adapt the children's positions to the new offset
    QPointF childOffset( tickWidth + thinSpace, thinSpace );
    foreach( BasicElement* element, childElements() )
        element->setOrigin( element->origin() + childOffset );

    // Draw the sqrt symbol into a QPainterPath as buffer
    m_rootSymbol = QPainterPath();
    m_rootSymbol.moveTo( linethickness, 2.0 * symbolHeight / 3.0 );
    m_rootSymbol.lineTo( 0 + tickWidth/2.0, symbolHeight-linethickness/2 );
    m_rootSymbol.lineTo( 0 + tickWidth, linethickness/2 );
    m_rootSymbol.lineTo( width() - linethickness/2, linethickness/2 );

}
コード例 #4
0
ファイル: text.cpp プロジェクト: guifre2/MuseScore
QLineF Text::dragAnchor() const
      {
      QPointF p1;

      if (parent()->type() == MEASURE) {
            Measure* m     = static_cast<Measure*>(parent());
            System* system = m->system();
            qreal yp       = system->staff(staffIdx())->y() + system->y() + system->page()->pos().x();
            qreal xp       = m->canvasPos().x(); // m->tick2pos(tick()) + m->canvasPos().x();
            p1 = QPointF(xp, yp);
            }
      else {
            p1 = QPointF(parent()->canvasBoundingRect().topLeft());
            if (parent()->type() == SEGMENT) {
                  Segment* s = static_cast<Segment*>(parent());
                  p1.ry() += s ? s->measure()->system()->staff(staffIdx())->y() : 0.0;
                  }
            }
      qreal tw = width();
      qreal th = height();
      qreal x  = 0.0;
      qreal y  = 0.0;
      if (align() & ALIGN_BOTTOM)
            y = th;
      else if (align() & ALIGN_VCENTER)
            y = (th * .5);
      else if (align() & ALIGN_BASELINE)
            y = baseLine();
      if (align() & ALIGN_RIGHT)
            x = tw;
      else if (align() & ALIGN_HCENTER)
            x = (tw * .5);
      return QLineF(p1, canvasBoundingRect().topLeft() + QPointF(x, y));
      }
コード例 #5
0
ファイル: fret.cpp プロジェクト: gthomas/MuseScore
QLineF FretDiagram::dragAnchor() const
      {
      Measure* m     = measure();
      System* system = m->system();
      qreal yp      = system->staff(staffIdx())->y() + system->y();
      qreal xp      = m->tick2pos(segment()->tick()) + m->pagePos().x();
      QPointF p1(xp, yp);

      qreal x  = 0.0;
      qreal y  = 0.0;
#if 0 // TODOxx
      qreal tw = width();
      qreal th = height();
      if (_align & ALIGN_BOTTOM)
            y = th;
      else if (_align & ALIGN_VCENTER)
            y = (th * .5);
      else if (_align & ALIGN_BASELINE)
            y = baseLine();
      if (_align & ALIGN_RIGHT)
            x = tw;
      else if (_align & ALIGN_HCENTER)
            x = (tw * .5);
#endif
      return QLineF(p1, abbox().topLeft() + QPointF(x, y));
      }
コード例 #6
0
ファイル: fret.cpp プロジェクト: JessicaWhite17/MuseScore
QLineF FretDiagram::dragAnchor() const
      {
      if (parent()->type() == Element::Type::SEGMENT) {
            Segment* s     = static_cast<Segment*>(parent());
            Measure* m     = s->measure();
            System* system = m->system();
            qreal yp      = system->staff(staffIdx())->y() + system->y();
            qreal xp      = m->tick2pos(s->tick()) + m->pagePos().x();
            QPointF p1(xp, yp);

            qreal x  = 0.0;
            qreal y  = 0.0;
#if 0 // TODOxx
            qreal tw = width();
            qreal th = height();
            if (_align & AlignmentFlags::BOTTOM)
                  y = th;
            else if (_align & AlignmentFlags::VCENTER)
                  y = (th * .5);
            else if (_align & AlignmentFlags::BASELINE)
                  y = baseLine();
            if (_align & AlignmentFlags::RIGHT)
                  x = tw;
            else if (_align & AlignmentFlags::HCENTER)
                  x = (tw * .5);
#endif
            return QLineF(p1, abbox().topLeft() + QPointF(x, y));
            }
      return QLineF(parent()->pagePos(), abbox().topLeft());
      }
コード例 #7
0
bool SGMFastScanSettings::operator ==(const SGMFastScanSettings &other) const{
	if( fabs(runSeconds() - other.runSeconds()) < 0.01
			&& motorSettings() == other.motorSettings()
			&& fabs(scalerTime() - other.scalerTime()) < 0.01
			&& baseLine() == other.baseLine()
			&& undulatorVelocity() == other.undulatorVelocity())
		return true;
	return false;
}
コード例 #8
0
ファイル: fret.cpp プロジェクト: emeraldimp/MuseScore
QLineF FretDiagram::dragAnchor() const
      {
      qreal xp = 0.0;
      for (Element* e = parent(); e; e = e->parent())
            xp += e->x();
      qreal yp;
      if (parent()->isSegment()) {
            System* system = toSegment(parent())->measure()->system();
            yp = system->staffCanvasYpage(staffIdx());
            }
      else
            yp = parent()->canvasPos().y();
      QPointF p1(xp, yp);
      return QLineF(p1, canvasPos());
#if 0 // TODOxx
      if (parent()->type() == ElementType::SEGMENT) {
            Segment* s     = toSegment(parent());
            Measure* m     = s->measure();
            System* system = m->system();
            qreal yp      = system->staff(staffIdx())->y() + system->y();
            qreal xp      = m->tick2pos(s->tick()) + m->pagePos().x();
            QPointF p1(xp, yp);

            qreal x  = 0.0;
            qreal y  = 0.0;
            qreal tw = width();
            qreal th = height();
            if (_align & Align::BOTTOM)
                  y = th;
            else if (_align & Align::VCENTER)
                  y = (th * .5);
            else if (_align & Align::BASELINE)
                  y = baseLine();
            if (_align & Align::RIGHT)
                  x = tw;
            else if (_align & Align::HCENTER)
                  x = (tw * .5);
            return QLineF(p1, abbox().topLeft() + QPointF(x, y));
            }
      return QLineF(parent()->pagePos(), abbox().topLeft());
#endif
      }
コード例 #9
0
bool SGMFastScanParameters::operator ==(const SGMFastScanParameters &other){
	if( element() == other.element() &&
		runSeconds() == other.runSeconds() &&
		energyStart() == other.energyStart() &&
		energyMidpoint() == other.energyMidpoint() &&
		energyEnd() == other.energyEnd() &&
		velocity() == other.velocity() &&
		velocityBase() == other.velocityBase() &&
		acceleration() == other.acceleration() &&
		scalerTime() == other.scalerTime() &&
		baseLine() == other.baseLine() &&
		undulatorStartStep() == other.undulatorStartStep() &&
		undulatorVelocity() == other.undulatorVelocity() &&
		undulatorRelativeStep() == other.undulatorRelativeStep() &&
		exitSlitDistance() == other.exitSlitDistance() &&
		sgmGrating() == other.sgmGrating()){
		return true;
	}
	return false;
}
コード例 #10
0
ファイル: symbol.cpp プロジェクト: IsaacWeiss/MuseScore
void Symbol::layout()
      {
      // foreach(Element* e, leafs())     done in BSymbol::layout() ?
      //      e->layout();
      setbbox(_scoreFont ? _scoreFont->bbox(_sym, magS()) : symBbox(_sym));
      QPointF o(offset());
      qreal w = width();
      QPointF p;
      if (align() & Align::BOTTOM)
            p.setY(- height());
      else if (align() & Align::VCENTER)
            p.setY((- height()) * .5);
      else if (align() & Align::BASELINE)
            p.setY(-baseLine());
      if (align() & Align::RIGHT)
            p.setX(-w);
      else if (align() & Align::HCENTER)
            p.setX(-(w * .5));
      setPos(p);
      BSymbol::layout();
      }