Changeset - r10426:48725b2e41be
[Not reviewed]
master
0 7 0
rubidium - 16 years ago 2008-12-16 17:58:27
rubidium@openttd.org
(svn r14679) -Fix [FS#2431]: opening the OSK on the chatbox did disable map scrolling (with keyboard) until another window with editbox was opened and closed. Just "refcount" the open edit boxes instead of setting/clearing a bit when opening/closing a window.
7 files changed with 15 insertions and 27 deletions:
0 comments (0 inline, 0 general)
src/console_gui.cpp
Show inline comments
 
@@ -150,22 +150,22 @@ struct IConsoleWindow : Window
 
{
 
	static int scroll;
 

	
 
	IConsoleWindow(const WindowDesc *desc) : Window(desc)
 
	{
 
		_iconsole_mode = ICONSOLE_OPENED;
 
		SetBit(_no_scroll, SCROLL_CON); // override cursor arrows; the gamefield will not scroll
 
		_no_scroll++; // override cursor arrows; the gamefield will not scroll
 

	
 
		this->height = _screen.height / 3;
 
		this->width  = _screen.width;
 
	}
 

	
 
	~IConsoleWindow()
 
	{
 
		_iconsole_mode = ICONSOLE_CLOSED;
 
		ClrBit(_no_scroll, SCROLL_CON);
 
		_no_scroll--;
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		int max = (this->height / ICON_LINE_HEIGHT) - 1;
 
		const IConsoleLine *print = IConsoleLine::Get(IConsoleWindow::scroll);
src/misc_gui.cpp
Show inline comments
 
@@ -1065,13 +1065,12 @@ enum QueryStringWidgets {
 

	
 
struct QueryStringWindow : public QueryStringBaseWindow
 
{
 
	QueryStringWindow(uint16 size, const WindowDesc *desc, Window *parent) : QueryStringBaseWindow(size, desc)
 
	{
 
		this->parent = parent;
 
		SetBit(_no_scroll, SCROLL_EDIT);
 

	
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
@@ -1139,13 +1138,12 @@ struct QueryStringWindow : public QueryS
 
	{
 
		if (!this->handled && this->parent != NULL) {
 
			Window *parent = this->parent;
 
			this->parent = NULL; // so parent doesn't try to delete us again
 
			parent->OnQueryTextFinished(NULL);
 
		}
 
		ClrBit(_no_scroll, SCROLL_EDIT);
 
	}
 
};
 

	
 
static const Widget _query_string_widgets[] = {
 
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,        STR_018B_CLOSE_WINDOW},
 
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    11,   259,     0,    13, STR_012D,        STR_NULL},
 
@@ -1440,13 +1438,12 @@ struct SaveLoadWindow : public QueryStri
 
			STR_4000_SAVE_GAME,
 
			STR_0299_SAVE_SCENARIO,
 
			STR_LOAD_HEIGHTMAP,
 
		};
 

	
 
		SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
 
		SetBit(_no_scroll, SCROLL_SAVE);
 

	
 
		/* Use an array to define what will be the current file type being handled
 
		 * by current file mode */
 
		switch (mode) {
 
			case SLD_SAVE_GAME:     this->GenerateFileName(); break;
 
			case SLD_SAVE_SCENARIO: strcpy(this->edit_str_buf, "UNNAMED"); break;
 
@@ -1502,13 +1499,12 @@ struct SaveLoadWindow : public QueryStri
 
	{
 
		/* pause is only used in single-player, non-editor mode, non menu mode */
 
		if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) {
 
			if (_pause_game >= 0) DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
 
		}
 
		FiosFreeSavegameList();
 
		ClrBit(_no_scroll, SCROLL_SAVE);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		int y;
 

	
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -274,23 +274,21 @@ struct NetworkChatWindow : public QueryS
 
		this->dtype   = type;
 
		this->dest    = dest;
 
		this->afilter = CS_ALPHANUMERAL;
 
		InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, 0);
 

	
 
		InvalidateWindowData(WC_NEWS_WINDOW, 0, this->height);
 
		SetBit(_no_scroll, SCROLL_CHAT); // do not scroll the game with the arrow-keys
 

	
 
		_chat_tab_completion_active = false;
 

	
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
 
	~NetworkChatWindow ()
 
	{
 
		InvalidateWindowData(WC_NEWS_WINDOW, 0, 0);
 
		ClrBit(_no_scroll, SCROLL_CHAT);
 
	}
 

	
 
	/**
 
	 * Find the next item of the list of things that can be auto-completed.
 
	 * @param item The current indexed item to return. This function can, and most
 
	 *     likely will, alter item, to skip empty items in the arrays.
src/osk_gui.cpp
Show inline comments
 
@@ -63,13 +63,12 @@ struct OskWindow : public Window {
 
		this->ok_btn     = ok;
 
		this->text       = &parent->text;
 

	
 
		/* make a copy in case we need to reset later */
 
		this->orig_str_buf = strdup(this->qs->text.buf);
 

	
 
		SetBit(_no_scroll, SCROLL_EDIT);
 
		/* Not needed by default. */
 
		this->DisableWidget(OSK_WIDGET_SPECIAL);
 

	
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
src/signs_gui.cpp
Show inline comments
 
@@ -196,26 +196,20 @@ enum QueryEditSignWidgets {
 

	
 
struct SignWindow : QueryStringBaseWindow, SignList {
 
	SignID cur_sign;
 

	
 
	SignWindow(const WindowDesc *desc, const Sign *si) : QueryStringBaseWindow(MAX_LENGTH_SIGN_NAME_BYTES, desc)
 
	{
 
		SetBit(_no_scroll, SCROLL_EDIT);
 
		this->caption = STR_280B_EDIT_SIGN_TEXT;
 
		this->afilter = CS_ALPHANUMERAL;
 
		this->LowerWidget(QUERY_EDIT_SIGN_WIDGET_TEXT);
 

	
 
		UpdateSignEditWindow(si);
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
 
	~SignWindow()
 
	{
 
		ClrBit(_no_scroll, SCROLL_EDIT);
 
	}
 

	
 
	void UpdateSignEditWindow(const Sign *si)
 
	{
 
		char *last_of = &this->edit_str_buf[this->edit_str_size - 1]; // points to terminating '\0'
 

	
 
		/* Display an empty string when the sign hasnt been edited yet */
 
		if (si->name != NULL) {
src/window.cpp
Show inline comments
 
@@ -458,13 +458,19 @@ Window::~Window()
 

	
 
	this->DeleteChildWindows();
 

	
 
	if (this->viewport != NULL) DeleteWindowViewport(this);
 

	
 
	this->SetDirty();
 
	free(this->widget);
 

	
 
	if (this->widget != NULL) {
 
		for (const Widget *wi = this->widget; wi->type != WWT_LAST; wi++) {
 
			if (wi->type == WWT_EDITBOX) _no_scroll--;
 
		}
 
		free(this->widget);
 
	}
 
}
 

	
 
/**
 
 * Find a window by its class and window number
 
 * @param cls Window class
 
 * @param number Number of the window within the window class
 
@@ -687,12 +693,16 @@ static void AssignWidgetToWindow(Window 
 

	
 
		for (const Widget *wi = widget; wi->type != WWT_LAST; wi++) index++;
 

	
 
		w->widget = MallocT<Widget>(index);
 
		memcpy(w->widget, widget, sizeof(*w->widget) * index);
 
		w->widget_count = index - 1;
 

	
 
		for (const Widget *wi = w->widget; wi->type != WWT_LAST; wi++) {
 
			if (wi->type == WWT_EDITBOX) _no_scroll++;
 
		}
 
	} else {
 
		w->widget = NULL;
 
		w->widget_count = 0;
 
	}
 
}
 

	
src/window_gui.h
Show inline comments
 
@@ -541,24 +541,15 @@ extern Window *_z_windows[];
 
extern Window **_last_z_window;
 

	
 
/** Iterate over all windows */
 
#define FOR_ALL_WINDOWS(wz) for (wz = _z_windows; wz != _last_z_window; wz++)
 

	
 
/**
 
 * In certain windows you navigate with the arrow keys. Do not scroll the
 
 * gameview when here. Bitencoded variable that only allows scrolling if all
 
 * elements are zero
 
 * Disable scrolling of the main viewport when an input-window is active.
 
 * This contains the count of windows with a textbox in them.
 
 */
 
enum {
 
	SCROLL_CON  = 0,
 
	SCROLL_EDIT = 1,
 
	SCROLL_SAVE = 2,
 
	SCROLL_CHAT = 4,
 
};
 

	
 
/** Disable scrolling of the main viewport when an input-window is active. */
 
extern byte _no_scroll;
 

	
 
extern Point _cursorpos_drag_start;
 

	
 
extern int _scrollbar_start_pos;
 
extern int _scrollbar_size;
0 comments (0 inline, 0 general)