Add a back button gesture in clickwheel mode

custom
jacqueline 1 year ago
parent 5b272af545
commit 852ce7b917
  1. 1
      src/lua/include/lua_thread.hpp
  2. 20
      src/ui/encoder_input.cpp
  3. 1
      src/ui/include/ui_fsm.hpp
  4. 6
      src/ui/ui_fsm.cpp

@ -30,6 +30,7 @@ class LuaThread {
auto RunScript(const std::string& path) -> bool;
auto bridge() -> Bridge& { return *bridge_; }
auto state() -> lua_State* { return state_; }
private:
LuaThread(std::unique_ptr<Allocator>&, std::unique_ptr<Bridge>&, lua_State*);

@ -264,6 +264,26 @@ auto EncoderInput::Read(lv_indev_data_t* data) -> void {
break;
}
// Only trigger the directional long-press gestures if they trigger at the
// same time as a trigger on the overall touchwheel. This means the
// gestures only trigger if it's your only interaction with the wheel this
// press; scrolling and then resting on a direction should not trigger
// them.
trigger = TriggerKey(Keys::kTouchWheel, KeyStyle::kLongPress, now_ms);
if (trigger == Trigger::kLongPress) {
trigger =
TriggerKey(Keys::kDirectionalLeft, KeyStyle::kLongPress, now_ms);
switch (trigger) {
case Trigger::kNone:
break;
case Trigger::kClick:
break;
case Trigger::kLongPress:
events::Ui().Dispatch(internal::BackPressed{});
break;
}
}
break;
}
}

@ -130,6 +130,7 @@ class Lua : public UiState {
void react(const audio::PlaybackStarted&) override;
void react(const audio::PlaybackUpdate&) override;
void react(const audio::PlaybackFinished&) override;
void react(const internal::BackPressed&) override;
using UiState::react;

@ -245,7 +245,7 @@ auto Lua::PushLuaScreen(lua_State* s) -> int {
return 0;
}
auto Lua::PopLuaScreen(lua_State* s) -> int {
auto Lua::PopLuaScreen(lua_State *s) -> int {
PopScreen();
luavgl_set_root(s, sCurrentScreen->content());
lv_group_set_default(sCurrentScreen->group());
@ -301,6 +301,10 @@ void Lua::react(const audio::PlaybackFinished&) {
playback_playing_->Update(false);
}
void Lua::react(const internal::BackPressed& ev) {
PopLuaScreen(sLua->state());
}
void Browse::entry() {}
void Browse::react(const internal::ShowSettingsPage& ev) {

Loading…
Cancel
Save