OpenTTD
zoom_func.h
Go to the documentation of this file.
1 /* $Id$ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8  */
9 
12 #ifndef ZOOM_FUNC_H
13 #define ZOOM_FUNC_H
14 
15 #include "zoom_type.h"
16 
24 static inline int ScaleByZoom(int value, ZoomLevel zoom)
25 {
26  return value << zoom;
27 }
28 
36 static inline int UnScaleByZoom(int value, ZoomLevel zoom)
37 {
38  return (value + (1 << zoom) - 1) >> zoom;
39 }
40 
47 static inline int ScaleByZoomLower(int value, ZoomLevel zoom)
48 {
49  return value << zoom;
50 }
51 
58 static inline int UnScaleByZoomLower(int value, ZoomLevel zoom)
59 {
60  return value >> zoom;
61 }
62 
68 static inline int UnScaleGUI(int value)
69 {
70  return UnScaleByZoom(value, ZOOM_LVL_GUI);
71 }
72 
78 static inline int ScaleGUITrad(int value)
79 {
80  return UnScaleGUI(value * ZOOM_LVL_BASE);
81 }
82 
88 static inline int UnScaleFont(int value)
89 {
90  return UnScaleByZoom(value, ZOOM_LVL_FONT);
91 }
92 
98 static inline int ScaleFontTrad(int value)
99 {
100  return UnScaleFont(value * ZOOM_LVL_BASE);
101 }
102 
103 #endif /* ZOOM_FUNC_H */
static int UnScaleGUI(int value)
Short-hand to apply GUI zoom level.
Definition: zoom_func.h:68
static int UnScaleByZoomLower(int value, ZoomLevel zoom)
Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL)
Definition: zoom_func.h:58
static int UnScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL) When shifting right...
Definition: zoom_func.h:36
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Definition: zoom_func.h:78
static int ScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL) When shifting right...
Definition: zoom_func.h:24
static int ScaleFontTrad(int value)
Scale traditional pixel dimensions to Font zoom level.
Definition: zoom_func.h:98
static int ScaleByZoomLower(int value, ZoomLevel zoom)
Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL)
Definition: zoom_func.h:47
Types related to zooming in and out.
static int UnScaleFont(int value)
Short-hand to apply font zoom level.
Definition: zoom_func.h:88
ZoomLevel
All zoom levels we know.
Definition: zoom_type.h:21