mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-03-09 00:37:59 +01:00
49 lines
1.1 KiB
C++
49 lines
1.1 KiB
C++
#ifdef WINDOWS
|
|
#include "Tool_Use.h"
|
|
#include "Simulator.h"
|
|
#include "Shape.h"
|
|
#include "CursorManager.h"
|
|
#include "Controller_Base.h"
|
|
|
|
void Tool_Use::onMouseDown(const Coord &pos, int button) {
|
|
currentTarget = sim->getShapeUnderCursor();
|
|
prevPos = GetMousePos();
|
|
|
|
}
|
|
void Tool_Use::onMouseUp(const Coord &pos, int button) {
|
|
currentTarget = 0;
|
|
|
|
}
|
|
|
|
void Tool_Use::onEnd() {
|
|
sim->getCursorMgr()->setCursor(SDL_SYSTEM_CURSOR_ARROW);
|
|
}
|
|
void Tool_Use::drawTool() {
|
|
if (currentTarget) {
|
|
sim->getCursorMgr()->setCursor(SDL_SYSTEM_CURSOR_HAND);
|
|
}
|
|
else {
|
|
CShape *currentUnder = sim->getShapeUnderCursor();
|
|
if (currentUnder) {
|
|
sim->getCursorMgr()->setCursor(SDL_SYSTEM_CURSOR_HAND);
|
|
}
|
|
else {
|
|
sim->getCursorMgr()->setCursor(SDL_SYSTEM_CURSOR_ARROW);
|
|
}
|
|
}
|
|
if (currentTarget != 0) {
|
|
Coord curPos = GetMousePos();
|
|
Coord delta = curPos - prevPos;
|
|
prevPos = curPos;
|
|
CControllerBase *cntrl = currentTarget->getController();
|
|
if (cntrl != 0) {
|
|
if (sim->isMouseButtonHold(SDL_BUTTON_LEFT)) {
|
|
cntrl->sendEvent(EVE_LMB_HOLD, delta);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
#endif
|