Changeset - r6289:e952747c6a2c
[Not reviewed]
master
0 7 0
bjarni - 17 years ago 2007-03-11 10:55:35
bjarni@openttd.org
(svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
It has to be enabled first (in patches->interface) first and this will disable scrollwheel zooming
Note: patch setting "Map scrollwheel speed" might need to be changed since the "correct" setting
appears to depend on what kind of mouse is in use (mighty mouse or touchpad)
7 files changed with 42 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/gfx.h
Show inline comments
 
@@ -2,12 +2,13 @@
 

	
 
/** @file gfx.h */
 

	
 
#ifndef GFX_H
 
#define GFX_H
 

	
 
#include "openttd.h"
 

	
 
enum WindowKeyCodes {
 
	WKC_SHIFT = 0x8000,
 
	WKC_CTRL  = 0x4000,
 
	WKC_ALT   = 0x2000,
 
	WKC_META  = 0x1000,
 
@@ -112,12 +113,18 @@ struct CursorVars {
 
	Point pos, size, offs, delta; ///< position, size, offset from top-left, and movement
 
	Point draw_pos, draw_size;    ///< position and size bounding-box for drawing
 
	SpriteID sprite; ///< current image of cursor
 
	SpriteID pal;
 

	
 
	int wheel;       ///< mouse wheel movement
 

	
 
	/* We need two different vars to keep track of how far the scrollwheel moved.
 
	 * OSX uses this for scrolling around the map. */
 
	int v_wheel;
 
	int h_wheel;
 

	
 
	const AnimCursor *animate_list; ///< in case of animated cursor, list of frames
 
	const AnimCursor *animate_cur;  ///< in case of animated cursor, current frame
 
	uint animate_timeout;           ///< in case of animated cursor, number of ticks to show the current cursor
 

	
 
	bool visible;    ///< cursor is visible
 
	bool dirty;      ///< the rect occupied by the mouse is dirty (redraw)
src/lang/english.txt
Show inline comments
 
@@ -1087,12 +1087,16 @@ STR_CONFIG_PATCHES_REVERSE_SCROLLING    
 
STR_CONFIG_PATCHES_MEASURE_TOOLTIP                              :{LTBLUE}Show a measurement tooltip when using various build-tools: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_LIVERIES                                     :{LTBLUE}Show company liveries: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_LIVERIES_NONE                                :None
 
STR_CONFIG_PATCHES_LIVERIES_OWN                                 :Own company
 
STR_CONFIG_PATCHES_LIVERIES_ALL                                 :All companies
 
STR_CONFIG_PATCHES_PREFER_TEAMCHAT                              :{LTBLUE}Prefer team chat with <ENTER>: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLLING                        :{LTBLUE}Function of scrollwheel: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_SCROLLWHEEL_ZOOM                             :Zoom map
 
STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLL                           :Scroll map
 
STR_CONFIG_PATCHES_SCROLLWHEEL_MULTIPLIER                       :{LTBLUE}Map scrollwheel speed: {ORANGE}{STRING1}
 

	
 
STR_CONFIG_PATCHES_MAX_TRAINS                                   :{LTBLUE}Max trains per player: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_MAX_ROADVEH                                  :{LTBLUE}Max road vehicles per player: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_MAX_AIRCRAFT                                 :{LTBLUE}Max aircraft per player: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_MAX_SHIPS                                    :{LTBLUE}Max ships per player: {ORANGE}{STRING1}
 

	
src/settings.cpp
Show inline comments
 
@@ -1280,12 +1280,14 @@ const SettingDesc _patch_settings[] = {
 
	SDT_BOOL(Patches, population_in_label,           S, 0,  true,        STR_CONFIG_PATCHES_POPULATION_IN_LABEL,   PopulationInLabelActive),
 
	 SDT_VAR(Patches, map_x,              SLE_UINT8, S, 0,  8, 6, 11, 0, STR_CONFIG_PATCHES_MAP_X,                 NULL),
 
	 SDT_VAR(Patches, map_y,              SLE_UINT8, S, 0,  8, 6, 11, 0, STR_CONFIG_PATCHES_MAP_Y,                 NULL),
 
	SDT_BOOL(Patches, link_terraform_toolbar,        S, 0, false,        STR_CONFIG_PATCHES_LINK_TERRAFORM_TOOLBAR,NULL),
 
	 SDT_VAR(Patches, liveries,           SLE_UINT8, S,MS,  2, 0,  2, 0, STR_CONFIG_PATCHES_LIVERIES,              RedrawScreen),
 
	SDT_BOOL(Patches, prefer_teamchat,               S, 0, false,        STR_CONFIG_PATCHES_PREFER_TEAMCHAT,       NULL),
 
	SDT_VAR(Patches, scrollwheel_scrolling,SLE_UINT8,S,MS, 1,  0,  1, 0, STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLLING, NULL),
 
	SDT_VAR(Patches,scrollwheel_multiplier,SLE_UINT8,S, 0, 5,  1, 15, 1, STR_CONFIG_PATCHES_SCROLLWHEEL_MULTIPLIER,NULL),
 

	
 
	/***************************************************************************/
 
	/* Construction section of the GUI-configure patches window */
 
	SDT_BOOL(Patches, build_on_slopes,               0, 0,  true,        STR_CONFIG_PATCHES_BUILDONSLOPES,       NULL),
 
	SDT_BOOL(Patches, extra_dynamite,                0, 0, false,        STR_CONFIG_PATCHES_EXTRADYNAMITE,       NULL),
 
	SDT_BOOL(Patches, longbridges,                   0, 0,  true,        STR_CONFIG_PATCHES_LONGBRIDGES,         NULL),
src/settings_gui.cpp
Show inline comments
 
@@ -572,12 +572,19 @@ static const char *_patches_ui[] = {
 
	"window_snap_radius",
 
	"invisible_trees",
 
	"population_in_label",
 
	"link_terraform_toolbar",
 
	"liveries",
 
	"prefer_teamchat",
 
#if defined(__APPLE__)
 
	/* While the horizontal scrollwheel scrolling is written as general code, only
 
	 *  the cocoa (OSX) driver generates input for it.
 
	 *  Until some other driver will read this input, we will hide the GUI to control this from other systems. */
 
	"scrollwheel_scrolling",
 
	"scrollwheel_multiplier",
 
#endif
 
};
 

	
 
static const char *_patches_construction[] = {
 
	"build_on_slopes",
 
	"extra_dynamite",
 
	"longbridges",
src/variables.h
Show inline comments
 
@@ -218,12 +218,14 @@ struct Patches {
 

	
 
	uint8 freight_trains; ///< Value to multiply the weight of cargo by
 

	
 
	/** YAPF settings */
 
	YapfSettings  yapf;
 

	
 
	uint8 scrollwheel_scrolling;
 
	uint8 scrollwheel_multiplier;
 
};
 

	
 
VARDEF Patches _patches;
 

	
 

	
 
struct Cheat {
src/video/cocoa_v.mm
Show inline comments
 
@@ -65,12 +65,13 @@ extern "C" void HideMenuBar();
 

	
 

	
 
#include "../stdafx.h"
 
#include "../debug.h"
 
#include "../macros.h"
 
#include "../os/macosx/splash.h"
 
#include "../variables.h"
 
#include "cocoa_v.h"
 
#include "cocoa_keys.h"
 

	
 
#undef Point
 
#undef Rect
 

	
 
@@ -650,12 +651,16 @@ static bool QZ_PollEvent()
 
		case NSScrollWheel:
 
			if ([ event deltaY ] > 0.0) { /* Scroll up */
 
				_cursor.wheel--;
 
			} else if ([ event deltaY ] < 0.0) { /* Scroll down */
 
				_cursor.wheel++;
 
			} /* else: deltaY was 0.0 and we don't want to do anything */
 

	
 
			/* Set the scroll count for scrollwheel scrolling */
 
			_cursor.h_wheel -= (int)([ event deltaX ]* 5 * _patches.scrollwheel_multiplier);
 
			_cursor.v_wheel -= (int)([ event deltaY ]* 5 * _patches.scrollwheel_multiplier);
 
			break;
 

	
 
		default:
 
			[NSApp sendEvent:event];
 
	}
 

	
src/window.cpp
Show inline comments
 
@@ -1387,17 +1387,19 @@ static bool HandleScrollbarScrolling()
 

	
 
static bool HandleViewportScroll()
 
{
 
	WindowEvent e;
 
	Window *w;
 

	
 
	bool scrollwheel_scrolling = _patches.scrollwheel_scrolling == 1 && (_cursor.v_wheel != 0 || _cursor.h_wheel != 0);
 

	
 
	if (!_scrolling_viewport) return true;
 

	
 
	w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
 

	
 
	if (!_right_button_down || w == NULL) {
 
	if (!(_right_button_down || scrollwheel_scrolling) || w == NULL) {
 
		_cursor.fix_at = false;
 
		_scrolling_viewport = false;
 
		return true;
 
	}
 

	
 
	if (_patches.reverse_scroll) {
 
@@ -1405,12 +1407,20 @@ static bool HandleViewportScroll()
 
		e.we.scroll.delta.y = -_cursor.delta.y;
 
	} else {
 
		e.we.scroll.delta.x = _cursor.delta.x;
 
		e.we.scroll.delta.y = _cursor.delta.y;
 
	}
 

	
 
	if (scrollwheel_scrolling) {
 
		/* We are using scrollwheels for scrolling */
 
		e.we.scroll.delta.x = _cursor.h_wheel;
 
		e.we.scroll.delta.y = _cursor.v_wheel;
 
		_cursor.v_wheel = 0;
 
		_cursor.h_wheel = 0;
 
	}
 

	
 
	/* Create a scroll-event and send it to the window */
 
	e.event = WE_SCROLL;
 
	w->wndproc(w, &e);
 

	
 
	_cursor.delta.x = 0;
 
	_cursor.delta.y = 0;
 
@@ -1625,12 +1635,13 @@ static void HandleAutoscroll()
 

	
 
void MouseLoop(int click, int mousewheel)
 
{
 
	int x,y;
 
	Window *w;
 
	ViewPort *vp;
 
	bool scrollwheel_scrolling = _patches.scrollwheel_scrolling == 1 && (_cursor.v_wheel != 0 || _cursor.h_wheel != 0);
 

	
 
	DecreaseWindowCounters();
 
	HandlePlacePresize();
 
	UpdateTileSelection();
 
	if (!VpHandlePlaceSizingDrag())  return;
 
	if (!HandleDragDrop())           return;
 
@@ -1640,13 +1651,13 @@ void MouseLoop(int click, int mousewheel
 
	if (!HandleViewportScroll())     return;
 
	if (!HandleMouseOver())          return;
 

	
 
	x = _cursor.pos.x;
 
	y = _cursor.pos.y;
 

	
 
	if (click == 0 && mousewheel == 0) return;
 
	if (click == 0 && mousewheel == 0 && !scrollwheel_scrolling) return;
 

	
 
	w = FindWindowFromPt(x, y);
 
	if (w == NULL) return;
 
	if (!MaybeBringWindowToFront(w)) return;
 
	vp = IsPtInWindowViewport(w, x, y);
 

	
 
@@ -1656,19 +1667,20 @@ void MouseLoop(int click, int mousewheel
 
	if (mousewheel != 0) {
 
		WindowEvent e;
 

	
 
		/* Send WE_MOUSEWHEEL event to window */
 
		e.event = WE_MOUSEWHEEL;
 
		e.we.wheel.wheel = mousewheel;
 
		w->wndproc(w, &e);
 
		if (!scrollwheel_scrolling) w->wndproc(w, &e);
 

	
 
		/* Dispatch a MouseWheelEvent for widgets if it is not a viewport */
 
		if (vp == NULL) DispatchMouseWheelEvent(w, GetWidgetFromPos(w, x - w->left, y - w->top), mousewheel);
 
	}
 

	
 
	if (vp != NULL) {
 
		if (scrollwheel_scrolling) click = 2; // we are using the scrollwheel in a viewport, so we emulate right mouse button
 
		switch (click) {
 
			case 1:
 
				DEBUG(misc, 2, "Cursor: 0x%X (%d)", _cursor.sprite, _cursor.sprite);
 
				if (_thd.place_mode != 0 &&
 
						// query button and place sign button work in pause mode
 
						_cursor.sprite != SPR_CURSOR_QUERY &&
0 comments (0 inline, 0 general)