OpenTTD Source: src/zoom_func.h File Reference

OpenTTD Source 15.0-beta1

Functions
zoom_func.h File Reference

Functions related to zooming. More...

`#include "zoom_type.h"`

Go to the source code of this file.

## Functions
int | ScaleByZoom (int value, ZoomLevel zoom)
| Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_MIN) When shifting right, value is rounded up.
int | UnScaleByZoom (int value, ZoomLevel zoom)
| Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_MIN) When shifting right, value is rounded up.
int | AdjustByZoom (int value, int zoom)
| Adjust by zoom level; zoom < 0 shifts right, zoom >= 0 shifts left.
int | ScaleByZoomLower (int value, ZoomLevel zoom)
| Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_MIN)
int | UnScaleByZoomLower (int value, ZoomLevel zoom)
| Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_MIN)
int | UnScaleGUI (int value)
| Short-hand to apply GUI zoom level.
ZoomLevel | ScaleZoomGUI (ZoomLevel value)
| Scale zoom level relative to GUI zoom.
ZoomLevel | UnScaleZoomGUI (ZoomLevel value)
| UnScale zoom level relative to GUI zoom.
int | ScaleSpriteTrad (int value)
| Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
int | ScaleGUITrad (int value)
| Scale traditional pixel dimensions to GUI zoom level.

## Detailed Description

Functions related to zooming.

Definition in file zoom_func.h.

## Function Documentation

## ◆ AdjustByZoom()

int AdjustByZoom | ( | int | value,
|  | int | zoom
| ) |  |
| inline

Adjust by zoom level; zoom < 0 shifts right, zoom >= 0 shifts left.

Parameters

  value | value to shift
  zoom | zoom level to shift to

Returns
  shifted value

Definition at line 45 of file zoom_func.h.

References ScaleByZoom(), and UnScaleByZoom().

## ◆ ScaleByZoom()

int ScaleByZoom | ( | int | value,
|  | ZoomLevel | zoom
| ) |  |
| inline

Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_MIN) When shifting right, value is rounded up.

Parameters

  value | value to shift
  zoom | zoom level to shift to

Returns
  shifted value

Definition at line 22 of file zoom_func.h.

Referenced by AdjustByZoom(), CheckClickOnVehicle(), CheckClickOnViewportSign(), CheckClickOnViewportSign(), Blitter_32bppSimple::Draw(), Blitter_8bppSimple::Draw(), GfxBlitter(), HandleAutoscroll(), InitializeWindowViewport(), LargeWorldCallback(), ViewportSign::MarkDirty(), SpriteAlignerWindow::OnClick(), MainWindow::OnScroll(), ExtraViewportWindow::OnScroll(), TranslateXYToTileCoord(), NWidgetViewport::UpdateViewportCoordinates(), and ViewportAddString().

## ◆ ScaleByZoomLower()

int ScaleByZoomLower | ( | int | value,
|  | ZoomLevel | zoom
| ) |  |
| inline

Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_MIN)

Parameters

  value | value to shift
  zoom | zoom level to shift to

Returns
  shifted value

Definition at line 56 of file zoom_func.h.

## ◆ ScaleGUITrad()

int ScaleGUITrad | ( | int | value | ) |
| inline

Scale traditional pixel dimensions to GUI zoom level.

Parameters

  value | Pixel amount at ZOOM_BASE (traditional "normal" interface size).

Returns
  Pixel amount at ZOOM_LVL_GUI (current interface size).

Definition at line 117 of file zoom_func.h.

References _gui_scale.

## ◆ ScaleSpriteTrad()

int ScaleSpriteTrad | ( | int | value | ) |
| inline

Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.

Parameters

  value | Pixel amount at ZOOM_BASE (traditional "normal" interface size).

Returns
  Pixel amount at ZOOM_LVL_GUI (current interface size).

Definition at line 107 of file zoom_func.h.

References UnScaleGUI().

Referenced by DrawAircraftImage(), DrawCargoIcons(), DrawCloseBox(), DrawCommonTileSeqInGUI(), DrawEngineList(), DrawRoadVehDetails(), DrawRoadVehImage(), DrawShipImage(), DrawTrainDetails(), DrawTrainImage(), DepotWindow::DrawVehicleInDepot(), DepotWindow::DrawWidget(), BuildDocksDepotWindow::DrawWidget(), BuildObjectWindow::DrawWidget(), PickerWindow::DrawWidget(), BuildRailStationWindow::DrawWidget(), BuildRailDepotWindow::DrawWidget(), BuildRoadDepotWindow::DrawWidget(), BuildRoadStationWindow::DrawWidget(), RefitWindow::DrawWidget(), FallbackParagraphLayout::FallbackVisualRun::FallbackVisualRun(), RoadVehicle::GetDisplayImageWidth(), Train::GetDisplayImageWidth(), GetTrainDetailsWndVScroll(), GetTrainSpriteSize(), HighlightDragPosition(), DepotWindow::OnPaint(), EndGameWindow::OnPaint(), HighScoreWindow::OnPaint(), SetMouseCursorVehicle(), ICURun::Shape(), UniscribeShapeRun(), DepotWindow::UpdateWidgetSize(), and EnginePreviewWindow::UpdateWidgetSize().

## ◆ ScaleZoomGUI()

ZoomLevel ScaleZoomGUI | ( | ZoomLevel | value | ) |
| inline

Scale zoom level relative to GUI zoom.

Parameters

  value | zoom level to scale

Returns
  scaled zoom level

Definition at line 87 of file zoom_func.h.

References ZOOM_LVL_MAX, ZOOM_LVL_MIN, and ZOOM_LVL_NORMAL.

Referenced by WaypointWindow::WaypointWindow().

## ◆ UnScaleByZoom()

int UnScaleByZoom | ( | int | value,
|  | ZoomLevel | zoom
| ) |  |
| inline

Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_MIN) When shifting right, value is rounded up.

Parameters

  value | value to shift
  zoom | zoom level to shift to

Returns
  shifted value

Definition at line 34 of file zoom_func.h.

Referenced by AdjustByZoom(), OpenGLBackend::DrawMouseCursor(), SpriteAlignerWindow::DrawWidget(), GetSpriteSize(), GfxBlitter(), MarkViewportDirty(), ScaleFontTrad(), SpriteAlignerWindow::SetStringParameters(), SetupScreenshotViewport(), UnScaleGUI(), and ViewportDrawDirtyBlocks().

## ◆ UnScaleByZoomLower()

int UnScaleByZoomLower | ( | int | value,
|  | ZoomLevel | zoom
| ) |  |
| inline

Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_MIN)

Parameters

  value | value to shift
  zoom | zoom level to shift to

Returns
  shifted value

Definition at line 67 of file zoom_func.h.

Referenced by OpenGLSprite::GetSize(), GfxBlitter(), and MarkViewportDirty().

## ◆ UnScaleGUI()

int UnScaleGUI | ( | int | value | ) |
| inline

Short-hand to apply GUI zoom level.

Parameters

  value | Pixel amount at ZOOM_LVL_MIN (full zoom in).

Returns
  Pixel amount at ZOOM_LVL_GUI (current interface size).

Definition at line 77 of file zoom_func.h.

References UnScaleByZoom().

Referenced by DrawAircraftImage(), DrawCommonTileSeqInGUI(), DrawHouseInGUI(), DrawRoadVehEngine(), DrawShipImage(), GetAircraftSpriteSize(), GetRoadVehSpriteSize(), GetShipSpriteSize(), GetSingleVehicleWidth(), GetTrainSpriteSize(), ScaleSpriteTrad(), and UpdateCursorSize().

## ◆ UnScaleZoomGUI()

ZoomLevel UnScaleZoomGUI | ( | ZoomLevel | value | ) |
| inline

UnScale zoom level relative to GUI zoom.

Parameters

  value | zoom level to scale

Returns
  un-scaled zoom level

Definition at line 97 of file zoom_func.h.

References ZOOM_LVL_MAX, ZOOM_LVL_MIN, and ZOOM_LVL_NORMAL.