src/viewport.cpp
branchcpp_gui
changeset 6235 5077e6ed3788
parent 6206 67358999d80d
child 6237 bce32e54c993
equal deleted inserted replaced
6234:42bf2d268a86 6235:5077e6ed3788
   184 	vp->virtual_top = 0;//pt.y;
   184 	vp->virtual_top = 0;//pt.y;
   185 }
   185 }
   186 
   186 
   187 static Point _vp_move_offs;
   187 static Point _vp_move_offs;
   188 
   188 
   189 static void DoSetViewportPosition(Window* const *wz, int left, int top, int width, int height)
   189 static void DoSetViewportPosition(WindowList::Iterator vit, int left, int top, int width, int height)
   190 {
   190 {
   191 
   191 	//Window *w = (*wit).w;
   192 	for (; wz != _last_z_window; wz++) {
   192 
   193 		const Window *w = *wz;
   193 	for (WindowList::Iterator wit = vit; wit != Window::s_list.m_list.end(); wit++) {
       
   194 		const Window *w = (*wit).w;
   194 
   195 
   195 		if (left + width > w->left &&
   196 		if (left + width > w->left &&
   196 				w->left + w->width > left &&
   197 				w->left + w->width > left &&
   197 				top + height > w->top &&
   198 				top + height > w->top &&
   198 				w->top + w->height > top) {
   199 				w->top + w->height > top) {
   199 
   200 
   200 			if (left < w->left) {
   201 			if (left < w->left) {
   201 				DoSetViewportPosition(wz, left, top, w->left - left, height);
   202 				DoSetViewportPosition(wit, left, top, w->left - left, height);
   202 				DoSetViewportPosition(wz, left + (w->left - left), top, width - (w->left - left), height);
   203 				DoSetViewportPosition(wit, left + (w->left - left), top, width - (w->left - left), height);
   203 				return;
   204 				return;
   204 			}
   205 			}
   205 
   206 
   206 			if (left + width > w->left + w->width) {
   207 			if (left + width > w->left + w->width) {
   207 				DoSetViewportPosition(wz, left, top, (w->left + w->width - left), height);
   208 				DoSetViewportPosition(wit, left, top, (w->left + w->width - left), height);
   208 				DoSetViewportPosition(wz, left + (w->left + w->width - left), top, width - (w->left + w->width - left) , height);
   209 				DoSetViewportPosition(wit, left + (w->left + w->width - left), top, width - (w->left + w->width - left) , height);
   209 				return;
   210 				return;
   210 			}
   211 			}
   211 
   212 
   212 			if (top < w->top) {
   213 			if (top < w->top) {
   213 				DoSetViewportPosition(wz, left, top, width, (w->top - top));
   214 				DoSetViewportPosition(wit, left, top, width, (w->top - top));
   214 				DoSetViewportPosition(wz, left, top + (w->top - top), width, height - (w->top - top));
   215 				DoSetViewportPosition(wit, left, top + (w->top - top), width, height - (w->top - top));
   215 				return;
   216 				return;
   216 			}
   217 			}
   217 
   218 
   218 			if (top + height > w->top + w->height) {
   219 			if (top + height > w->top + w->height) {
   219 				DoSetViewportPosition(wz, left, top, width, (w->top + w->height - top));
   220 				DoSetViewportPosition(wit, left, top, width, (w->top + w->height - top));
   220 				DoSetViewportPosition(wz, left, top + (w->top + w->height - top), width , height - (w->top + w->height - top));
   221 				DoSetViewportPosition(wit, left, top + (w->top + w->height - top), width , height - (w->top + w->height - top));
   221 				return;
   222 				return;
   222 			}
   223 			}
   223 
   224 
   224 			return;
   225 			return;
   225 		}
   226 		}
   298 		}
   299 		}
   299 
   300 
   300 		i = top + height - _screen.height;
   301 		i = top + height - _screen.height;
   301 		if (i >= 0) height -= i;
   302 		if (i >= 0) height -= i;
   302 
   303 
   303 		if (height > 0) DoSetViewportPosition(FindWindowZPosition(w) + 1, left, top, width, height);
   304 		WindowList::Iterator it = Window::s_list.Find(w);
       
   305 		if (height > 0) DoSetViewportPosition(++it, left, top, width, height);
   304 	}
   306 	}
   305 }
   307 }
   306 
   308 
   307 
   309 
   308 ViewPort *IsPtInWindowViewport(const Window *w, int x, int y)
   310 ViewPort *IsPtInWindowViewport(const Window *w, int x, int y)
  1805 
  1807 
  1806 
  1808 
  1807 bool ScrollMainWindowTo(int x, int y)
  1809 bool ScrollMainWindowTo(int x, int y)
  1808 {
  1810 {
  1809 	Window *w;
  1811 	Window *w;
  1810 	bool res = ScrollWindowTo(x, y, FindWindowById(WC_MAIN_WINDOW, 0));
  1812 	bool res = ScrollWindowTo(x, y, Window::FindById(WC_MAIN_WINDOW, 0));
  1811 
  1813 
  1812 	/* If a user scrolls to a tile (via what way what so ever) and already is on
  1814 	/* If a user scrolls to a tile (via what way what so ever) and already is on
  1813 	 *  that tile (e.g.: pressed twice), move the smallmap to that location,
  1815 	 *  that tile (e.g.: pressed twice), move the smallmap to that location,
  1814 	 *  so you directly see where you are on the smallmap. */
  1816 	 *  so you directly see where you are on the smallmap. */
  1815 
  1817 
  1816 	if (res) return res;
  1818 	if (res) return res;
  1817 
  1819 
  1818 	w = FindWindowById(WC_SMALLMAP, 0);
  1820 	w = Window::FindById(WC_SMALLMAP, 0);
  1819 	if (w == NULL) return res;
  1821 	if (w == NULL) return res;
  1820 
  1822 
  1821 	SmallMapCenterOnCurrentPos(w);
  1823 	SmallMapCenterOnCurrentPos(w);
  1822 
  1824 
  1823 	return res;
  1825 	return res;
  2392 	if (_special_mouse_mode != WSM_SIZING) return true;
  2394 	if (_special_mouse_mode != WSM_SIZING) return true;
  2393 
  2395 
  2394 	e.we.place.userdata = _thd.userdata;
  2396 	e.we.place.userdata = _thd.userdata;
  2395 
  2397 
  2396 	// stop drag mode if the window has been closed
  2398 	// stop drag mode if the window has been closed
  2397 	w = FindWindowById(_thd.window_class,_thd.window_number);
  2399 	w = Window::FindById(_thd.window_class,_thd.window_number);
  2398 	if (w == NULL) {
  2400 	if (w == NULL) {
  2399 		ResetObjectToPlace();
  2401 		ResetObjectToPlace();
  2400 		return false;
  2402 		return false;
  2401 	}
  2403 	}
  2402 
  2404 
  2446 	Window *w;
  2448 	Window *w;
  2447 
  2449 
  2448 	// undo clicking on button
  2450 	// undo clicking on button
  2449 	if (_thd.place_mode != 0) {
  2451 	if (_thd.place_mode != 0) {
  2450 		_thd.place_mode = 0;
  2452 		_thd.place_mode = 0;
  2451 		w = FindWindowById(_thd.window_class, _thd.window_number);
  2453 		w = Window::FindById(_thd.window_class, _thd.window_number);
  2452 		if (w != NULL) CallWindowEventNP(w, WE_ABORT_PLACE_OBJ);
  2454 		if (w != NULL) CallWindowEventNP(w, WE_ABORT_PLACE_OBJ);
  2453 	}
  2455 	}
  2454 
  2456 
  2455 	SetTileSelectSize(1, 1);
  2457 	SetTileSelectSize(1, 1);
  2456 
  2458