From b742d15c364cd7cc3c4baf48d30247342a148e20 Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Mon, 26 Nov 2018 00:54:53 +0100 Subject: [PATCH] Use > to slide faster, < to slow down (#77) * sliding_step_factor * reset window offset on H/L * remove debug code * readme --- README.md | 1 + src/Scene3D.cc | 10 ++++++++++ src/include/Arguments.hh | 3 ++- src/include/Manager.hh | 12 ++++++++---- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6b56b86..ec4f1b0 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ The actual file being represented below [is data/BigPictureBG.tga](http://www.do # Press F for full screen # Use the arrows to slide and enlarge the sliding window # Press M to slide the window to the end +# Use > to slide faster, < to slow down # SPACE to toggle spinning the shape # Press O to reset the camera position # ESC to quit diff --git a/src/Scene3D.cc b/src/Scene3D.cc index fcea148..2d90cdf 100644 --- a/src/Scene3D.cc +++ b/src/Scene3D.cc @@ -124,6 +124,16 @@ Scene3D::update(std::shared_ptr manager, float elapsedTime) { manager->args()->spin_shape = !manager->args()->spin_shape; if (events->keyPressed('M')) manager->args()->move_window = !manager->args()->move_window; + if (events->keyPressed('.')) { // '>' + manager->args()->sliding_step_factor *= 2; + } + if (events->keyPressed(',')) { // '<' + manager->args()->sliding_step_factor /= 2; + if (manager->args()->sliding_step_factor == 0) { + manager->args()->sliding_step_factor = 1; + } + } + if (manager->args()->move_window || selected_.size() == 0 || manager->slide_window()) { if (manager->args()->move_window) manager->slide_window_right(); diff --git a/src/include/Arguments.hh b/src/include/Arguments.hh index e345280..30c3d78 100644 --- a/src/include/Arguments.hh +++ b/src/include/Arguments.hh @@ -13,7 +13,7 @@ struct Arguments { range_begin(0), range_end(0), fullscreen(false), keep_chrome(false), - sliding_window_length(37*1024), sliding_step(1024), move_window(false), + sliding_window_length(37*1024), sliding_step(1024), sliding_step_factor(1), move_window(false), spin_shape(true) {} @@ -29,6 +29,7 @@ struct Arguments { bool keep_chrome; size_t sliding_window_length; size_t sliding_step; + size_t sliding_step_factor; bool move_window; bool spin_shape; }; diff --git a/src/include/Manager.hh b/src/include/Manager.hh index 30a52ac..173a36c 100644 --- a/src/include/Manager.hh +++ b/src/include/Manager.hh @@ -27,20 +27,24 @@ public: bool loadFile(size_t index); void loadFile(const std::string& filename); - void loadNextFile() { loadFile((fileIndex_ + 1) % args_->paths.size()); } - void loadPrevFile() { loadFile((fileIndex_ - 1) % args_->paths.size()); } + void loadNextFile() { loadFile((fileIndex_ + 1) % args_->paths.size()); reset_window(); } + void loadPrevFile() { loadFile((fileIndex_ - 1) % args_->paths.size()); reset_window(); } virtual void toggleFullscreen() = 0; std::shared_ptr args() const { return args_; } std::shared_ptr scene() const { return scene_; } + void reset_window() { sliding_window_offset_ = 0; } + void slide_window_left() { sliding_window_offset_ = (sliding_window_offset_ > args_->sliding_step) - ? sliding_window_offset_ - args_->sliding_step + ? sliding_window_offset_ - args_->sliding_step_factor * args_->sliding_step : 0; } - void slide_window_right() { sliding_window_offset_ += args_->sliding_step; } + void slide_window_right() { + sliding_window_offset_ += args_->sliding_step_factor * args_->sliding_step; + } void slide_window_up() { sliding_window_length_ += args_->sliding_step; } void slide_window_down() { sliding_window_length_ = (sliding_window_length_ > args_->sliding_step)