Example #1
0
void ResizableLayout::resizeStart() {
  bool haveChildren = false;

  // first recursively call resizeStart() on all children
  for (int i = 0; i < m_anchors.size(); i++) {
    ResizableChild* child = m_anchors.getUnchecked(i).child;
    if (child) {
      child->resizeStart();
      haveChildren = true;
    }
  }

  // now check our immediate children for constraints
  if (haveChildren) {
      // start with our values
    int xmin0 = getMinimumWidth();
    int ymin0 = getMinimumHeight();

    // for each child, use the inverse of the resize function to solve for the min/max
    for (int i = 0; i < m_anchors.size(); i++) {
      Anchor anchor = m_anchors.getUnchecked(i);
      if (anchor.child) {
        State state = m_states.getUnchecked(i);
        jassert(anchor.component == state.component);

        int xmin1 = anchor.child->getMinimumWidth();
        int ymin1 = anchor.child->getMinimumHeight();
        //int xmax1 = anchor.child->getMaximumWidth();
        //int ymax1 = anchor.child->getMaximumHeight();

        // invert the sauce
        int d; // anchor difference
        int m; // solution to f'(x)

        d = anchor.bottomRight.getX() - anchor.topLeft.getX();
        if (d != 0) {
          m = (xmin1 + state.margin.left - state.margin.right) * anchorUnit / d;
          xmin0 = jmax(xmin0, m);
        }

        d = anchor.bottomRight.getY() - anchor.topLeft.getY();
        if (d != 0) {
          m = (ymin1 + state.margin.top - state.margin.bottom) * anchorUnit / d;
          ymin0 = jmax(ymin0, m);
        }
      }
    }

    // apply adjusted limits
    setMinimumWidth(xmin0);
    setMinimumHeight(ymin0);
  }
}
bool DetViewMultiLineRenderer::isOnAnnotationLine(const QPoint &p, Annotation *a, int region, const AnnotationSettings *as, const QSize &canvasSize, const U2Region& visibleRange) const {
    qint64 symbolsPerLine = getSymbolsPerLine(canvasSize.width());
    QSize oneLineMinSize(canvasSize.width(), getMinimumHeight());
    U2Region yRange = singleLinePainter->getAnnotationYRange(a, region, as, oneLineMinSize,
                                                            U2Region(visibleRange.startPos, qMin(visibleRange.length, symbolsPerLine)));
    yRange.startPos += (INDENT_BETWEEN_LINES + extraIndent) / 2;
    do {
        if (yRange.contains(p.y())) {
            return true;
        }
        yRange.startPos += getOneLineHeight();
    } while (canvasSize.height() > yRange.endPos());

    return false;
}
void OsuUISongBrowserInfoLabel::draw(Graphics *g)
{
	// debug bounding box
	if (m_osu_debug_ref->getBool())
	{
		g->setColor(0xffff0000);
		g->drawLine(m_vPos.x, m_vPos.y, m_vPos.x+m_vSize.x, m_vPos.y);
		g->drawLine(m_vPos.x, m_vPos.y, m_vPos.x, m_vPos.y+m_vSize.y);
		g->drawLine(m_vPos.x, m_vPos.y+m_vSize.y, m_vPos.x+m_vSize.x, m_vPos.y+m_vSize.y);
		g->drawLine(m_vPos.x+m_vSize.x, m_vPos.y, m_vPos.x+m_vSize.x, m_vPos.y+m_vSize.y);
	}

	// build strings
	const UString titleText = buildTitleString();
	const UString subTitleText = buildSubTitleString();
	const UString songInfoText = buildSongInfoString();
	const UString diffInfoText = buildDiffInfoString();
	const UString offsetInfoText = buildOffsetInfoString();

	const float globalScale = std::max((m_vSize.y / getMinimumHeight())*0.7f, 1.0f);

	int yCounter = m_vPos.y;

	// draw title
	g->setColor(0xffffffff);
	g->pushTransform();
	{
		const float scale = m_fTitleScale*globalScale;

		yCounter += m_font->getHeight()*scale;

		g->scale(scale, scale);
		g->translate((int)(m_vPos.x), yCounter);
		g->drawString(m_font, titleText);
	}
	g->popTransform();

	// draw subtitle (mapped by)
	g->setColor(0xffffffff);
	g->pushTransform();
	{
		const float scale = m_fSubTitleScale*globalScale;

		yCounter += m_font->getHeight()*scale + m_iMargin*globalScale*1.0f;

		g->scale(scale, scale);
		g->translate((int)(m_vPos.x), yCounter);
		g->drawString(m_font, subTitleText);
	}
	g->popTransform();

	// draw song info (length, bpm, objects)
	g->setColor(0xffffffff);
	if (m_osu->getSpeedMultiplier() != 1.0f)
		g->setColor(m_osu->getSpeedMultiplier() > 1.0f ? 0xffff7f7f : 0xffadd8e6);

	g->pushTransform();
	{
		const float scale = m_fSongInfoScale*globalScale*0.9f;

		yCounter += m_font->getHeight()*scale + m_iMargin*globalScale*1.0f;

		g->scale(scale, scale);
		g->translate((int)(m_vPos.x), yCounter);
		g->drawString(m_font, songInfoText);
	}
	g->popTransform();

	// draw diff info (CS, AR, OD, HP, Stars)
	g->setColor(m_osu->getModEZ() ? 0xffadd8e6 : (m_osu->getModHR() ? 0xffff7f7f : 0xffffffff));
	g->pushTransform();
	{
		const float scale = m_fDiffInfoScale*globalScale*0.9f;

		yCounter += m_font->getHeight()*scale + m_iMargin*globalScale*0.85f;

		g->scale(scale, scale);
		g->translate((int)(m_vPos.x), yCounter);
		g->drawString(m_font, diffInfoText);
	}
	g->popTransform();

	// draw offset (local, online)
	if (m_iLocalOffset != 0 || m_iOnlineOffset != 0)
	{
		g->setColor(0xffffffff);
		g->pushTransform();
		{
			const float scale = m_fOffsetInfoScale*globalScale*0.8f;

			yCounter += m_font->getHeight()*scale + m_iMargin*globalScale*0.85f;

			g->scale(scale, scale);
			g->translate((int)(m_vPos.x), yCounter);
			g->drawString(m_font, offsetInfoText);
		}
		g->popTransform();
	}
}