Skip to content

Commit

Permalink
Use > to slide faster, < to slow down (#77)
Browse files Browse the repository at this point in the history
* sliding_step_factor

* reset window offset on H/L

* remove debug code

* readme
  • Loading branch information
fenollp authored Nov 25, 2018
1 parent 5100323 commit b742d15
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/Scene3D.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ Scene3D::update(std::shared_ptr<Manager> 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();
Expand Down
3 changes: 2 additions & 1 deletion src/include/Arguments.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{}

Expand All @@ -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;
};
Expand Down
12 changes: 8 additions & 4 deletions src/include/Manager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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<Arguments> args() const { return args_; }
std::shared_ptr<Scene> 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)
Expand Down

0 comments on commit b742d15

Please sign in to comment.