equal
deleted
inserted
replaced
156 { |
156 { |
157 w->viewport->width = 0; |
157 w->viewport->width = 0; |
158 w->viewport = NULL; |
158 w->viewport = NULL; |
159 } |
159 } |
160 |
160 |
|
161 /** |
|
162 * Initialize viewport of the window for use. |
|
163 * @param w Window to use/display the viewport in |
|
164 * @param x Offset of left edge of viewport with respect to left edge window \a w |
|
165 * @param y Offset of top edge of viewport with respect to top edge window \a w |
|
166 * @param width Width of the viewport |
|
167 * @param height Height of the viewport |
|
168 * @param follow_flags Flags controlling the viewport. |
|
169 * - If bit 31 is set, the lower 16 bits are the vehicle that the viewport should follow. |
|
170 * - If bit 31 is clear, it is a tile position. |
|
171 * @param zoom Zoomlevel to display |
|
172 */ |
161 void AssignWindowViewport(Window *w, int x, int y, |
173 void AssignWindowViewport(Window *w, int x, int y, |
162 int width, int height, uint32 follow_flags, ZoomLevel zoom) |
174 int width, int height, uint32 follow_flags, ZoomLevel zoom) |
163 { |
175 { |
164 assert(w->viewport == NULL); |
176 assert(w->viewport == NULL); |
165 |
177 |
322 |
334 |
323 if (height > 0) DoSetViewportPosition(FindWindowZPosition(w) + 1, left, top, width, height); |
335 if (height > 0) DoSetViewportPosition(FindWindowZPosition(w) + 1, left, top, width, height); |
324 } |
336 } |
325 } |
337 } |
326 |
338 |
327 |
339 /** |
|
340 * Is a xy position inside the viewport of the window? |
|
341 * @param w Window to examine its viewport |
|
342 * @param x X coordinate of the xy position |
|
343 * @param y Y coordinate of the xy position |
|
344 * @return Pointer to the viewport if the xy position is in the viewport of the window, |
|
345 * otherwise \c NULL is returned. |
|
346 */ |
328 ViewPort *IsPtInWindowViewport(const Window *w, int x, int y) |
347 ViewPort *IsPtInWindowViewport(const Window *w, int x, int y) |
329 { |
348 { |
330 ViewPort *vp = w->viewport; |
349 ViewPort *vp = w->viewport; |
331 |
350 |
332 if (vp != NULL && |
351 if (vp != NULL && |
1589 SetViewportPosition(w, WP(w, vp_d).scrollpos_x, WP(w, vp_d).scrollpos_y); |
1608 SetViewportPosition(w, WP(w, vp_d).scrollpos_x, WP(w, vp_d).scrollpos_y); |
1590 } |
1609 } |
1591 } |
1610 } |
1592 |
1611 |
1593 /** |
1612 /** |
1594 * Marks a viewport as dirty for repaint. |
1613 * Marks a viewport as dirty for repaint if it displays (a part of) the area the needs to be repainted. |
1595 * |
1614 * @param vp The viewport to mark as dirty |
1596 * @param vp The viewport to mark as dirty |
1615 * @param left Left edge of area to repaint |
1597 * @todo documents the missing parameters @c left, @c top, @c right and @c bottom |
1616 * @param top Top edge of area to repaint |
1598 * @todo detailed description missing |
1617 * @param right Right edge of area to repaint |
|
1618 * @param bottom Bottom edge of area to repaint |
1599 * @ingroup dirty |
1619 * @ingroup dirty |
1600 */ |
1620 */ |
1601 static void MarkViewportDirty(const ViewPort *vp, int left, int top, int right, int bottom) |
1621 static void MarkViewportDirty(const ViewPort *vp, int left, int top, int right, int bottom) |
1602 { |
1622 { |
1603 right -= vp->virtual_left; |
1623 right -= vp->virtual_left; |
1620 UnScaleByZoom(right, vp->zoom) + vp->left, |
1640 UnScaleByZoom(right, vp->zoom) + vp->left, |
1621 UnScaleByZoom(bottom, vp->zoom) + vp->top |
1641 UnScaleByZoom(bottom, vp->zoom) + vp->top |
1622 ); |
1642 ); |
1623 } |
1643 } |
1624 |
1644 |
|
1645 /** |
|
1646 * Mark all viewports that display an area as dirty (in need of repaint). |
|
1647 * @param left Left edge of area to repaint |
|
1648 * @param top Top edge of area to repaint |
|
1649 * @param right Right edge of area to repaint |
|
1650 * @param bottom Bottom edge of area to repaint |
|
1651 * @ingroup dirty |
|
1652 */ |
1625 void MarkAllViewportsDirty(int left, int top, int right, int bottom) |
1653 void MarkAllViewportsDirty(int left, int top, int right, int bottom) |
1626 { |
1654 { |
1627 Window **wz; |
1655 Window **wz; |
1628 |
1656 |
1629 FOR_ALL_WINDOWS(wz) { |
1657 FOR_ALL_WINDOWS(wz) { |