|
1 | 1 | <template> |
2 | | - <BlockUI ref="blockUi" class="opencor overflow-hidden h-full" |
| 2 | + <BlockUI ref="blockUi" class="opencor overflow-hidden h-full" :class="showMainMenu ? 'with-main-menu' : ''" |
3 | 3 | :blocked="compBlockUiEnabled" |
4 | 4 | @click="activateInstance" |
5 | 5 | @focus="activateInstance" |
|
21 | 21 | > |
22 | 22 | <input ref="files" type="file" multiple style="display: none;" @change="onChange" /> |
23 | 23 | <DragNDropComponent v-show="dragAndDropCounter" /> |
24 | | - <MainMenu :id="mainMenuId" v-if="!electronApi && !omex" |
| 24 | + <MainMenu ref="mainMenu" :id="mainMenuId" v-if="showMainMenu" |
25 | 25 | :isActive="compIsActive" |
26 | 26 | :uiEnabled="compUiEnabled" |
27 | 27 | :hasFiles="hasFiles" |
@@ -139,6 +139,7 @@ const { isDialogActive } = provideDialogState(); |
139 | 139 |
|
140 | 140 | const blockUi = vue.ref<vue.ComponentPublicInstance | null>(null); |
141 | 141 | const toastId = vue.ref('opencorToast'); |
| 142 | +const mainMenu = vue.ref<vue.ComponentPublicInstance | null>(null); |
142 | 143 | const mainMenuId = vue.ref('opencorMainMenu'); |
143 | 144 | const files = vue.ref<HTMLElement | null>(null); |
144 | 145 | const contents = vue.ref<InstanceType<typeof IContentsComponent> | null>(null); |
@@ -181,6 +182,12 @@ const compUiEnabled = vue.computed(() => { |
181 | 182 | return !compBlockUiEnabled.value && !isDialogActive.value; |
182 | 183 | }); |
183 | 184 |
|
| 185 | +// Determine whether to show the main menu or not. |
| 186 | +
|
| 187 | +const showMainMenu = vue.computed(() => { |
| 188 | + return !electronApi && !props.omex; |
| 189 | +}); |
| 190 | +
|
184 | 191 | // Provide access to our progress message features. |
185 | 192 |
|
186 | 193 | export interface IProgressMessage { |
@@ -933,6 +940,33 @@ vue.onMounted(() => { |
933 | 940 | }, SHORT_DELAY); |
934 | 941 | }); |
935 | 942 |
|
| 943 | +// Track the height of our main menu. |
| 944 | +
|
| 945 | +let stopTrackingMainMenuHeight: (() => void) | null = null; |
| 946 | +
|
| 947 | +vue.onMounted(() => { |
| 948 | + if (!showMainMenu.value) { |
| 949 | + return; |
| 950 | + } |
| 951 | +
|
| 952 | + void vue.nextTick(() => { |
| 953 | + const mainMenuElement = mainMenu.value?.$el as HTMLElement | undefined; |
| 954 | + const blockUiElement = blockUi.value?.$el as HTMLElement | undefined; |
| 955 | +
|
| 956 | + if (mainMenuElement && blockUiElement) { |
| 957 | + stopTrackingMainMenuHeight = vueCommon.trackElementHeight(mainMenuElement, blockUiElement, '--main-menu-height'); |
| 958 | + } |
| 959 | + }); |
| 960 | +}); |
| 961 | +
|
| 962 | +vue.onBeforeUnmount(() => { |
| 963 | + if (stopTrackingMainMenuHeight) { |
| 964 | + stopTrackingMainMenuHeight(); |
| 965 | +
|
| 966 | + stopTrackingMainMenuHeight = null; |
| 967 | + } |
| 968 | +}); |
| 969 | +
|
936 | 970 | // If a COMBINE archive is provided then open it (and then the Simulation Experiment view will be shown in isolation) or |
937 | 971 | // carry on as normal (i.e. the whole OpenCOR UI will be shown). |
938 | 972 |
|
@@ -1258,4 +1292,14 @@ const onGitHubButtonClick = async (): Promise<void> => { |
1258 | 1292 | color: var(--p-red-200); |
1259 | 1293 | } |
1260 | 1294 | } |
| 1295 | +
|
| 1296 | +.with-main-menu { |
| 1297 | + :deep(.p-dialog-mask) { |
| 1298 | + padding-top: var(--main-menu-height) !important; |
| 1299 | + } |
| 1300 | +
|
| 1301 | + :deep(.p-message) { |
| 1302 | + margin-top: calc(0.5 * var(--main-menu-height)) !important; |
| 1303 | + } |
| 1304 | +} |
1261 | 1305 | </style> |
0 commit comments