Пример #1
0
void SelectBoxState::postRenderDecorator(EditorPostRender* render)
{
    Editor* editor = render->getEditor();
    render::Zoom zoom = editor->zoom();
    gfx::Rect vp = View::getView(editor)->getViewportBounds();
    vp.w += zoom.apply(1);
    vp.h += zoom.apply(1);
    vp = editor->screenToEditor(vp);

    // Paint a grid generated by the box
    if (hasFlag(GRID)) {
        gfx::Color gridColor = gfx::rgba(100, 200, 100);
        gfx::Rect boxBounds = getBoxBounds();

        if (boxBounds.w > 0)
            for (int x=boxBounds.x+boxBounds.w*2; x<vp.x+vp.w; x+=boxBounds.w)
                render->drawLine(x, boxBounds.y, x, vp.y+vp.h-1, gridColor);

        if (boxBounds.h > 0)
            for (int y=boxBounds.y+boxBounds.h*2; y<vp.y+vp.h; y+=boxBounds.h)
                render->drawLine(boxBounds.x, y, vp.x+vp.w-1, y, gridColor);
    }

    // Draw the rulers enclosing the box
    if (hasFlag(RULERS)) {
        gfx::Color rulerColor = gfx::rgba(0, 0, 255);

        for (Rulers::iterator it = m_rulers.begin(), end = m_rulers.end(); it != end; ++it) {
            switch (it->getOrientation()) {

            case Ruler::Horizontal:
                render->drawLine(vp.x, it->getPosition(), vp.x+vp.w-1, it->getPosition(), rulerColor);
                break;

            case Ruler::Vertical:
                render->drawLine(it->getPosition(), vp.y, it->getPosition(), vp.y+vp.h-1, rulerColor);
                break;
            }
        }
    }

    if (hasFlag(QUICKBOX)) {
        render->drawRectXor(getBoxBounds());
    }
}
Пример #2
0
void SelectBoxState::postRenderDecorator(EditorPostRender* render)
{
  Editor* editor = render->getEditor();
  int zoom = editor->getZoom();
  gfx::Rect vp = View::getView(editor)->getViewportBounds();

  vp.w += 1<<zoom;
  vp.h += 1<<zoom;
  editor->screenToEditor(vp, &vp);

  // Paint a grid generated by the box
  if (hasPaintFlag(PaintGrid)) {
    int gridColor = makecol(100, 200, 100);
    gfx::Rect boxBounds = getBoxBounds();

    if (boxBounds.w > 0)
      for (int x=boxBounds.x+boxBounds.w*2; x<vp.x+vp.w; x+=boxBounds.w)
        render->drawLine(x, boxBounds.y, x, vp.y+vp.h-1, gridColor);

    if (boxBounds.h > 0)
      for (int y=boxBounds.y+boxBounds.h*2; y<vp.y+vp.h; y+=boxBounds.h)
        render->drawLine(boxBounds.x, y, vp.x+vp.w-1, y, gridColor);
  }

  // Draw the rulers enclosing the box
  if (hasPaintFlag(PaintRulers)) {
    int rulerColor = makecol(0, 0, 255);

    for (Rulers::iterator it = m_rulers.begin(), end = m_rulers.end(); it != end; ++it) {
      switch (it->getOrientation()) {

        case Ruler::Horizontal:
          render->drawLine(vp.x, it->getPosition(), vp.x+vp.w-1, it->getPosition(), rulerColor);
          break;

        case Ruler::Vertical:
          render->drawLine(it->getPosition(), vp.y, it->getPosition(), vp.y+vp.h-1, rulerColor);
          break;
      }
    }
  }
}