src/zoom.hpp
author truelight
Tue, 15 May 2007 17:54:46 +0000
changeset 6628 8055b5f1031a
parent 6626 207875b9069a
child 6653 b20fcfed0847
permissions -rw-r--r--
(svn r9848) -Fix r9846: how every many times you check something, of course you always switch them at the last moment... UnScaleByZoom was ScaleByZoom and visa versa... (tnx to yeti_ for noticing)
6624
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
     1
/* $Id$ */
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
     2
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
     3
/** @file zoom.hpp */
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
     4
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
     5
#ifndef ZOOM_HPP
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
     6
#define ZOOM_HPP
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
     7
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
     8
enum ZoomLevel {
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
     9
	/* Our possible zoom-levels */
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
    10
	ZOOM_LVL_NORMAL = 0,
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
    11
	ZOOM_LVL_OUT_2X,
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
    12
	ZOOM_LVL_OUT_4X,
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
    13
	ZOOM_LVL_END,
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
    14
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
    15
	/* Here we define in which zoom viewports are */
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
    16
	ZOOM_LVL_VIEWPORT = ZOOM_LVL_NORMAL,
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
    17
	ZOOM_LVL_NEWS     = ZOOM_LVL_NORMAL,
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
    18
	ZOOM_LVL_INDUSTRY = ZOOM_LVL_OUT_2X,
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
    19
	ZOOM_LVL_TOWN     = ZOOM_LVL_OUT_2X,
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
    20
	ZOOM_LVL_AIRCRAFT = ZOOM_LVL_NORMAL,
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
    21
	ZOOM_LVL_SHIP     = ZOOM_LVL_NORMAL,
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
    22
	ZOOM_LVL_TRAIN    = ZOOM_LVL_NORMAL,
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
    23
	ZOOM_LVL_ROADVEH  = ZOOM_LVL_NORMAL,
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
    24
	ZOOM_LVL_WORLD_SCREENSHOT = ZOOM_LVL_NORMAL,
6626
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
    25
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
    26
	ZOOM_LVL_DETAIL   = ZOOM_LVL_OUT_2X, //! All zoomlevels below or equal to this, will result in details on the screen, like road-work, ...
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
    27
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
    28
	ZOOM_LVL_MIN      = ZOOM_LVL_NORMAL,
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
    29
	ZOOM_LVL_MAX      = ZOOM_LVL_OUT_4X,
6624
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
    30
};
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
    31
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
    32
extern ZoomLevel _saved_scrollpos_zoom;
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
    33
6626
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
    34
static inline int ScaleByZoom(int value, ZoomLevel zoom)
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
    35
{
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
    36
	int izoom = (int)zoom - (int)ZOOM_LVL_NORMAL;
6628
8055b5f1031a (svn r9848) -Fix r9846: how every many times you check something, of course you always switch them at the last moment... UnScaleByZoom was ScaleByZoom and visa versa... (tnx to yeti_ for noticing)
truelight
parents: 6626
diff changeset
    37
	return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : value >> izoom;
6626
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
    38
}
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
    39
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
    40
static inline int UnScaleByZoom(int value, ZoomLevel zoom)
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
    41
{
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
    42
	int izoom = (int)zoom - (int)ZOOM_LVL_NORMAL;
6628
8055b5f1031a (svn r9848) -Fix r9846: how every many times you check something, of course you always switch them at the last moment... UnScaleByZoom was ScaleByZoom and visa versa... (tnx to yeti_ for noticing)
truelight
parents: 6626
diff changeset
    43
	return (zoom > ZOOM_LVL_NORMAL) ? value >> izoom : value << izoom;
6626
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
    44
}
207875b9069a (svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents: 6624
diff changeset
    45
6624
880e29b1f25e (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
diff changeset
    46
#endif /* ZOOM_HPP */