Esempio n. 1
0
File: main.c Progetto: Aiur/Airtab
bool execCommand(Command *cmd) {
    double x, y;
    int key;
    if (strcmp(cmd->cmd, "mm") == 0) {
        x = strtod(cmd->arg1, NULL);
        y = strtod(cmd->arg2, NULL);
        mousemove(x, y);
        return true;
    } else if (strcmp(cmd->cmd, "kd") == 0) {
        key = (int) strtol(cmd->arg1, NULL, 10);
        keydown(key);
    } else if (strcmp(cmd->cmd, "ku") == 0) {
        key = (int)strtol(cmd->arg1, NULL, 10);
        keyup(key);
    } else if (strcmp(cmd->cmd, "md") == 0) {
        mousedown(cmd->arg1[0]);
    } else if (strcmp(cmd->cmd, "mu") == 0) {
        mouseup(cmd->arg1[0]);
    } else if (strcmp(cmd->cmd, "sy") == 0) {
        scrollY(strtod(cmd->arg1, NULL));
    } else if (strcmp(cmd->cmd, "sx") == 0) {
        scrollX(strtod(cmd->arg1, NULL));
    }
    
    return false;
}
Esempio n. 2
0
/**
 * @brief Called when the user wheel the mouse over the node
 */
bool uiMaterialEditorNode::onScroll (uiNode_t* node, int deltaX, int deltaY)
{
	bool down = deltaY > 0;
	const int diff = (down) ? 1 : -1;
	if (deltaY == 0)
		return false;
	return scrollY(node, diff);
}
Esempio n. 3
0
void ScrollView::platformRepaintContentRectangle(const IntRect& updateRect, bool now)
{
    // we need to convert coordinates to scrolled position
    wxRect contentsRect = updateRect;
    contentsRect.Offset(-scrollX(), -scrollY());
    wxWindow* win = platformWidget();
    if (win) {
        win->RefreshRect(contentsRect, true);
        if (now)
            win->Update();
    }
}
Esempio n. 4
0
void uiTextNode::onCapturedMouseMove (uiNode_t* node, int x, int y)
{
	const int lineHeight = getCellHeight(node);
	const int deltaY = (mouseScrollY - y) / lineHeight;
	/* We're doing only vertical scroll, that's enough for the most instances */
	if (abs(mouseScrollY - y) >= lineHeight) {
		scrollY(node, deltaY);
		/* @todo not accurate */
		mouseScrollX = x;
		mouseScrollY = y;
	}
	onMouseMove(node, x, y);
}
Esempio n. 5
0
void LevelEditor::selectObjectAtIndex(int index) {
  previewScene_.selectObjectAtIndex(index);
  
//  if ((toolManager_.objectEditorSingleGroupIt()->xPos())
//        > (scrollX_ + 50)) {
    setScrollX(toolManager_.objectEditorSingleGroupIt()
                 ->xPos() - (300 / scale()));
    if (scrollX() < 0) {
      setScrollX(0);
    }
    
    setScrollY(toolManager_.objectEditorSingleGroupIt()
                 ->yPos() - (300 / scale()));
    if (scrollY() < 0) {
      setScrollY(0);
    }
//  }
}
Esempio n. 6
0
bool LevelEditor::editAndAppendObject() {
  bool result = previewScene_.editAndAppendObject();
  
  if (result) {
    setScrollX(toolManager_.objectEditorSingleGroupIt()
                 ->xPos() - (300 / scale()));
    if (scrollX() < 0) {
      setScrollX(0);
    }
    
    setScrollY(toolManager_.objectEditorSingleGroupIt()
                 ->yPos() - (300 / scale()));
    if (scrollY() < 0) {
      setScrollY(0);
    }
  }
  
  return result;
}
Esempio n. 7
0
bool uiTextNode::onScroll (uiNode_t* node, int deltaX, int deltaY)
{
	bool updated;
	bool down = deltaY > 0;
	if (deltaY == 0)
		return false;
	updated = scrollY(node, (down ? 1 : -1));

	/* @todo use super behaviour */
	if (node->onWheelUp && !down) {
		UI_ExecuteEventActions(node, node->onWheelUp);
		updated = true;
	}
	if (node->onWheelDown && down) {
		UI_ExecuteEventActions(node, node->onWheelDown);
		updated = true;
	}
	if (node->onWheel) {
		UI_ExecuteEventActions(node, node->onWheel);
		updated = true;
	}
	return updated;
}
Esempio n. 8
0
void LevelEditor::drawPreviewGraphic(Graphic& dst) {
//  dst.copy(levelGraphicsData_.compressedGraphic(0).toGrayscaleGraphic(16),
//          Box(0, 0, 0, 0),
//          Graphic::noTransUpdate);

//  levelGraphicsData_.compressedGraphic(0).toGrayscaleGraphic(16)
//    .scale(dst,
//           Graphic::noTransUpdate);

  previewScene_.render(dst,
                       Box(scrollX(),
                           scrollY(),
                           dst.w() / scale(),
                           dst.h() / scale()),
                       scale());

/*  if ((needWrapCacheRefresh_)
      || (wrapScrollCache_.surface().w() != (int)(dst.w() / scale()))
      || (wrapScrollCache_.surface().h() != (int)(dst.h() / scale()))) {
    wrapScrollCache_ = WrapScrollGraphic(dst.w() / scale(),
                                         dst.h() / scale());
//    std::cout << wrapScrollCache_.surface().w() << " " << dst.w() << std::endl;
    previewScene_.render(dst,
                         wrapScrollCache_,
                         Box(scrollX_,
                             scrollY_,
                             dst.w() / scale(),
                             dst.h() / scale()),
                         scale());
    needWrapCacheRefresh_ = false;
    return;
  }
  
  if (lastRenderedScrollX_ != scrollX_) {
    wrapScrollCache_.scrollInX(scrollX_ - lastRenderedScrollX_);
    
    Box scrollBox(scrollX_, scrollY_,
                  scrollX_ - lastRenderedScrollX_,
                  wrapScrollCache_.surface().h());
    // If width is negative, adjust x-position and make width positive
    if (scrollBox.w() < 0) {
      scrollBox.setX(scrollBox.x() + scrollBox.w());
      scrollBox.setW(-(scrollBox.w()));
    }
  
    // Render changed columns
    previewScene_.render(dst,
                         wrapScrollCache_,
                         scrollBox,
                         scale());
  }
  
  if (lastRenderedScrollY_ != scrollY_) {
    wrapScrollCache_.scrollInY(scrollY_ - lastRenderedScrollY_);
    
    Box scrollBox(scrollX_, scrollY_,
                  wrapScrollCache_.surface().w(),
                  scrollY_ - lastRenderedScrollY_);
    // If height is negative, adjust y-position and make height positive
    if (scrollBox.h() < 0) {
      scrollBox.setY(scrollBox.y() + scrollBox.h());
      scrollBox.setH(-(scrollBox.h()));
    }
  
    // Render changed rows
    previewScene_.render(dst,
                         wrapScrollCache_,
                         scrollBox,
                         scale());
  }
                       
  lastRenderedScrollX_ = scrollX_;
  lastRenderedScrollY_ = scrollY_; */
}