Beispiel #1
0
void PreviewEditorWindow::onWindowResize()
{
  Window::onWindowResize();

  DocView* view = UIContext::instance()->activeView();
  if (view)
    updateUsingEditor(view->editor());
}
Beispiel #2
0
gfx::Point MoveThing::getDelta(Context* context) const
{
  gfx::Point delta(0, 0);

  DocView* view = static_cast<UIContext*>(context)->activeView();
  if (!view)
    return delta;

  DocumentPreferences& docPref = Preferences::instance().document(view->document());
  Editor* editor = view->editor();
  gfx::Rect vp = view->viewWidget()->viewportBounds();
  gfx::Rect gridBounds = docPref.grid.bounds();
  int pixels = 0;

  switch (units) {
    case Pixel:
      pixels = 1;
      break;
    case TileWidth:
      pixels = gridBounds.w;
      break;
    case TileHeight:
      pixels = gridBounds.h;
      break;
    case ZoomedPixel:
      pixels = editor->zoom().apply(1);
      break;
    case ZoomedTileWidth:
      pixels = editor->zoom().apply(gridBounds.w);
      break;
    case ZoomedTileHeight:
      pixels = editor->zoom().apply(gridBounds.h);
      break;
    case ViewportWidth:
      pixels = vp.h;
      break;
    case ViewportHeight:
      pixels = vp.w;
      break;
  }

  switch (direction) {
    case Left:  delta.x = -quantity * pixels; break;
    case Right: delta.x = +quantity * pixels; break;
    case Up:    delta.y = -quantity * pixels; break;
    case Down:  delta.y = +quantity * pixels; break;
  }

  return delta;
}