Author: mordante
Date: Sun Dec  7 13:46:24 2008
New Revision: 31339

URL: http://svn.gna.org/viewcvs/wesnoth?rev=31339&view=rev
Log:
Improved the map scrolling feature.

After r30918 fixed the scrolling outside the window, several people noticed the
threshold of 5 pixels is rather small. Added a hidden preference named
'scroll_threshold' which is used to determine the number of pixels. The
threshold also defaults to 10 instead of 5, more testing is needed to get a
good default value.

Modified:
    trunk/changelog
    trunk/players_changelog
    trunk/src/controller_base.cpp
    trunk/src/preferences.cpp
    trunk/src/preferences.hpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=31339&r1=31338&r2=31339&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Sun Dec  7 13:46:24 2008
@@ -45,6 +45,8 @@
    * Improved wrapping in the new widgets.
    * Improved easy close handling.
    * Added a horizontal scrollbar widget.
+   * Made the border scrolling threshold a (hidden) preference and made it
+     default to 10 instead of 5 pixels.
  * WML engine:
    * Added the 'round' key to [set_variable].
    * It is possible to override the end-of-campaign screen text

Modified: trunk/players_changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/players_changelog?rev=31339&r1=31338&r2=31339&view=diff
==============================================================================
--- trunk/players_changelog (original)
+++ trunk/players_changelog Sun Dec  7 13:46:24 2008
@@ -16,6 +16,7 @@
         line.
     * Under the Burning Suns:
       * Made Elyssa Loyal and Quick instead of Quick and Intelligent.
+
   * Editor2
     * The map editor is automatically started if the binary file used
       to start Wesnoth contains "editor" somewhere in its name (useful
@@ -111,6 +112,9 @@
     * Updated movement and defense values on the reef terrain for many units.
     * Added the 'fearless' trait to the Heavy Infantryman line.
 
+  * User interface
+    * The map now scrolls earlier when the mouse reaches the border of Wesnoth.
+
   * Miscellaneous and bugfixes
     * There is a new revision of the main Wesnoth map with more placenames
       on it.

Modified: trunk/src/controller_base.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/controller_base.cpp?rev=31339&r1=31338&r2=31339&view=diff
==============================================================================
--- trunk/src/controller_base.cpp (original)
+++ trunk/src/controller_base.cpp Sun Dec  7 13:46:24 2008
@@ -128,8 +128,10 @@
 bool controller_base::handle_scroll(CKey& key, int mousex, int mousey, int 
mouse_flags)
 {
        bool scrolling = false;
-       const int scroll_threshold = (preferences::mouse_scroll_enabled()) ? 5 
: 0;
        bool mouse_in_window = SDL_GetAppState() & SDL_APPMOUSEFOCUS;
+       const int scroll_threshold = (preferences::mouse_scroll_enabled()) 
+                       ? preferences::mouse_scroll_threshold()
+                       : 0;
 
        if ((key[SDLK_UP] && have_keyboard_focus()) 
        || (mousey < scroll_threshold && mouse_in_window)) {

Modified: trunk/src/preferences.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/preferences.cpp?rev=31339&r1=31338&r2=31339&view=diff
==============================================================================
--- trunk/src/preferences.cpp (original)
+++ trunk/src/preferences.cpp Sun Dec  7 13:46:24 2008
@@ -54,6 +54,11 @@
 base_manager::~base_manager()
 {
        if (no_preferences_save) return;
+       
+       // Set the 'hidden' preferences.
+       prefs["scroll_threshold"] =
+                       lexical_cast<std::string>(mouse_scroll_threshold());
+
        write_preferences();
 }
 
@@ -519,6 +524,11 @@
        set("mouse_scrolling", value ? "yes" : "no");
 }
 
+int mouse_scroll_threshold()
+{
+       return lexical_cast_default<int>(prefs["scroll_threshold"], 10);
+}
+
 bool animate_map()
 {
        return utils::string_bool(preferences::get("animate_map"), true);

Modified: trunk/src/preferences.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/preferences.hpp?rev=31339&r1=31338&r2=31339&view=diff
==============================================================================
--- trunk/src/preferences.hpp (original)
+++ trunk/src/preferences.hpp Sun Dec  7 13:46:24 2008
@@ -130,6 +130,14 @@
        bool mouse_scroll_enabled();
        void enable_mouse_scroll(bool value);
 
+       /** 
+        * Gets the threshold for when to scroll.
+        *
+        * This scrolling happens when the mouse is in the application and near
+        * the border.
+        */
+       int mouse_scroll_threshold();
+
        /** Set editor red tint level. */
        void set_editor_r(int value);
        /** Set editor green tint level. */


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to