Fix: separate menu for export from toolbar

This commit is contained in:
Twan van Laarhoven
2020-04-10 16:56:54 +02:00
parent be9bae942e
commit 25fd7dc079
2 changed files with 22 additions and 13 deletions
+14 -7
View File
@@ -62,12 +62,7 @@ SetWindow::SetWindow(Window* parent, const SetP& set)
menuFile->Append(ID_FILE_OPEN, _("open"), _MENU_("open set"), _HELP_("open set"));
menuFile->Append(ID_FILE_SAVE, _("save"), _MENU_("save set"), _HELP_("save set"));
menuFile->Append(ID_FILE_SAVE_AS, _MENU_("save set as"), _HELP_("save set as"));
menuExport = new IconMenu();
menuExport->Append(ID_FILE_EXPORT_HTML, _("export_html"), _MENU_("export html"), _HELP_("export html"));
menuExport->Append(ID_FILE_EXPORT_IMAGE, _("export_image"), _MENU_("export image"), _HELP_("export image"));
menuExport->Append(ID_FILE_EXPORT_IMAGES, _("export_images"), _MENU_("export images"), _HELP_("export images"));
menuExport->Append(ID_FILE_EXPORT_APPR, _("export_apprentice"), _MENU_("export apprentice"),_HELP_("export apprentice"));
menuExport->Append(ID_FILE_EXPORT_MWS, _("export_mws"), _MENU_("export mws"), _HELP_("export mws"));
IconMenu* menuExport = makeExportMenu();
menuFile->Append(wxID_ANY, _("export"), _MENU_("export"), _HELP_("export"), wxITEM_NORMAL, menuExport);
menuFile->AppendSeparator();
menuFile->Append(ID_FILE_CHECK_UPDATES, _MENU_("check updates"), _HELP_("check updates"));
@@ -187,6 +182,16 @@ SetWindow::SetWindow(Window* parent, const SetP& set)
current_panel->Layout();
}
IconMenu* SetWindow::makeExportMenu() {
IconMenu* menuExport = new IconMenu();
menuExport->Append(ID_FILE_EXPORT_HTML, _("export_html"), _MENU_("export html"), _HELP_("export html"));
menuExport->Append(ID_FILE_EXPORT_IMAGE, _("export_image"), _MENU_("export image"), _HELP_("export image"));
menuExport->Append(ID_FILE_EXPORT_IMAGES, _("export_images"), _MENU_("export images"), _HELP_("export images"));
menuExport->Append(ID_FILE_EXPORT_APPR, _("export_apprentice"), _MENU_("export apprentice"), _HELP_("export apprentice"));
menuExport->Append(ID_FILE_EXPORT_MWS, _("export_mws"), _MENU_("export mws"), _HELP_("export mws"));
return menuExport;
}
SetWindow::~SetWindow() {
// store window size in settings
wxSize s = GetSize();
@@ -199,6 +204,7 @@ SetWindow::~SetWindow() {
current_panel->destroyUI(GetToolBar(), GetMenuBar());
// cleanup (see find stuff)
delete find_dialog;
delete export_menu;
// remove from list of set windows
set_windows.erase(remove(set_windows.begin(), set_windows.end(), this));
}
@@ -622,7 +628,8 @@ void SetWindow::onFileExportMenu(wxCommandEvent& ev) {
// tool down
tb->ToggleTool(ev.GetId(), true);
// pop up a menu of export options
tb->PopupMenu(menuExport, tool_rect.x, tool_rect.GetBottom());
if (!export_menu) export_menu = makeExportMenu();
tb->PopupMenu(export_menu, tool_rect.x, tool_rect.GetBottom());
// tool up
tb->ToggleTool(ev.GetId(), false);
}