| 112 | } |
| 113 | |
| 114 | void WorkspaceControl::notifyChangePosition() |
| 115 | { |
| 116 | if (!mMoveableWidget) |
| 117 | return; |
| 118 | |
| 119 | mCoordValue = mAreaSelectorControl->getCoord(); |
| 120 | |
| 121 | // конвертируем в локальные координаты |
| 122 | if (mCurrentWidget != nullptr) |
| 123 | { |
| 124 | MyGUI::Widget* parent = mCurrentWidget->getParent(); |
| 125 | if (parent != nullptr && !mCurrentWidget->isRootWidget()) |
| 126 | mCoordValue = mCoordValue - parent->getAbsolutePosition(); |
| 127 | } |
| 128 | |
| 129 | // снапим к гриду |
| 130 | if (!MyGUI::InputManager::getInstance().isShiftPressed()) |
| 131 | { |
| 132 | MyGUI::IntCoord coord = mCoordValue; |
| 133 | MyGUI::IntCoord actionScale = mAreaSelectorControl->getActionScale(); |
| 134 | |
| 135 | if (actionScale.left != 0 && actionScale.width != 0) |
| 136 | { |
| 137 | int right = coord.right(); |
| 138 | coord.left = GridManager::getInstance().toGrid(coord.left); |
| 139 | coord.width = right - coord.left; |
| 140 | } |
| 141 | else if (actionScale.width != 0) |
| 142 | { |
| 143 | int right = GridManager::getInstance().toGrid(coord.right()); |
| 144 | coord.width = right - coord.left; |
| 145 | } |
| 146 | else if (actionScale.left != 0) |
| 147 | { |
| 148 | coord.left = GridManager::getInstance().toGrid(coord.left); |
| 149 | } |
| 150 | |
| 151 | if (actionScale.top != 0 && actionScale.height != 0) |
| 152 | { |
| 153 | int bottom = coord.bottom(); |
| 154 | coord.top = GridManager::getInstance().toGrid(coord.top); |
| 155 | coord.height = bottom - coord.top; |
| 156 | } |
| 157 | else if (actionScale.height != 0) |
| 158 | { |
| 159 | int bottom = GridManager::getInstance().toGrid(coord.bottom()); |
| 160 | coord.height = bottom - coord.top; |
| 161 | } |
| 162 | else if (actionScale.top != 0) |
| 163 | { |
| 164 | coord.top = GridManager::getInstance().toGrid(coord.top); |
| 165 | } |
| 166 | |
| 167 | if (coord != mCoordValue) |
| 168 | { |
| 169 | mCoordValue = coord; |
| 170 | updateSelectionFromValue(); |
| 171 | } |
nothing calls this directly
no test coverage detected