(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.
--- a/src/console_gui.cpp Mon Dec 15 22:22:23 2008 +0000
+++ b/src/console_gui.cpp Tue Dec 16 17:58:27 2008 +0000
@@ -153,7 +153,7 @@
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;
@@ -162,7 +162,7 @@
~IConsoleWindow()
{
_iconsole_mode = ICONSOLE_CLOSED;
- ClrBit(_no_scroll, SCROLL_CON);
+ _no_scroll--;
}
virtual void OnPaint()
--- a/src/misc_gui.cpp Mon Dec 15 22:22:23 2008 +0000
+++ b/src/misc_gui.cpp Tue Dec 16 17:58:27 2008 +0000
@@ -1068,7 +1068,6 @@
QueryStringWindow(uint16 size, const WindowDesc *desc, Window *parent) : QueryStringBaseWindow(size, desc)
{
this->parent = parent;
- SetBit(_no_scroll, SCROLL_EDIT);
this->FindWindowPlacementAndResize(desc);
}
@@ -1142,7 +1141,6 @@
this->parent = NULL; // so parent doesn't try to delete us again
parent->OnQueryTextFinished(NULL);
}
- ClrBit(_no_scroll, SCROLL_EDIT);
}
};
@@ -1443,7 +1441,6 @@
};
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 */
@@ -1505,7 +1502,6 @@
if (_pause_game >= 0) DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
}
FiosFreeSavegameList();
- ClrBit(_no_scroll, SCROLL_SAVE);
}
virtual void OnPaint()
--- a/src/network/network_chat_gui.cpp Mon Dec 15 22:22:23 2008 +0000
+++ b/src/network/network_chat_gui.cpp Tue Dec 16 17:58:27 2008 +0000
@@ -277,7 +277,6 @@
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;
@@ -287,7 +286,6 @@
~NetworkChatWindow ()
{
InvalidateWindowData(WC_NEWS_WINDOW, 0, 0);
- ClrBit(_no_scroll, SCROLL_CHAT);
}
/**
--- a/src/osk_gui.cpp Mon Dec 15 22:22:23 2008 +0000
+++ b/src/osk_gui.cpp Tue Dec 16 17:58:27 2008 +0000
@@ -66,7 +66,6 @@
/* 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);
--- a/src/signs_gui.cpp Mon Dec 15 22:22:23 2008 +0000
+++ b/src/signs_gui.cpp Tue Dec 16 17:58:27 2008 +0000
@@ -199,7 +199,6 @@
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);
@@ -208,11 +207,6 @@
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'
--- a/src/window.cpp Mon Dec 15 22:22:23 2008 +0000
+++ b/src/window.cpp Tue Dec 16 17:58:27 2008 +0000
@@ -461,7 +461,13 @@
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);
+ }
}
/**
@@ -690,6 +696,10 @@
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;
--- a/src/window_gui.h Mon Dec 15 22:22:23 2008 +0000
+++ b/src/window_gui.h Tue Dec 16 17:58:27 2008 +0000
@@ -544,18 +544,9 @@
#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;