New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement the beginnings of scrolling via dragging. #460
Closed
+188
−93
Closed
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Loading status checks…
Implement the beginnings of scrolling via dragging.
There are tearing problems and GLUT does not support the mouse wheel. Still, it's a start!
- Loading branch information
commit 66e31aa0bd224008635a0c9d52f4de4ace731a93
| @@ -106,6 +106,11 @@ fn run_main_loop(po: Port<Msg>, script_chan: SharedChan<ScriptMsg>, opts: &Opts) | ||
| let key_handlers: @mut ~[Chan<()>] = @mut ~[]; | ||
| let done = @mut false; | ||
|
|
||
| // FIXME: This should not be a separate offset applied after the fact but rather should be | ||
| // applied to the layers themselves on a per-layer basis. However, this won't work until scroll | ||
| // positions are sent to content. | ||
| let world_offset = @mut Point2D(0f32, 0f32); | ||
|
|
||
| let check_for_messages: @fn() = || { | ||
| // Periodically check if the script task responded to our last resize event | ||
| resize_rate_limiter.check_resize_response(); | ||
| @@ -164,8 +169,11 @@ fn run_main_loop(po: Port<Msg>, script_chan: SharedChan<ScriptMsg>, opts: &Opts) | ||
| }; | ||
|
|
||
| // Set the layer's transform. | ||
| let (x, y) = (buffer.rect.origin.x as f32, buffer.rect.origin.y as f32); | ||
| let transform = original_layer_transform.translate(x, y, 0.0); | ||
| let mut origin = Point2D(buffer.rect.origin.x as f32, | ||
|
||
| buffer.rect.origin.y as f32); | ||
| let transform = original_layer_transform.translate(origin.x, | ||
| origin.y, | ||
| 0.0); | ||
| let transform = transform.scale(width as f32, height as f32, 1.0); | ||
| image_layer.common.set_transform(transform) | ||
| } | ||
| @@ -178,6 +186,7 @@ fn run_main_loop(po: Port<Msg>, script_chan: SharedChan<ScriptMsg>, opts: &Opts) | ||
|
|
||
| do window.set_composite_callback { | ||
| do time::time(~"compositing") { | ||
| debug!("compositor: compositing"); | ||
| // Adjust the layer dimensions as necessary to correspond to the size of the window. | ||
| scene.size = window.size(); | ||
|
|
||
| @@ -200,6 +209,19 @@ fn run_main_loop(po: Port<Msg>, script_chan: SharedChan<ScriptMsg>, opts: &Opts) | ||
| script_chan.send(LoadMsg(url::make_url(url_string.to_str(), None))) | ||
| } | ||
|
|
||
| // When the user scrolls, move the layer around. | ||
| do window.set_scroll_callback |delta| { | ||
| // FIXME: Can't use `+=` due to a Rust bug. | ||
metajack
Contributor
|
||
| let world_offset_copy = *world_offset; | ||
| *world_offset = world_offset_copy + delta; | ||
|
|
||
| debug!("compositor: scrolled to %?", *world_offset); | ||
|
|
||
| root_layer.common.set_transform(identity().translate(world_offset.x, world_offset.y, 0.0)); | ||
|
|
||
| window.set_needs_display() | ||
| } | ||
|
|
||
| // Enter the main event loop. | ||
| while !*done { | ||
| // Check for new messages coming from the rendering task. | ||
Submodule rust-layers
updated
from 60036b to af9607
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Does this not warn about unused mut? I don't see where it's ever mutated.