90 Commits

Author SHA1 Message Date
Daniel Santos
2578e9e2ef
Add lua mouse button event handler (#7952)
* Add lua mouse button event handler that can be consumed.
* Fix middle-mouse down/click not getting sent to lua

This is a flexible event handler mechanism to allow for more advanced
add-on features. It does not allow the add-on to consume the value
however, so there's no mechanism for the add-on to requrest the default
action not be executed.

We would normally deal separately with mouse down, up and click, with
the later being an event where the mouse has gone both down and up on
the same UI component. However, Wesnoth's code seems to allow a mouse up
on many UI components to serve as a click, so this implementation
follows that behavior.

This addresses issue #7949

The mouse handling code needs an overhaul, so this patch works with it
in it's current state in the best possible way. The revised code
attempts to restrict clicks to those events where a mouse went both down
and up on the same map tile. It is able to do this with the right mouse
button as well as X1 and X2, but must work as existing click events are
treated for now.

This means that "left click" is managed via the `left_click()` function
which occurrs at mouse down, "right click" via `right_mouse_up()` when
the right mouse button comes up, and the middle button's click behavior
is coded directly into mouse_handler_base::mouse_press() (so no function
is called) and "clicks" when the button comes down. The new
`on_mouse_button()` code will allow the mod developer to consume any
click event, preventing the default behavior, and also receive event
callbacks for up and down events, although the return value is ignored
for these calls and left and middle click occur on mouse down.
2023-10-17 00:08:00 -04:00
Pentarctagon
c44cc2742e Copyright update.. 2023-04-29 10:48:11 -05:00
Tommy
1c25ebdfa2 Remove std::endl from log lines, now that it's added automatically 2022-07-20 15:20:57 +12:00
Tommy
7370ef62cb Disable other mouse motion events while scrolling via middle mouse
Fixes stuttering while scrolling, and also various other distracting
effects such as showing reach map of units when passed over.
2022-07-13 13:34:01 +12:00
Tommy
103dfc031c Replace sdl::point_in_location with new rect::contains 2022-07-02 12:30:58 +12:00
Tommy
738392069d Fix a whole bunch of bad indentation.
Mostly spaces where tabs should have been used.
2022-06-25 15:24:03 +12:00
Gunter Labes
157d3426ab
Fix type 2022-06-18 08:45:27 +02:00
Tommy
ab10d4d219 Fix remaining input issues with scaled display.
There is a new sdl::get_mouse_state() function that should be used in place
of SDL_GetMouseState() in every case. It returns coordinates relative to
the drawing surface.

With this, the pixel scale option seems to be working without issue.
2022-04-18 17:25:06 +12:00
Pentarctagon
340023921d
2022 copyright update. 2022-03-06 19:07:13 -06:00
Pentarctagon
57ce449af8
Re-add attribution to copyright notices.
These are mostly useless and outdated/wrong, but apparently it's probably illegal to remove them.
2021-07-27 20:21:38 -05:00
Pentarctagon
ba75e1af50
Copyright update.
This additionally:
* Makes all copyright notices identical aside from the starting year for Wesnoth-specific source files. Files not included: mariadbpp, lua, spirit po, xbrz, and bcrypt (crypt_blowfish).
* Removes all attribution from the files, since the vast majority of them are outdated or seemingly just outright incorrect. For example, I would guess that Dave is no longer the sole author of the majority of Wesnoth's current code.
2021-07-26 11:38:03 -05:00
Victor Sergienko
941844f14a iOS: Long-touch context menu. Work around event queue delays. 2018-10-28 18:21:54 +02:00
Victor Sergienko
b4ef4c9b34 iOS: Touch-hex action added. 2018-10-28 18:21:54 +02:00
Victor Sergienko
c9097f4dad std::chrono::high_resolution_clock didn't work (do I have different versions of clang?), changed to clock(). 2018-10-28 18:21:53 +02:00
Victor Sergienko
aedc081b2e iOS: Touch interface implemented, and a RMB emulation of such on PC. 2018-10-28 18:21:53 +02:00
Martin Hrubý (hrubymar10)
674fda85b7 Migrate links to https if available - Fwd c18537edc0678f40a209797d72dfaba3e5e88545
(cherry-picked from commit bc4d22dc72e79c3d6a3364ac896e473afd298246)
2018-10-07 03:23:36 +00:00
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Charles Dang
eba94b3e22 Cleaned up unnecessary drawing calls
After testing, it seems these calls to raise_draw_event and display/game_display::draw()
were unnecessary - or at least, became unnecessary at some point. One or two are definitely
still needed, but removing these doesn't seem to cause anything to to glitch out. Likely
explanation is anything that needs updating just gets updated either immediately or on the
next play_slice loop.
2017-11-28 06:38:19 +11:00
Charles Dang
c5dc04c900 Handle context menus on mouse up instead of mouse down
This is more consistent behavior with apps in general.
2017-07-31 10:27:27 +11:00
Charles Dang
cc3c9be5b0 Mouse Handler Base: formatting cleanup
# Conflicts:
#	src/mouse_handler_base.cpp
2017-07-26 22:13:11 +11:00
Charles Dang
e4f03fe459 Moved all preferences source files into a single folder 2017-05-04 11:04:19 +11:00
qmo2015
c551cfd048 Fixed bug #24644: Units moving after in game help exit (#1002) 2017-05-01 02:37:28 -04:00
Celtic Minstrel
067301ea95 Fix ability to scroll via minimap while view locked 2017-04-24 00:07:43 -04:00
Celtic Minstrel
b4dc11ce36 Belated 2017 copyright update 2017-03-19 10:05:38 -04:00
Charles Dang
c912f7e7e7 Removed zoom slider code
This slider hasn't worked in ages, and we're planning to remove it anyway.

The slider "groove" image remains since it's hard drawn in the background image file.
2017-03-07 21:05:25 +11:00
Charles Dang
48d35a3199 Don't handle mousewheel scrolling if mouse is not in game map area (bug #24501) 2017-02-28 19:12:22 +11:00
Jyrki Vesterinen
af733360a8 Fix a bunch of MSVC2015 compiler warnings about hiding declarations
This commit still doesn't fix all of them. I decided to leave alone
cases where variables with the same name are assigned in multiple
conditions of the same if...else if...else statement, and cases where a
scope logging macro is used multiple times in the same scope. In any
case, this commit greatly reduces the warning count on MSVC2015 and makes
new warnings much easier to spot.
2016-10-06 00:11:56 +03:00
Andreas Löf
64b90042c4 Fix bug #24762: Recreate buttons GUI buttons on a full redraw
This re-creates the main display-gui() buttons on a full redraw to take
into account that the theme expects them to be out of sync. As a
consequence I have also been forced to refactor how said buttons are
managed and introduced a new method to join the same event context
as another component.
2016-07-09 21:54:48 +12:00
loonycyborg
dfe2f331a8 Fixed the direction of horizontal scrolling with mousewheel 2016-06-25 16:53:58 +03:00
Celtic Minstrel
3ac7f8d970 NULL -> nullptr
A few cases of NULL were missed, since changing them led to errors
(Mainly instances where it was passed to a boost::function)
2016-03-31 00:42:38 -04:00
Andreas Löf
358bd1235f Remove SDL1.2 code
This removes all legacy SDL1.2 code. It was done by invoking:
coan source --replace --no-transients -D"SDL_VERSION_ATLEAST(X, Y, Z)"=1 <file>
on each file.
2016-03-13 11:34:34 +13:00
Chris Beck
ba51524f6e update copyright to year 2016
using this shell script:

find src -type f -print0 | xargs -0 sed -i "s|Copyright (C) \([[:digit:]]*\)\([ ]*\)-\([ ]*\)2015|Copyright (C) \1\2-\32016|g"
2016-01-02 23:59:31 -05:00
Martin Proud
70f04dd2b1 Update mouse_handler_base.cpp
For Apple, control is the modifier key that is used for contextual menus.

KMOD_CTRL will check for a control-click. This fixes #15259 (https://gna.org/bugs/?15259). (I’ve built and verified with this patch, it works correctly.)
2015-12-29 07:53:02 -06:00
Ignacio R. Morelle
57ae45387a New Year copyright update 2015-01-01 19:07:35 -03:00
Mark de Wever
e35f4bb501 Strip trailing whitespace. 2014-06-09 15:26:19 +02:00
Boldizsár Lipka
ac96a2b91b Move some functions to sdl/rect. 2014-06-03 10:30:12 +02:00
Chris Beck
03a956d05c Make sure all warning logs are flushed, so travis gets the results.
This is the result of running command, in src/,

find . -type f -exec sed -i 's/\(WRN.*\)\\n\"\;/\1\" << std::endl\;/g' '{}' \;

and inspecting the results.

Also ran this subsequently:

find . -type f -exec sed -i 's/\(WARN.*\)\\n\"\;/\1\" << std::endl\;/g' '{}' \;

which only affected render.cpp
2014-05-20 15:48:36 -04:00
Alexander van Gessel
0e8c135c14 Fix strict compilation 2014-05-02 14:24:37 +02:00
David Mikos
c53b204abd Fix bug #21491: fix drag+drop for unit movements 2014-05-02 07:56:56 +09:30
Boldizsár Lipka
ea3bd56555 Switch vertical scrolling directions. 2014-03-14 22:56:55 +01:00
Boldizsár Lipka
2d54ec7aca Wrap old SDL code in a preproc directive. 2014-03-14 22:00:22 +01:00
Boldizsár Lipka
821b009948 Support SDL2's mouse wheel event in mouse_handler_base.
Allows to scroll the map with the wheel.
2014-03-14 22:00:22 +01:00
Ignacio R. Morelle
a4f47a63c7 New Year copyright update 2014-01-01 02:08:52 -03:00
Alexander van Gessel
6b0acc4c34 Initialize two variables
Found by coverity
2013-12-22 17:10:41 +01:00
Ignacio R. Morelle
25266cd2f6 Fix NULL pointer dereference when scroll-wheeling in the editor
From cd8c83532b0d33a3a2e24d9af04dac0455a84625:

  gui::slider* s = gui().find_slider("map-zoom-slider");
  if (point_in_rect(event.x, event.y, s->location())) {
      scrollx = 0; scrolly = 0;
  }

s is not guaranteed to not be NULL. display::find_slider() WILL return
NULL if it can't find the requested widget. As it turns out, the editor
currently lacks a slider called "map-zoom-slider".
2013-12-21 14:34:13 -03:00
David Mikos
d04f6af930 add check to see that middle click scrolling variables are fully intialized 2013-12-22 01:53:44 +10:30
David Mikos
cd8c83532b Make it so that sliders can be mouse wheel scrolled. 2013-12-22 00:16:27 +10:30
David Mikos
36b6b60beb Make middle click scrolling based on movement distance not screen centre. 2013-12-21 22:28:59 +10:30
Eric S. Raymond
043c4f9fd3 Remove $Id$ cookies. 2013-03-26 21:41:37 -04:00
Mark de Wever
43b71f2ff0 New year copyright update. 2013-01-01 09:22:03 +00:00