예제 #1
0
bool SelectBoxState::onSetCursor(Editor* editor)
{
  if (m_movingRuler >= 0) {
    switch (m_rulers[m_movingRuler].getOrientation()) {
      case Ruler::Horizontal: jmouse_set_cursor(kSizeTCursor); return true;
      case Ruler::Vertical: jmouse_set_cursor(kSizeLCursor); return true;
    }
  }

  int x = jmouse_x(0);
  int y = jmouse_y(0);

  for (Rulers::iterator it = m_rulers.begin(), end = m_rulers.end(); it != end; ++it) {
    if (touchRuler(editor, *it, x, y)) {
      switch (it->getOrientation()) {
        case Ruler::Horizontal:
          jmouse_set_cursor(kSizeTCursor);
          return true;
        case Ruler::Vertical:
          jmouse_set_cursor(kSizeLCursor);
          return true;
      }
    }
  }

  return false;
}
예제 #2
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());
    }
}
예제 #3
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;
      }
    }
  }
}
예제 #4
0
bool SelectBoxState::onSetCursor(Editor* editor, const gfx::Point& mouseScreenPos)
{
    if (hasFlag(RULERS)) {
        if (m_movingRuler >= 0) {
            switch (m_rulers[m_movingRuler].getOrientation()) {

            case Ruler::Horizontal:
                editor->showMouseCursor(kSizeNSCursor);
                return true;

            case Ruler::Vertical:
                editor->showMouseCursor(kSizeWECursor);
                return true;
            }
        }

        for (Rulers::iterator it = m_rulers.begin(), end = m_rulers.end(); it != end; ++it) {
            if (touchRuler(editor, *it, mouseScreenPos.x, mouseScreenPos.y)) {
                switch (it->getOrientation()) {
                case Ruler::Horizontal:
                    editor->showMouseCursor(kSizeNSCursor);
                    return true;
                case Ruler::Vertical:
                    editor->showMouseCursor(kSizeWECursor);
                    return true;
                }
            }
        }
    }

    if (!requireBrushPreview()) {
        editor->showMouseCursor(kArrowCursor);
        return true;
    }

    return StandbyState::onSetCursor(editor, mouseScreenPos);
}