MCPcopy Create free account
hub / github.com/MyGUI/mygui / loadMouseRelative

Method loadMouseRelative

Tools/LayoutEditor/TextureControl.cpp:243–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241 }
242
243 void TextureControlLE::loadMouseRelative()
244 {
245 MyGUI::IntCoord viewCoord = mView->getViewCoord();
246 MyGUI::IntSize canvasSize = mView->getCanvasSize();
247 MyGUI::IntPoint mousePoint = MyGUI::InputManager::getInstance().getMousePositionByLayer();
248
249 // смещение мыши относительно вью
250 MyGUI::IntPoint mouseOffset = mousePoint - mView->getAbsolutePosition() - viewCoord.point();
251 // смещение нужной точки внутри текстуры в пикселях
252 MyGUI::IntPoint canvasPointOffset(
253 (int)(mMouseRelative.left * (float)canvasSize.width),
254 (int)(mMouseRelative.top * (float)canvasSize.height));
255 // смещение вью в пикселях
256 MyGUI::IntPoint canvasOffset = canvasPointOffset - mouseOffset;
257
258 mView->setViewOffset(MyGUI::IntPoint(-canvasOffset.left, -canvasOffset.top));
259 }
260
261 MyGUI::IntPoint TextureControlLE::getMousePosition()
262 {

Callers

nothing calls this directly

Calls 6

getViewCoordMethod · 0.80
getCanvasSizeMethod · 0.80
IntPointFunction · 0.50
pointMethod · 0.45
setViewOffsetMethod · 0.45

Tested by

no test coverage detected