Author: mordante
Date: Wed Jul 16 18:56:46 2008
New Revision: 28055
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28055&view=rev
Log:
Make clicking on the bar before and after the positioner also scroll the
scrollbar.
Modified:
trunk/src/gui/widgets/scrollbar.cpp
trunk/src/gui/widgets/scrollbar.hpp
trunk/src/gui/widgets/vertical_scrollbar.cpp
trunk/src/gui/widgets/vertical_scrollbar.hpp
Modified: trunk/src/gui/widgets/scrollbar.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/scrollbar.cpp?rev=28055&r1=28054&r2=28055&view=diff
==============================================================================
--- trunk/src/gui/widgets/scrollbar.cpp (original)
+++ trunk/src/gui/widgets/scrollbar.cpp Wed Jul 16 18:56:46 2008
@@ -145,6 +145,22 @@
mouse_ = mouse;
event.mouse_capture();
set_state(PRESSED);
+ }
+
+ const int bar = on_bar(mouse);
+
+ if(bar == -1) {
+ scroll(HALF_JUMP_BACKWARDS);
+ if(callback_positioner_move_) {
+ callback_positioner_move_(this);
+ }
+ } else if(bar == 1) {
+ scroll(HALF_JUMP_FORWARD);
+ if(callback_positioner_move_) {
+ callback_positioner_move_(this);
+ }
+ } else {
+ assert(bar == 0);
}
}
Modified: trunk/src/gui/widgets/scrollbar.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/scrollbar.hpp?rev=28055&r1=28054&r2=28055&view=diff
==============================================================================
--- trunk/src/gui/widgets/scrollbar.hpp (original)
+++ trunk/src/gui/widgets/scrollbar.hpp Wed Jul 16 18:56:46 2008
@@ -256,6 +256,19 @@
virtual bool on_positioner(const tpoint& coordinate) const = 0;
/**
+ * Is the coordinate on the bar?
+ *
+ * @param coordinate Coordinate to test whether it's on the
+ * bar.
+ *
+ * @returns Whether the location on the bar is.
+ * @retval -1 Coordinate is on the bar before
positioner.
+ * @retval 0 Coordinate is not on the bar.
+ * @retval 1 Coordinate is on the bar after the
positioner.
+ */
+ virtual int on_bar(const tpoint& coordinate) const = 0;
+
+ /**
* Gets the relevent difference in between the two positions.
*
* This function is used to determine how much the positioner needs to
be
Modified: trunk/src/gui/widgets/vertical_scrollbar.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/vertical_scrollbar.cpp?rev=28055&r1=28054&r2=28055&view=diff
==============================================================================
--- trunk/src/gui/widgets/vertical_scrollbar.cpp (original)
+++ trunk/src/gui/widgets/vertical_scrollbar.cpp Wed Jul 16 18:56:46 2008
@@ -69,10 +69,28 @@
bool tvertical_scrollbar::on_positioner(const tpoint& coordinate) const
{
// Note we assume the positioner is over the entire width of the widget.
- return coordinate.y >= static_cast<int>(get_positioner_offset())
- && coordinate.y < static_cast<int>(get_positioner_offset() +
get_positioner_length())
- && coordinate.x > 0
- && coordinate.x < static_cast<int>(get_width());
+ return coordinate.y >= static_cast<int>(get_positioner_offset())
+ && coordinate.y < static_cast<int>(get_positioner_offset() +
get_positioner_length())
+ && coordinate.x > 0
+ && coordinate.x < static_cast<int>(get_width());
+}
+
+int tvertical_scrollbar::on_bar(const tpoint& coordinate) const
+{
+ // Not on the widget, leave.
+ if(coordinate.x < 0 || coordinate.x > get_width()
+ || coordinate.y < 0 || coordinate.y > get_height()) {
+ return 0;
+ }
+
+ // we also assume the bar is over the entire width of the widget.
+ if(coordinate.y < get_positioner_offset()) {
+ return -1;
+ } else if(coordinate.y >get_positioner_offset() +
get_positioner_length()) {
+ return 1;
+ } else {
+ return 0;
+ }
}
} // namespace gui2
Modified: trunk/src/gui/widgets/vertical_scrollbar.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/vertical_scrollbar.hpp?rev=28055&r1=28054&r2=28055&view=diff
==============================================================================
--- trunk/src/gui/widgets/vertical_scrollbar.hpp (original)
+++ trunk/src/gui/widgets/vertical_scrollbar.hpp Wed Jul 16 18:56:46 2008
@@ -47,6 +47,9 @@
bool on_positioner(const tpoint& coordinate) const;
/** Inherited from tscrollbar. */
+ int on_bar(const tpoint& coordinate) const;
+
+ /** Inherited from tscrollbar. */
int get_length_difference(const tpoint& original, const tpoint&
current) const
{ return current.y - original.y; }
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits