Simplify management of mouse clicks and keystrokes
For now, there is a ping-pong among the Video, the TimeScale and the TimePane objects, as regards the management of mouse clicks and keystrokes.
The class TimeScale
respond to mousePressEvent
. The user clicks on the timescale in order to change the position time of the video. This triggers this chain of events:
-
TimeScale.mousePressEvent
computes the time (in ms, as an integer) associated with the position clicked and passes it toWindow.set_video_position
. -
Window.set_video_position
just passes its argument toVideo.set_position
. -
Video.set_position
truncates the position to a multiple ofself.mfps
and passes the result toWindow.set_position
. -
Window.set_position
just passes its argument toTimePaneView.set_position
. -
TimePaneView.set_position
does three things:- If there is an occurrence under creation, it calls method
get_time_from_bounding_interval
for that occurrence. Essentially, this method restrains its time argument to the feasible interval and returns the new bounded value. - Do the same thing for the selected item, if it is an occurrence.
- Call the method
Window.set_media_player_position
, passing as argument the value of time (after casting it toint
, unnecessarily, btw).
- If there is an occurrence under creation, it calls method
-
Window.set_media_player_position
passes its argumentposition
toVideo.media_player.setPosition
(after casting it toint
, unnecessarily, btw) - Changing the
MediaPlayer
position triggers the call to methodVideo.position_changed
, which:- updates the
Timestamp
(viaTimestamp.update
); - passes its argument to
Window.position_changed
.
- updates the
-
Window.position_changed
does two things:- Set the value of
TimePane.time
. This triggers a call toTimePane.on_time_changed
- Call
TimePaneView.update
- Set the value of
-
TimePane.on_time_changed
does this:- If there is an occurrence under creation, limit the time to the borders (this will trigger again
TimePane.on_time_changed
, eventually) - If there is a selected occurrence, calls
Occurrence.get_time_from_bounding_interval
. - Set the x position of the
Cursor
object - If there is an
OccurrenceHandle
object focused, calls itsOccurrenceHandle.change_time
, passing thetime
argument to it. - Update the occurrence borders, via
TimePane.occurrence_borders
.
- If there is an occurrence under creation, limit the time to the borders (this will trigger again
-
OccurrenceHandle.change_time
calls eitherOccurrence.update_begin_time
orOccurrence.update_end_time
. - Finally, both
Occurrence.update_begin_time
andOccurrence.update_end_time
call nobody.
[See issue #122 (closed).]
This must be improved, probably in connection with issues #116 (closed) and #145 (closed).
Edited by Rafael Laboissière