Changeset 48:d853401b7307 in xplra for src
- Timestamp:
- 02/16/13 09:44:59 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/plugin/src/xplra
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/plugin/src/xplra/MessageWindow.cc
r47 r48 42 42 using hu::varadiistvan::xplcommon::Util; 43 43 44 using std::min; 45 using std::max; 46 44 47 //------------------------------------------------------------------------------ 45 48 … … 159 162 bool MessageWindow::handleMouseClick(int x, int y, XPLMMouseStatus mouse) 160 163 { 161 Util::debug("hu.varadiistvan.xplra.MessageWindow.handleMouseClick: x=%d, y=%d, mouse=0x%04x\n", 162 x, y, mouse); 164 if (mouse==xplm_MouseDown) { 165 if (x <= (left + resizeArea) ) { 166 mouseMode = MOUSE_RESIZE_LEFT; 167 } else if (x > (right-resizeArea) ) { 168 mouseMode = MOUSE_RESIZE_RIGHT; 169 } else { 170 mouseMode = MOUSE_MOVE; 171 } 172 clickedX = x; 173 clickedY = y; 174 } else if (mouse==xplm_MouseDrag) { 175 int xDiff = x - clickedX; 176 177 if (mouseMode==MOUSE_MOVE) { 178 int newLeft = left + xDiff; 179 int newRight = right + xDiff; 180 181 int screenWidth = XPLMGetDatai(widthDataRef); 182 if (newLeft>=0 && newRight<screenWidth) { 183 left = newLeft; 184 right = newRight; 185 } 186 187 int yDiff = y - clickedY; 188 int newTop = top + yDiff; 189 int newBottom = bottom + yDiff; 190 191 int screenHeight = XPLMGetDatai(heightDataRef); 192 if (newTop<screenHeight && newBottom>=0) { 193 top = newTop; 194 bottom = newBottom; 195 } 196 } else if (mouseMode==MOUSE_RESIZE_LEFT) { 197 int newLeft = left + xDiff; 198 if (newLeft>=0 && (right-newLeft)>=minimalWidth) { 199 left = newLeft; 200 } 201 } else if (mouseMode==MOUSE_RESIZE_RIGHT) { 202 int newRight = right + xDiff; 203 int screenWidth = XPLMGetDatai(widthDataRef); 204 if (newRight<screenWidth && (newRight-left)>=minimalWidth) { 205 right = newRight; 206 } 207 } 208 209 XPLMSetWindowGeometry(windowID, left, top, right, bottom); 210 211 clickedX = x; 212 clickedY = y; 213 } 214 163 215 return true; 164 216 } -
src/plugin/src/xplra/MessageWindow.h
r47 r48 68 68 XPLMMouseStatus mouse, void* refCon); 69 69 70 71 /** 72 * The minimal width of the message area. 73 */ 74 static const int minimalWidth = 150; 75 76 /** 77 * The size of the resize sensitivity area. 78 */ 79 static const int resizeArea = 50; 80 70 81 private: 71 82 /** … … 119 130 */ 120 131 float hideTime; 132 133 /** 134 * The mouse mode 135 */ 136 enum { 137 // Move the message area 138 MOUSE_MOVE, 139 140 // Resize the message area from the left 141 MOUSE_RESIZE_LEFT, 142 143 // Resize the message area from the right. 144 MOUSE_RESIZE_RIGHT 145 } mouseMode; 146 147 /** 148 * The X-coordinate where the window was clicked. 149 */ 150 int clickedX; 151 152 /** 153 * The Y-coordinate where the window was clicked. 154 */ 155 int clickedY; 121 156 122 157 /**
Note:
See TracChangeset
for help on using the changeset viewer.