more container window menu items

This commit is contained in:
nakst 2021-09-14 21:29:11 +01:00
parent 9a7c7106f4
commit d005957fc5
3 changed files with 55 additions and 21 deletions

View File

@ -568,7 +568,7 @@ int ProcessGlobalKeyboardShortcuts(EsElement *, EsMessage *message) {
bool ctrlOnly = message->keyboard.modifiers == ES_MODIFIER_CTRL;
int scancode = message->keyboard.scancode;
if (ctrlOnly && scancode == ES_SCANCODE_N) {
if (ctrlOnly && scancode == ES_SCANCODE_N && !message->keyboard.repeat) {
ApplicationInstanceCreate(APPLICATION_ID_DESKTOP_BLANK_TAB, nullptr, nullptr);
} else if (message->keyboard.modifiers == (ES_MODIFIER_CTRL | ES_MODIFIER_FLAG) && scancode == ES_SCANCODE_D) {
if (!desktop.inspectorOpen) {
@ -612,9 +612,9 @@ int ContainerWindowMessage(EsElement *element, EsMessage *message) {
if (tab == -1) tab = container->tabBand->items.Length() - 1;
if (tab == (int) container->tabBand->items.Length()) tab = 0;
WindowTabActivate((WindowTab *) container->tabBand->items[tab]);
} else if (ctrlOnly && scancode == ES_SCANCODE_T) {
} else if (ctrlOnly && scancode == ES_SCANCODE_T && !message->keyboard.repeat) {
ApplicationInstanceCreate(APPLICATION_ID_DESKTOP_BLANK_TAB, nullptr, container);
} else if (ctrlOnly && scancode == ES_SCANCODE_W) {
} else if (ctrlOnly && scancode == ES_SCANCODE_W && !message->keyboard.repeat) {
WindowTabClose(container->active);
} else if (message->keyboard.modifiers == ES_MODIFIER_FLAG && scancode == ES_SCANCODE_UP_ARROW) {
WindowSnap(container->window, false, false, SNAP_EDGE_MAXIMIZE);
@ -851,6 +851,35 @@ int WindowTabBandMessage(EsElement *element, EsMessage *message) {
} else if (message->type == ES_MSG_MOUSE_RIGHT_CLICK) {
EsMenu *menu = EsMenuCreate(band, ES_MENU_AT_CURSOR);
EsMenuAddItem(menu, ES_FLAGS_DEFAULT,
band->items.Length() > 1 ? interfaceString_DesktopCloseAllTabs : interfaceString_DesktopCloseWindow, -1,
[] (EsMenu *, EsGeneric context) {
WindowTabBand *band = (WindowTabBand *) context.p;
for (uintptr_t i = 0; i < band->items.Length(); i++) {
WindowTabClose((WindowTab *) band->items[i]);
}
}, band);
EsMenuAddSeparator(menu);
EsMenuAddItem(menu, band->window->isMaximised ? ES_ELEMENT_DISABLED : ES_FLAGS_DEFAULT,
INTERFACE_STRING(DesktopMaximiseWindow), [] (EsMenu *, EsGeneric context) {
WindowSnap((EsWindow *) context.p, false, false, SNAP_EDGE_MAXIMIZE);
}, band->window);
EsMenuAddItem(menu, band->window->isMaximised ? ES_ELEMENT_DISABLED : ES_FLAGS_DEFAULT,
INTERFACE_STRING(DesktopMinimiseWindow), [] (EsMenu *, EsGeneric context) {
EsSyscall(ES_SYSCALL_WINDOW_MOVE, ((EsWindow *) context.p)->handle, 0, 0, ES_WINDOW_MOVE_HIDDEN);
}, band->window);
EsMenuAddItem(menu, !band->window->isMaximised ? ES_ELEMENT_DISABLED : ES_FLAGS_DEFAULT,
INTERFACE_STRING(DesktopRestoreWindow), [] (EsMenu *, EsGeneric context) {
WindowRestore((EsWindow *) context.p);
}, band->window);
EsMenuAddSeparator(menu);
EsMenuAddItem(menu, band->window->isMaximised ? ES_ELEMENT_DISABLED : ES_FLAGS_DEFAULT,
INTERFACE_STRING(DesktopCenterWindow), [] (EsMenu *, EsGeneric context) {
WindowTabBand *band = (WindowTabBand *) context.p;
@ -861,15 +890,15 @@ int WindowTabBandMessage(EsElement *element, EsMessage *message) {
EsSyscall(ES_SYSCALL_WINDOW_MOVE, band->window->handle, (uintptr_t) &newBounds, 0, ES_FLAGS_DEFAULT);
}, band);
EsMenuAddItem(menu, band->window->isMaximised ? ES_ELEMENT_DISABLED : ES_FLAGS_DEFAULT,
band->items.Length() > 1 ? interfaceString_DesktopCloseAllTabs : interfaceString_DesktopCloseWindow, -1,
[] (EsMenu *, EsGeneric context) {
WindowTabBand *band = (WindowTabBand *) context.p;
EsMenuAddItem(menu, ES_FLAGS_DEFAULT,
INTERFACE_STRING(DesktopSnapWindowLeft), [] (EsMenu *, EsGeneric context) {
WindowSnap((EsWindow *) context.p, false, false, SNAP_EDGE_LEFT);
}, band->window);
for (uintptr_t i = 0; i < band->items.Length(); i++) {
WindowTabClose((WindowTab *) band->items[i]);
}
}, band);
EsMenuAddItem(menu, ES_FLAGS_DEFAULT,
INTERFACE_STRING(DesktopSnapWindowRight), [] (EsMenu *, EsGeneric context) {
WindowSnap((EsWindow *) context.p, false, false, SNAP_EDGE_RIGHT);
}, band->window);
EsMenuShow(menu);
} else {
@ -1139,7 +1168,7 @@ void ShutdownModalCreate() {
EsSyscall(ES_SYSCALL_WINDOW_SET_PROPERTY, window->handle, (uintptr_t) &screen, 0, ES_WINDOW_PROPERTY_BLUR_BOUNDS);
EsSyscall(ES_SYSCALL_WINDOW_SET_PROPERTY, window->handle, ES_WINDOW_SOLID_TRUE, 0, ES_WINDOW_PROPERTY_SOLID);
EsSyscall(ES_SYSCALL_WINDOW_SET_PROPERTY, window->handle, 0, 0, ES_WINDOW_PROPERTY_FOCUSED);
EsSyscall(ES_SYSCALL_WINDOW_SET_PROPERTY, window->handle, BLEND_WINDOW_MATERIAL_LIGHT_BLUR, 0, ES_WINDOW_PROPERTY_MATERIAL);
// EsSyscall(ES_SYSCALL_WINDOW_SET_PROPERTY, window->handle, BLEND_WINDOW_MATERIAL_LIGHT_BLUR, 0, ES_WINDOW_PROPERTY_MATERIAL);
// Setup the UI.

View File

@ -5272,7 +5272,7 @@ void FileMenuCreate(EsInstance *_instance, EsElement *element, EsCommand *) {
instance->startupInformation->filePath, instance->startupInformation->filePathBytes);
}
EsButton *renameButton = EsButtonCreate(panel3, ES_BUTTON_TOOLBAR); // TODO.
EsButton *renameButton = EsButtonCreate(panel3, ES_BUTTON_TOOLBAR);
if (!renameButton) goto show;
EsButtonSetIcon(renameButton, ES_ICON_DOCUMENT_EDIT_SYMBOLIC);
EsButtonOnCommand(renameButton, FileMenuRename);
@ -5293,22 +5293,22 @@ void FileMenuCreate(EsInstance *_instance, EsElement *element, EsCommand *) {
}
}
EsMenuAddSeparator(menu);
if (instance->instanceClass == ES_INSTANCE_CLASS_EDITOR && !newDocument) {
EsMenuAddSeparator(menu);
if (instance->instanceClass == ES_INSTANCE_CLASS_EDITOR) {
if (instance->commandSave.disabled) {
EsMenuAddItem(menu, ES_ELEMENT_DISABLED, INTERFACE_STRING(CommonFileUnchanged));
} else {
EsMenuAddCommand(menu, ES_FLAGS_DEFAULT, INTERFACE_STRING(CommonFileSave), &instance->commandSave);
}
EsMenuAddItem(menu, newDocument ? ES_ELEMENT_DISABLED : ES_FLAGS_DEFAULT, INTERFACE_STRING(CommonFileMakeCopy)); // TODO.
// EsMenuAddItem(menu, newDocument ? ES_ELEMENT_DISABLED : ES_FLAGS_DEFAULT, INTERFACE_STRING(CommonFileMakeCopy)); // TODO.
EsMenuAddSeparator(menu);
}
EsMenuAddItem(menu, newDocument ? ES_ELEMENT_DISABLED : ES_FLAGS_DEFAULT, INTERFACE_STRING(CommonFileShare)); // TODO.
EsMenuAddItem(menu, newDocument ? ES_ELEMENT_DISABLED : ES_FLAGS_DEFAULT, INTERFACE_STRING(CommonFileVersionHistory)); // TODO.
EsMenuAddCommand(menu, ES_FLAGS_DEFAULT, INTERFACE_STRING(CommonFileShowInFileManager), &instance->commandShowInFileManager);
// EsMenuAddItem(menu, newDocument ? ES_ELEMENT_DISABLED : ES_FLAGS_DEFAULT, INTERFACE_STRING(CommonFileShare)); // TODO.
// EsMenuAddItem(menu, newDocument ? ES_ELEMENT_DISABLED : ES_FLAGS_DEFAULT, INTERFACE_STRING(CommonFileVersionHistory)); // TODO.
EsMenuAddCommand(menu, ES_FLAGS_DEFAULT, INTERFACE_STRING(CommonFileShowInFileManager), &instance->commandShowInFileManager);
}
show: EsMenuShow(menu);
}

View File

@ -92,9 +92,14 @@ DEFINE_INTERFACE_STRING(DesktopConfirmShutdown, "Are you sure you want to turn o
DEFINE_INTERFACE_STRING(DesktopCloseTab, "Close tab");
DEFINE_INTERFACE_STRING(DesktopMoveTabToNewWindow, "Move to new window");
DEFINE_INTERFACE_STRING(DesktopInspectUI, "Inspect UI");
DEFINE_INTERFACE_STRING(DesktopCenterWindow, "Center in screen");
DEFINE_INTERFACE_STRING(DesktopCloseWindow, "Close window");
DEFINE_INTERFACE_STRING(DesktopCloseAllTabs, "Close all tabs");
DEFINE_INTERFACE_STRING(DesktopMaximiseWindow, "Fill screen");
DEFINE_INTERFACE_STRING(DesktopRestoreWindow, "Restore position");
DEFINE_INTERFACE_STRING(DesktopMinimiseWindow, "Hide");
DEFINE_INTERFACE_STRING(DesktopCenterWindow, "Center in screen");
DEFINE_INTERFACE_STRING(DesktopSnapWindowLeft, "Move to left side");
DEFINE_INTERFACE_STRING(DesktopSnapWindowRight, "Move to right side");
DEFINE_INTERFACE_STRING(DesktopSettingsApplication, "Settings");
DEFINE_INTERFACE_STRING(DesktopSettingsTitle, "Settings");