Skip to content

Commit

Permalink
TV Mode: Automatically cancel seeking when focus is lost.
Browse files Browse the repository at this point in the history
  • Loading branch information
xfangfang committed Mar 9, 2024
1 parent e352207 commit 8c1a9ac
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
3 changes: 3 additions & 0 deletions wiliwili/include/view/video_progress_slider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class VideoProgressSlider : public brls::Box {

brls::View* getDefaultFocus() override;

void onChildFocusLost(brls::View* directChild, brls::View* focusedView) override;

void draw(NVGcontext* vg, float x, float y, float width, float height, brls::Style style,
brls::FrameContext* ctx) override;

Expand Down Expand Up @@ -73,4 +75,5 @@ class VideoProgressSlider : public brls::Box {

void buttonsProcessing();
void updateUI();
bool cancelPointerChange();
};
31 changes: 21 additions & 10 deletions wiliwili/source/view/video_progress_slider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,7 @@ VideoProgressSlider::VideoProgressSlider() {
}, true, true);

pointer->registerAction("cancel", brls::BUTTON_B, [this](...) {
if (!pointerSelected) return false;
pointerSelected = false;
ignoreProgressSetting = false;
pointer->setHideHighlightBackground(true);
this->progress = lastProgress;
if (this->progress < 0) this->progress = 0;
if (this->progress > 1) this->progress = 1;
updateUI();
return true;
return cancelPointerChange();
});

addView(pointer);
Expand Down Expand Up @@ -236,4 +228,23 @@ void VideoProgressSlider::buttonsProcessing() {
(progress > 0.01f && progress < 0.99f)) {
repeat = false;
}
}
}

void VideoProgressSlider::onChildFocusLost(brls::View* directChild, brls::View* focusedView) {
Box::onChildFocusLost(directChild, focusedView);
if (directChild == pointer) {
cancelPointerChange();
}
}

bool VideoProgressSlider::cancelPointerChange() {
if (!pointerSelected) return false;
pointerSelected = false;
ignoreProgressSetting = false;
pointer->setHideHighlightBackground(true);
this->progress = lastProgress;
if (this->progress < 0) this->progress = 0;
if (this->progress > 1) this->progress = 1;
updateUI();
return true;
}

0 comments on commit 8c1a9ac

Please sign in to comment.