Skip to content

Commit

Permalink
Allow hiding bottom bar momentarily through a Cockpit Action
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaellehmkuhl committed Nov 8, 2023
1 parent 837aee8 commit 36a1a10
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
</div>
<Transition name="fade">
<div
v-if="widgetStore.currentView.showBottomBarOnBoot"
v-if="showBottomBarNow"
class="z-[60] w-full h-12 bg-slate-600/50 absolute flex bottom-0 backdrop-blur-[2px] justify-between"
>
<MiniWidgetContainer
Expand Down Expand Up @@ -130,6 +130,7 @@ import {
onBeforeUnmount,
// defineAsyncComponent,
ref,
watch,
} from 'vue'
import { useRoute } from 'vue-router'
Expand Down Expand Up @@ -186,6 +187,15 @@ const resetHideMouseTimeout = (): void => {
}
document.addEventListener('mousemove', resetHideMouseTimeout)
// Control bottom bar momentary hiding
const showBottomBarNow = ref(widgetStore.currentView.showBottomBarOnBoot)
watch([() => widgetStore.currentView, () => widgetStore.currentView.showBottomBarOnBoot], () => {
showBottomBarNow.value = widgetStore.currentView.showBottomBarOnBoot
})
const debouncedToggleBottomBar = useDebounceFn(() => (showBottomBarNow.value = !showBottomBarNow.value), 25)
const bottomBarToggleCallbackId = registerActionCallback(CockpitAction.TOGGLE_BOTTOM_BAR, debouncedToggleBottomBar)
onBeforeUnmount(() => unregisterActionCallback(bottomBarToggleCallbackId))
</script>

<style>
Expand Down
1 change: 1 addition & 0 deletions src/libs/joystick/protocols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export enum CockpitAction {
TOGGLE_FULL_SCREEN = 'Toggle full-screen',
MAVLINK_ARM = 'Mavlink Command - Arm',
MAVLINK_DISARM = 'Mavlink Command - Disarm',
TOGGLE_BOTTOM_BAR = 'Toggle bottom bar',
}

export type CockpitActionCallback = () => void
Expand Down

0 comments on commit 36a1a10

Please sign in to comment.