From d6589f1d0e5b99651c6ecfbca28620dbaafae4d9 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 7 Feb 2020 00:41:37 +0100 Subject: [PATCH] WIP: refactoring ongoing. --- src/lay/lay/gsiDeclLayMainWindow.cc | 664 +++--- src/lay/lay/lay.pro | 4 - src/lay/lay/layApplication.cc | 2 +- src/lay/lay/layApplication.h | 4 +- src/lay/lay/layMacroController.h | 6 +- src/lay/lay/layMainConfigPages.h | 32 +- src/lay/lay/layMainWindow.cc | 2099 +++-------------- src/lay/lay/layMainWindow.h | 243 +- src/lay/lay/layNavigator.cc | 58 +- src/lay/lay/layNavigator.h | 2 - src/lay/lay/laySaltController.h | 10 +- src/lay/lay/laySettingsForm.cc | 4 +- src/lay/lay/laySettingsForm.h | 6 +- src/lay/lay/layTechnologyController.h | 8 +- .../laybasic}/LayoutStatistics.ui | 0 .../laybasic}/SelectCellViewForm.ui | 0 src/laybasic/laybasic/gsiDeclLayLayoutView.cc | 12 + src/laybasic/laybasic/gsiDeclLayPlugin.cc | 148 +- src/laybasic/laybasic/layAbstractMenu.cc | 181 +- src/laybasic/laybasic/layAbstractMenu.h | 88 +- .../laybasic/layAbstractMenuProvider.cc | 51 - .../laybasic/layAbstractMenuProvider.h | 107 - src/laybasic/laybasic/layBookmarksView.cc | 45 +- src/laybasic/laybasic/layBookmarksView.h | 2 - src/laybasic/laybasic/layDispatcher.cc | 282 +++ src/laybasic/laybasic/layDispatcher.h | 175 ++ src/laybasic/laybasic/layGridNet.cc | 2 +- src/laybasic/laybasic/layGridNet.h | 6 +- .../laybasic/layHierarchyControlPanel.cc | 99 +- .../laybasic/layHierarchyControlPanel.h | 5 - src/laybasic/laybasic/layLayerControlPanel.cc | 172 +- src/laybasic/laybasic/layLayerControlPanel.h | 5 - .../laybasic}/layLayoutStatistics.qrc | 0 .../laybasic}/layLayoutStatisticsForm.cc | 0 .../laybasic}/layLayoutStatisticsForm.h | 0 src/laybasic/laybasic/layLayoutView.cc | 759 +++++- src/laybasic/laybasic/layLayoutView.h | 42 +- .../laybasic/layLayoutViewConfigPages.h | 56 +- src/laybasic/laybasic/layLibrariesView.cc | 43 +- src/laybasic/laybasic/layLibrariesView.h | 5 - .../laybasic/layLoadLayoutOptionsDialog.h | 4 +- src/laybasic/laybasic/layNetlistBrowser.h | 8 +- src/laybasic/laybasic/layPlugin.cc | 323 +-- src/laybasic/laybasic/layPlugin.h | 249 +- .../laybasic/laySaveLayoutOptionsDialog.h | 2 +- .../laybasic}/laySelectCellViewForm.cc | 0 .../laybasic}/laySelectCellViewForm.h | 0 src/laybasic/laybasic/laybasic.pro | 16 +- src/laybasic/laybasic/rdbMarkerBrowser.h | 8 +- 49 files changed, 2476 insertions(+), 3561 deletions(-) rename src/{lay/lay => laybasic/laybasic}/LayoutStatistics.ui (100%) rename src/{lay/lay => laybasic/laybasic}/SelectCellViewForm.ui (100%) delete mode 100644 src/laybasic/laybasic/layAbstractMenuProvider.cc delete mode 100644 src/laybasic/laybasic/layAbstractMenuProvider.h create mode 100644 src/laybasic/laybasic/layDispatcher.cc create mode 100644 src/laybasic/laybasic/layDispatcher.h rename src/{lay/lay => laybasic/laybasic}/layLayoutStatistics.qrc (100%) rename src/{lay/lay => laybasic/laybasic}/layLayoutStatisticsForm.cc (100%) rename src/{lay/lay => laybasic/laybasic}/layLayoutStatisticsForm.h (100%) rename src/{lay/lay => laybasic/laybasic}/laySelectCellViewForm.cc (100%) rename src/{lay/lay => laybasic/laybasic}/laySelectCellViewForm.h (100%) diff --git a/src/lay/lay/gsiDeclLayMainWindow.cc b/src/lay/lay/gsiDeclLayMainWindow.cc index 396290f04..149594c69 100644 --- a/src/lay/lay/gsiDeclLayMainWindow.cc +++ b/src/lay/lay/gsiDeclLayMainWindow.cc @@ -43,6 +43,145 @@ void enable_edits (lay::MainWindow * /*main_window*/, bool enable) } } +// NOTE: match this with the cm_method_decl's below +static const char *cm_symbols[] = { + "cm_reset_window_state", + "cm_select_all", + "cm_unselect_all", + "cm_undo", + "cm_redo", + "cm_delete", + "cm_show_properties", + "cm_copy", + "cm_paste", + "cm_cut", + "cm_zoom_fit_sel", + "cm_zoom_fit", + "cm_zoom_in", + "cm_zoom_out", + "cm_pan_up", + "cm_pan_down", + "cm_pan_left", + "cm_pan_right", + "cm_save_session", + "cm_restore_session", + "cm_setup", + "cm_save_as", + "cm_save", + "cm_save_all", + "cm_reload", + "cm_close", + "cm_close_all", + "cm_clone", + "cm_layout_props", + "cm_inc_max_hier", + "cm_dec_max_hier", + "cm_max_hier", + "cm_max_hier_0", + "cm_max_hier_1", + "cm_prev_display_state|#cm_last_display_state", + "cm_next_display_state", + "cm_cancel", + "cm_redraw", + "cm_screenshot", + "cm_save_layer_props", + "cm_load_layer_props", + "cm_save_bookmarks", + "cm_load_bookmarks", + "cm_select_cell", + "cm_select_current_cell", + "cm_print", + "cm_exit", + "cm_view_log", + "cm_bookmark_view", + "cm_manage_bookmarks", + "cm_macro_editor", + "cm_goto_position", + "cm_help_about", + "cm_technologies", + "cm_packages", + "cm_open_too", + "cm_open_new_view", + "cm_open", + "cm_pull_in", + "cm_reader_options", + "cm_new_layout", + "cm_new_panel", + "cm_adjust_origin", + "cm_new_cell", + "cm_new_layer", + "cm_clear_layer", + "cm_delete_layer", + "cm_edit_layer", + "cm_copy_layer", + "cm_sel_flip_x", + "cm_sel_flip_y", + "cm_sel_rot_cw", + "cm_sel_rot_ccw", + "cm_sel_free_rot", + "cm_sel_scale", + "cm_sel_move", + "cm_sel_move_to", + "cm_lv_new_tab", + "cm_lv_remove_tab", + "cm_lv_rename_tab", + "cm_lv_hide", + "cm_lv_hide_all", + "cm_lv_show", + "cm_lv_show_all", + "cm_lv_show_only", + "cm_lv_rename", + "cm_lv_select_all", + "cm_lv_delete", + "cm_lv_insert", + "cm_lv_group", + "cm_lv_ungroup", + "cm_lv_source", + "cm_lv_sort_by_name", + "cm_lv_sort_by_ild", + "cm_lv_sort_by_idl", + "cm_lv_sort_by_ldi", + "cm_lv_sort_by_dli", + "cm_lv_regroup_by_index", + "cm_lv_regroup_by_datatype", + "cm_lv_regroup_by_layer", + "cm_lv_regroup_flatten", + "cm_lv_expand_all", + "cm_lv_add_missing", + "cm_lv_remove_unused", + "cm_cell_delete", + "cm_cell_rename", + "cm_cell_copy", + "cm_cell_cut", + "cm_cell_paste", + "cm_cell_select", + "cm_open_current_cell", + "cm_save_current_cell_as", + "cm_cell_hide", + "cm_cell_flatten", + "cm_cell_show", + "cm_cell_show_all", + "cm_navigator_close", + "cm_navigator_freeze" +}; + +template +void call_cm_method (lay::MainWindow *mw) +{ + tl_assert (NUM < sizeof (cm_symbols) / sizeof (cm_symbols [0])); + mw->menu_activated (cm_symbols [NUM]); +} + +template +gsi::Methods cm_method_decl () +{ + tl_assert (NUM < sizeof (cm_symbols) / sizeof (cm_symbols [0])); + return gsi::method (std::string ("#") + cm_symbols [NUM], &call_cm_method, + std::string ("@brief '") + cm_symbols[NUM] + "' action.\n" + "This method has been added in version 0.25 and is deprecated in version 0.27.\n" + "Use \"call_menu('" + std::string (cm_symbols[NUM]) + "')\" instead."); +} + Class decl_MainWindow (QT_EXTERNAL_BASE (QMainWindow) "lay", "MainWindow", // QMainWindow interface @@ -378,405 +517,138 @@ Class decl_MainWindow (QT_EXTERNAL_BASE (QMainWindow) "lay", "M "\n" "This method has been introduced in version 0.26.\n" ) + - gsi::method ("cm_reset_window_state", &lay::MainWindow::cm_reset_window_state, - "@brief 'cm_reset_window_state' action (bound to a menu)" + gsi::method ("call_menu", &lay::MainWindow::menu_activated, + "@brief Calls the menu item with the provided symbol.\n" + "To obtain all symbols, use get_menu_symbols.\n" "\n" - "This method has been added in version 0.25.\n" + "This method has been introduced in version 0.27 and replaces the previous cm_... methods. " + "Instead of calling a specific cm_... method, use LayoutView#call_menu with 'cm_...' as the symbol." ) + - gsi::method ("cm_select_all", &lay::MainWindow::cm_select_all, - "@brief 'cm_select_all' action (bound to a menu)" + gsi::method ("get_menu_symbols", &lay::MainWindow::menu_symbols, + "@brief Calls the menu item with the provided symbol.\n" + "To obtain all available symbols, use get_menu_symbols.\n" "\n" - "This method has been added in version 0.22.\n" - ) + - gsi::method ("cm_unselect_all", &lay::MainWindow::cm_unselect_all, - "@brief 'cm_unselect_all' action (bound to a menu)" - "\n" - "This method has been added in version 0.22.\n" - ) + - gsi::method ("cm_undo", &lay::MainWindow::cm_undo, - "@brief 'cm_undo' action (bound to a menu)" - ) + - gsi::method ("cm_redo", &lay::MainWindow::cm_redo, - "@brief 'cm_redo' action (bound to a menu)" - ) + - gsi::method ("cm_delete", &lay::MainWindow::cm_delete, - "@brief 'cm_delete' action (bound to a menu)" - ) + - gsi::method ("cm_show_properties", &lay::MainWindow::cm_show_properties, - "@brief 'cm_show_properties' action (bound to a menu)" - ) + - gsi::method ("cm_copy", &lay::MainWindow::cm_copy, - "@brief 'cm_copy' action (bound to a menu)" - ) + - gsi::method ("cm_paste", &lay::MainWindow::cm_paste, - "@brief 'cm_paste' action (bound to a menu)" - ) + - gsi::method ("cm_cut", &lay::MainWindow::cm_cut, - "@brief 'cm_cut' action (bound to a menu)" - ) + - gsi::method ("cm_zoom_fit_sel", &lay::MainWindow::cm_zoom_fit, - "@brief 'cm_zoom_fit_sel' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_zoom_fit", &lay::MainWindow::cm_zoom_fit, - "@brief 'cm_zoom_fit' action (bound to a menu)" - ) + - gsi::method ("cm_zoom_in", &lay::MainWindow::cm_zoom_in, - "@brief 'cm_zoom_in' action (bound to a menu)" - ) + - gsi::method ("cm_zoom_out", &lay::MainWindow::cm_zoom_out, - "@brief 'cm_zoom_out' action (bound to a menu)" - ) + - gsi::method ("cm_pan_up", &lay::MainWindow::cm_pan_up, - "@brief 'cm_pan_up' action (bound to a menu)" - ) + - gsi::method ("cm_pan_down", &lay::MainWindow::cm_pan_down, - "@brief 'cm_pan_down' action (bound to a menu)" - ) + - gsi::method ("cm_pan_left", &lay::MainWindow::cm_pan_left, - "@brief 'cm_pan_left' action (bound to a menu)" - ) + - gsi::method ("cm_pan_right", &lay::MainWindow::cm_pan_right, - "@brief 'cm_pan_right' action (bound to a menu)" - ) + - gsi::method ("cm_save_session", &lay::MainWindow::cm_save_session, - "@brief 'cm_save_session' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_restore_session", &lay::MainWindow::cm_restore_session, - "@brief 'cm_restore_session' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_setup", &lay::MainWindow::cm_setup, - "@brief 'cm_setup' action (bound to a menu)" - ) + - gsi::method ("cm_save_as", &lay::MainWindow::cm_save_as, - "@brief 'cm_save_as' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_save", &lay::MainWindow::cm_save, - "@brief 'cm_save' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_save_all", &lay::MainWindow::cm_save_all, - "@brief 'cm_save_all' action (bound to a menu)\n" - "This method has been added in version 0.24.\n" - ) + - gsi::method ("cm_reload", &lay::MainWindow::cm_reload, - "@brief 'cm_reload' action (bound to a menu)" - ) + - gsi::method ("cm_close", &lay::MainWindow::cm_close, - "@brief 'cm_close' action (bound to a menu)" - ) + - gsi::method ("cm_close_all", &lay::MainWindow::cm_close_all, - "@brief 'cm_close_all' action (bound to a menu)\n" - "This method has been added in version 0.24.\n" - ) + - gsi::method ("cm_clone", &lay::MainWindow::cm_clone, - "@brief 'cm_clone' action (bound to a menu)" - ) + - gsi::method ("cm_layout_props", &lay::MainWindow::cm_layout_props, - "@brief 'cm_layout_props' action (bound to a menu)" - ) + - gsi::method ("cm_inc_max_hier", &lay::MainWindow::cm_inc_max_hier, - "@brief 'cm_inc_max_hier' action (bound to a menu)" - ) + - gsi::method ("cm_dec_max_hier", &lay::MainWindow::cm_dec_max_hier, - "@brief 'cm_dec_max_hier' action (bound to a menu)" - ) + - gsi::method ("cm_max_hier", &lay::MainWindow::cm_max_hier, - "@brief 'cm_max_hier' action (bound to a menu)" - ) + - gsi::method ("cm_max_hier_0", &lay::MainWindow::cm_max_hier_0, - "@brief 'cm_max_hier_0' action (bound to a menu)" - ) + - gsi::method ("cm_max_hier_1", &lay::MainWindow::cm_max_hier_1, - "@brief 'cm_max_hier_1' action (bound to a menu)" - ) + - gsi::method ("cm_prev_display_state|#cm_last_display_state", &lay::MainWindow::cm_prev_display_state, - "@brief 'cm_prev_display_state' action (bound to a menu)" - ) + - gsi::method ("cm_next_display_state", &lay::MainWindow::cm_next_display_state, - "@brief 'cm_next_display_state' action (bound to a menu)" - ) + - gsi::method ("cm_cancel", &lay::MainWindow::cm_cancel, - "@brief 'cm_cancel' action (bound to a menu)" - ) + - gsi::method ("cm_redraw", &lay::MainWindow::cm_redraw, - "@brief 'cm_redraw' action (bound to a menu)" - ) + - gsi::method ("cm_screenshot", &lay::MainWindow::cm_screenshot, - "@brief 'cm_screenshot' action (bound to a menu)" - ) + - gsi::method ("cm_save_layer_props", &lay::MainWindow::cm_save_layer_props, - "@brief 'cm_save_layer_props' action (bound to a menu)" - ) + - gsi::method ("cm_load_layer_props", &lay::MainWindow::cm_load_layer_props, - "@brief 'cm_load_layer_props' action (bound to a menu)" - ) + - gsi::method ("cm_save_bookmarks", &lay::MainWindow::cm_save_bookmarks, - "@brief 'cm_save_bookmarks' action (bound to a menu)" - ) + - gsi::method ("cm_load_bookmarks", &lay::MainWindow::cm_load_bookmarks, - "@brief 'cm_load_bookmarks' action (bound to a menu)" - ) + - gsi::method ("cm_select_cell", &lay::MainWindow::cm_select_cell, - "@brief 'cm_select_cell' action (bound to a menu)" - ) + - gsi::method ("cm_select_current_cell", &lay::MainWindow::cm_select_current_cell, - "@brief 'cm_select_current_cell' action (bound to a menu)" - ) + - gsi::method ("cm_print", &lay::MainWindow::cm_print, - "@brief 'cm_print' action (bound to a menu)\n" - "This method has been added in version 0.21.13." - ) + - gsi::method ("cm_exit", &lay::MainWindow::cm_exit, - "@brief 'cm_exit' action (bound to a menu)" - ) + - gsi::method ("cm_view_log", &lay::MainWindow::cm_view_log, - "@brief 'cm_view_log' action (bound to a menu)" - "\nThis method has been added in version 0.20." - ) + - gsi::method ("cm_bookmark_view", &lay::MainWindow::cm_bookmark_view, - "@brief 'cm_bookmark_view' action (bound to a menu)" - ) + - gsi::method ("cm_manage_bookmarks", &lay::MainWindow::cm_manage_bookmarks, - "@brief 'cm_manage_bookmarks' action (bound to a menu)" - ) + - gsi::method ("cm_macro_editor", &lay::MainWindow::cm_macro_editor, - "@brief 'cm_macro_editor' action (bound to a menu)" - ) + - gsi::method ("cm_goto_position", &lay::MainWindow::cm_goto_position, - "@brief 'cm_goto_position' action (bound to a menu)" - ) + - gsi::method ("cm_help_about", &lay::MainWindow::cm_help_about, - "@brief 'cm_help_about' action (bound to a menu)" - ) + - gsi::method ("cm_technologies", &lay::MainWindow::cm_technologies, - "@brief 'cm_technologies' action (bound to a menu)" - "\nThis method has been added in version 0.22." - ) + - gsi::method ("cm_packages", &lay::MainWindow::cm_packages, - "@brief 'cm_packages' action (bound to a menu)" - "\nThis method has been added in version 0.25." - ) + - gsi::method ("cm_open_too", &lay::MainWindow::cm_open_too, - "@brief 'cm_open_too' action (bound to a menu)" - ) + - gsi::method ("cm_open_new_view", &lay::MainWindow::cm_open_new_view, - "@brief 'cm_open_new_view' action (bound to a menu)" - ) + - gsi::method ("cm_open", &lay::MainWindow::cm_open, - "@brief 'cm_open' action (bound to a menu)" - ) + - gsi::method ("cm_pull_in", &lay::MainWindow::cm_pull_in, - "@brief 'cm_pull_in' action (bound to a menu)" - "\nThis method has been added in version 0.20." - ) + - gsi::method ("cm_reader_options", &lay::MainWindow::cm_reader_options, - "@brief 'cm_reader_options' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_new_layout", &lay::MainWindow::cm_new_layout, - "@brief 'cm_new_layout' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_new_panel", &lay::MainWindow::cm_new_panel, - "@brief 'cm_new_panel' action (bound to a menu)" - "\nThis method has been added in version 0.20." - ) + - gsi::method ("cm_adjust_origin", &lay::MainWindow::cm_adjust_origin, - "@brief 'cm_adjust_origin' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_new_cell", &lay::MainWindow::cm_new_cell, - "@brief 'cm_new_cell' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_new_layer", &lay::MainWindow::cm_new_layer, - "@brief 'cm_new_layer' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_clear_layer", &lay::MainWindow::cm_clear_layer, - "@brief 'cm_clear_layer' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_delete_layer", &lay::MainWindow::cm_delete_layer, - "@brief 'cm_delete_layer' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_edit_layer", &lay::MainWindow::cm_edit_layer, - "@brief 'cm_edit_layer' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_copy_layer", &lay::MainWindow::cm_copy_layer, - "@brief 'cm_copy_layer' action (bound to a menu)" - "\nThis method has been added in version 0.22." - ) + - gsi::method ("cm_sel_flip_x", &lay::MainWindow::cm_sel_flip_x, - "@brief 'cm_sel_flip_x' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_sel_flip_y", &lay::MainWindow::cm_sel_flip_y, - "@brief 'cm_sel_flip_y' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_sel_rot_cw", &lay::MainWindow::cm_sel_rot_cw, - "@brief 'cm_sel_rot_cw' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_sel_rot_ccw", &lay::MainWindow::cm_sel_rot_ccw, - "@brief 'cm_sel_rot_ccw' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_sel_free_rot", &lay::MainWindow::cm_sel_free_rot, - "@brief 'cm_sel_free_rot' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_sel_scale", &lay::MainWindow::cm_sel_scale, - "@brief 'cm_sel_scale' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_sel_move", &lay::MainWindow::cm_sel_move, - "@brief 'cm_sel_move' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_sel_move_to", &lay::MainWindow::cm_sel_move_to, - "@brief 'cm_sel_move_to' action (bound to a menu)" - "\nThis method has been added in version 0.24." - ) + - gsi::method ("cm_lv_new_tab", &lay::MainWindow::cm_lv_new_tab, - "@brief 'cm_lv_new_tab' action (bound to a menu)" - ) + - gsi::method ("cm_lv_remove_tab", &lay::MainWindow::cm_lv_remove_tab, - "@brief 'cm_lv_remove_tab' action (bound to a menu)" - ) + - gsi::method ("cm_lv_rename_tab", &lay::MainWindow::cm_lv_rename_tab, - "@brief 'cm_lv_rename_tab' action (bound to a menu)" - ) + - gsi::method ("cm_lv_hide", &lay::MainWindow::cm_lv_hide, - "@brief 'cm_lv_hide' action (bound to a menu)" - ) + - gsi::method ("cm_lv_hide_all", &lay::MainWindow::cm_lv_hide_all, - "@brief 'cm_lv_hide_all' action (bound to a menu)" - ) + - gsi::method ("cm_lv_show", &lay::MainWindow::cm_lv_show, - "@brief 'cm_lv_show' action (bound to a menu)" - ) + - gsi::method ("cm_lv_show_all", &lay::MainWindow::cm_lv_show_all, - "@brief 'cm_lv_show_all' action (bound to a menu)" - ) + - gsi::method ("cm_lv_show_only", &lay::MainWindow::cm_lv_show_only, - "@brief 'cm_lv_show_only' action (bound to a menu)" - "\nThis method has been added in version 0.20." - ) + - gsi::method ("cm_lv_rename", &lay::MainWindow::cm_lv_rename, - "@brief 'cm_lv_rename' action (bound to a menu)" - ) + - gsi::method ("cm_lv_select_all", &lay::MainWindow::cm_lv_select_all, - "@brief 'cm_lv_select_all' action (bound to a menu)" - ) + - gsi::method ("cm_lv_delete", &lay::MainWindow::cm_lv_delete, - "@brief 'cm_lv_delete' action (bound to a menu)" - ) + - gsi::method ("cm_lv_insert", &lay::MainWindow::cm_lv_insert, - "@brief 'cm_lv_insert' action (bound to a menu)" - ) + - gsi::method ("cm_lv_group", &lay::MainWindow::cm_lv_group, - "@brief 'cm_lv_group' action (bound to a menu)" - ) + - gsi::method ("cm_lv_ungroup", &lay::MainWindow::cm_lv_ungroup, - "@brief 'cm_lv_ungroup' action (bound to a menu)" - ) + - gsi::method ("cm_lv_source", &lay::MainWindow::cm_lv_source, - "@brief 'cm_lv_source' action (bound to a menu)" - ) + - gsi::method ("cm_lv_sort_by_name", &lay::MainWindow::cm_lv_sort_by_name, - "@brief 'cm_lv_sort_by_name' action (bound to a menu)" - ) + - gsi::method ("cm_lv_sort_by_ild", &lay::MainWindow::cm_lv_sort_by_ild, - "@brief 'cm_lv_sort_by_ild' action (bound to a menu)" - ) + - gsi::method ("cm_lv_sort_by_idl", &lay::MainWindow::cm_lv_sort_by_idl, - "@brief 'cm_lv_sort_by_idl' action (bound to a menu)" - ) + - gsi::method ("cm_lv_sort_by_ldi", &lay::MainWindow::cm_lv_sort_by_ldi, - "@brief 'cm_lv_sort_by_ldi' action (bound to a menu)" - ) + - gsi::method ("cm_lv_sort_by_dli", &lay::MainWindow::cm_lv_sort_by_dli, - "@brief 'cm_lv_sort_by_dli' action (bound to a menu)" - ) + - gsi::method ("cm_lv_regroup_by_index", &lay::MainWindow::cm_lv_regroup_by_index, - "@brief 'cm_lv_regroup_by_index' action (bound to a menu)" - ) + - gsi::method ("cm_lv_regroup_by_datatype", &lay::MainWindow::cm_lv_regroup_by_datatype, - "@brief 'cm_lv_regroup_by_datatype' action (bound to a menu)" - ) + - gsi::method ("cm_lv_regroup_by_layer", &lay::MainWindow::cm_lv_regroup_by_layer, - "@brief 'cm_lv_regroup_by_layer' action (bound to a menu)" - ) + - gsi::method ("cm_lv_regroup_flatten", &lay::MainWindow::cm_lv_regroup_flatten, - "@brief 'cm_lv_regroup_flatten' action (bound to a menu)" - ) + - gsi::method ("cm_lv_expand_all", &lay::MainWindow::cm_lv_expand_all, - "@brief 'cm_lv_expand_all' action (bound to a menu)" - ) + - gsi::method ("cm_lv_add_missing", &lay::MainWindow::cm_lv_add_missing, - "@brief 'cm_lv_add_missing' action (bound to a menu)" - ) + - gsi::method ("cm_lv_remove_unused", &lay::MainWindow::cm_lv_remove_unused, - "@brief 'cm_lv_remove_unused' action (bound to a menu)" - ) + - gsi::method ("cm_cell_delete", &lay::MainWindow::cm_cell_delete, - "@brief 'cm_cell_delete' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_cell_rename", &lay::MainWindow::cm_cell_rename, - "@brief 'cm_cell_rename' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_cell_copy", &lay::MainWindow::cm_cell_copy, - "@brief 'cm_cell_copy' action (bound to a menu)" - "\nThis method has been added in version 0.20." - ) + - gsi::method ("cm_cell_cut", &lay::MainWindow::cm_cell_cut, - "@brief 'cm_cell_cut' action (bound to a menu)" - "\nThis method has been added in version 0.20." - ) + - gsi::method ("cm_cell_paste", &lay::MainWindow::cm_cell_paste, - "@brief 'cm_cell_paste' action (bound to a menu)" - "\nThis method has been added in version 0.20." - ) + - gsi::method ("cm_cell_select", &lay::MainWindow::cm_cell_select, - "@brief 'cm_cell_select' action (bound to a menu)" - ) + - gsi::method ("cm_open_current_cell", &lay::MainWindow::cm_open_current_cell, - "@brief 'cm_open_current_cell' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_save_current_cell_as", &lay::MainWindow::cm_save_current_cell_as, - "@brief 'cm_save_current_cell_as' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_cell_hide", &lay::MainWindow::cm_cell_hide, - "@brief 'cm_cell_hide' action (bound to a menu)" - ) + - gsi::method ("cm_cell_flatten", &lay::MainWindow::cm_cell_flatten, - "@brief 'cm_cell_flatten' action (bound to a menu)" - ) + - gsi::method ("cm_cell_show", &lay::MainWindow::cm_cell_show, - "@brief 'cm_cell_show' action (bound to a menu)" - ) + - gsi::method ("cm_cell_show_all", &lay::MainWindow::cm_cell_show_all, - "@brief 'cm_cell_show_all' action (bound to a menu)" - ) + - gsi::method ("cm_navigator_close", &lay::MainWindow::cm_navigator_close, - "@brief 'cm_navigator_close' action (bound to a menu)" - ) + - gsi::method ("cm_navigator_freeze", &lay::MainWindow::cm_navigator_freeze, - "@brief 'cm_navigator_freeze' action (bound to a menu)" - ), - + "This method has been introduced in version 0.27." + ) + + // backward compatibility (cm_... methods, deprecated) + cm_method_decl<0> () + + cm_method_decl<1> () + + cm_method_decl<2> () + + cm_method_decl<3> () + + cm_method_decl<4> () + + cm_method_decl<5> () + + cm_method_decl<6> () + + cm_method_decl<7> () + + cm_method_decl<8> () + + cm_method_decl<9> () + + cm_method_decl<10> () + + cm_method_decl<11> () + + cm_method_decl<12> () + + cm_method_decl<13> () + + cm_method_decl<14> () + + cm_method_decl<15> () + + cm_method_decl<16> () + + cm_method_decl<17> () + + cm_method_decl<18> () + + cm_method_decl<19> () + + cm_method_decl<20> () + + cm_method_decl<21> () + + cm_method_decl<22> () + + cm_method_decl<23> () + + cm_method_decl<24> () + + cm_method_decl<25> () + + cm_method_decl<26> () + + cm_method_decl<27> () + + cm_method_decl<28> () + + cm_method_decl<29> () + + cm_method_decl<30> () + + cm_method_decl<31> () + + cm_method_decl<32> () + + cm_method_decl<33> () + + cm_method_decl<34> () + + cm_method_decl<35> () + + cm_method_decl<36> () + + cm_method_decl<37> () + + cm_method_decl<38> () + + cm_method_decl<39> () + + cm_method_decl<40> () + + cm_method_decl<41> () + + cm_method_decl<42> () + + cm_method_decl<43> () + + cm_method_decl<44> () + + cm_method_decl<45> () + + cm_method_decl<46> () + + cm_method_decl<47> () + + cm_method_decl<48> () + + cm_method_decl<49> () + + cm_method_decl<50> () + + cm_method_decl<51> () + + cm_method_decl<52> () + + cm_method_decl<53> () + + cm_method_decl<54> () + + cm_method_decl<55> () + + cm_method_decl<56> () + + cm_method_decl<57> () + + cm_method_decl<58> () + + cm_method_decl<59> () + + cm_method_decl<60> () + + cm_method_decl<61> () + + cm_method_decl<62> () + + cm_method_decl<63> () + + cm_method_decl<64> () + + cm_method_decl<65> () + + cm_method_decl<66> () + + cm_method_decl<67> () + + cm_method_decl<68> () + + cm_method_decl<69> () + + cm_method_decl<70> () + + cm_method_decl<71> () + + cm_method_decl<72> () + + cm_method_decl<73> () + + cm_method_decl<74> () + + cm_method_decl<75> () + + cm_method_decl<76> () + + cm_method_decl<77> () + + cm_method_decl<78> () + + cm_method_decl<79> () + + cm_method_decl<80> () + + cm_method_decl<81> () + + cm_method_decl<82> () + + cm_method_decl<83> () + + cm_method_decl<84> () + + cm_method_decl<85> () + + cm_method_decl<86> () + + cm_method_decl<87> () + + cm_method_decl<88> () + + cm_method_decl<89> () + + cm_method_decl<90> () + + cm_method_decl<91> () + + cm_method_decl<92> () + + cm_method_decl<93> () + + cm_method_decl<94> () + + cm_method_decl<95> () + + cm_method_decl<96> () + + cm_method_decl<97> () + + cm_method_decl<98> () + + cm_method_decl<99> () + + cm_method_decl<100> () + + cm_method_decl<101> () + + cm_method_decl<102> () + + cm_method_decl<103> () + + cm_method_decl<104> () + + cm_method_decl<105> () + + cm_method_decl<106> () + + cm_method_decl<107> () + + cm_method_decl<108> () + + cm_method_decl<109> () + + cm_method_decl<110> () + + cm_method_decl<111> () + + cm_method_decl<112> () + + cm_method_decl<113> () + + cm_method_decl<114> () + + cm_method_decl<115> () + + cm_method_decl<116> () + + cm_method_decl<117> (), "@brief The main application window and central controller object\n" "\n" "This object first is the main window but also the main controller. The main controller " diff --git a/src/lay/lay/lay.pro b/src/lay/lay/lay.pro index a4599dfca..b5c376219 100644 --- a/src/lay/lay/lay.pro +++ b/src/lay/lay/lay.pro @@ -15,7 +15,6 @@ HEADERS = \ layHelpDialog.h \ layHelpProvider.h \ layHelpSource.h \ - layLayoutStatisticsForm.h \ layLogViewerDialog.h \ layMacroEditorDialog.h \ layMacroEditorPage.h \ @@ -32,7 +31,6 @@ HEADERS = \ laySearchReplaceConfigPage.h \ laySearchReplaceDialog.h \ laySearchReplacePropertiesWidgets.h \ - laySelectCellViewForm.h \ laySession.h \ laySettingsForm.h \ layTechSetupDialog.h \ @@ -68,7 +66,6 @@ FORMS = \ DeleteModeDialog.ui \ FillDialog.ui \ HelpAboutDialog.ui \ - LayoutStatistics.ui \ LogViewerDialog.ui \ MacroEditorDialog.ui \ MacroPropertiesDialog.ui \ @@ -122,7 +119,6 @@ SOURCES = \ layHelpDialog.cc \ layHelpProvider.cc \ layHelpSource.cc \ - layLayoutStatisticsForm.cc \ layLogViewerDialog.cc \ layMacroEditorDialog.cc \ layMacroEditorPage.cc \ diff --git a/src/lay/lay/layApplication.cc b/src/lay/lay/layApplication.cc index 5e2b13b15..33f7dc0c4 100644 --- a/src/lay/lay/layApplication.cc +++ b/src/lay/lay/layApplication.cc @@ -1483,7 +1483,7 @@ GuiApplication::setup () { tl_assert (mp_mw == 0 && mp_plugin_root == 0); - mp_plugin_root = new lay::PluginRootToMainWindow (); + mp_plugin_root = new lay::DispatcherToMainWindow (); mp_mw = new lay::MainWindow (this, mp_plugin_root, "main_window", is_undo_enabled ()); mp_plugin_root->attach_to (mp_mw); diff --git a/src/lay/lay/layApplication.h b/src/lay/lay/layApplication.h index 8ef31e2d5..b121138b2 100644 --- a/src/lay/lay/layApplication.h +++ b/src/lay/lay/layApplication.h @@ -57,7 +57,7 @@ namespace lay { class MainWindow; -class PluginRootToMainWindow; +class DispatcherToMainWindow; class PluginRoot; class ProgressReporter; class ProgressBar; @@ -445,7 +445,7 @@ protected: private: MainWindow *mp_mw; - PluginRootToMainWindow *mp_plugin_root; + DispatcherToMainWindow *mp_plugin_root; gtf::Recorder *mp_recorder; }; diff --git a/src/lay/lay/layMacroController.h b/src/lay/lay/layMacroController.h index 5f00b4686..13cd5dd3e 100644 --- a/src/lay/lay/layMacroController.h +++ b/src/lay/lay/layMacroController.h @@ -89,12 +89,12 @@ public: /** * @brief Reimplementation of the PluginDeclaration interface */ - virtual void initialized (lay::PluginRoot *root); + virtual void initialized (lay::Dispatcher *root); /** * @brief Reimplementation of the PluginDeclaration interface */ - virtual void uninitialize (lay::PluginRoot *root); + virtual void uninitialize (lay::Dispatcher *root); /** * @brief Reimplementation of the PluginDeclaration interface @@ -109,7 +109,7 @@ public: /** * @brief Reimplementation of the PluginDeclaration interface */ - virtual bool can_exit (lay::PluginRoot *root) const; + virtual bool can_exit (lay::Dispatcher *root) const; /** * @brief Gets a value indicating whether the plugin will accept a dropped file with the given URL or path diff --git a/src/lay/lay/layMainConfigPages.h b/src/lay/lay/layMainConfigPages.h index 6a88bae83..6401546f8 100644 --- a/src/lay/lay/layMainConfigPages.h +++ b/src/lay/lay/layMainConfigPages.h @@ -59,8 +59,8 @@ public: MainConfigPage (QWidget *parent); ~MainConfigPage (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::MainConfigPage *mp_ui; @@ -75,8 +75,8 @@ public: MainConfigPage2 (QWidget *parent); ~MainConfigPage2 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::MainConfigPage2 *mp_ui; @@ -91,8 +91,8 @@ public: MainConfigPage3 (QWidget *parent); ~MainConfigPage3 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::MainConfigPage3 *mp_ui; @@ -107,8 +107,8 @@ public: MainConfigPage4 (QWidget *parent); ~MainConfigPage4 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::MainConfigPage4 *mp_ui; @@ -123,8 +123,8 @@ public: MainConfigPage5 (QWidget *parent); ~MainConfigPage5 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::MainConfigPage5 *mp_ui; @@ -139,8 +139,8 @@ public: MainConfigPage6 (QWidget *parent); ~MainConfigPage6 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::MainConfigPage6 *mp_ui; @@ -155,8 +155,8 @@ public: MainConfigPage7 (QWidget *parent); ~MainConfigPage7 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::MainConfigPage7 *mp_ui; @@ -171,8 +171,8 @@ public: CustomizeMenuConfigPage (QWidget *parent); ~CustomizeMenuConfigPage (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private slots: void current_changed (QTreeWidgetItem *current, QTreeWidgetItem *previous); diff --git a/src/lay/lay/layMainWindow.cc b/src/lay/lay/layMainWindow.cc index be39fa22b..74560e83e 100644 --- a/src/lay/lay/layMainWindow.cc +++ b/src/lay/lay/layMainWindow.cc @@ -64,7 +64,6 @@ #include "layApplication.h" #include "layVersion.h" #include "layConverters.h" -#include "layCellSelectionForm.h" #include "layDialogs.h" #include "laybasicConfig.h" #include "layConfig.h" @@ -85,12 +84,10 @@ #include "layLogViewerDialog.h" #include "layLayerToolbox.h" #include "laySettingsForm.h" +#include "laySelectCellViewForm.h" #include "layTechnologyController.h" #include "laySaltController.h" #include "layTipDialog.h" -#include "laySelectCellViewForm.h" -#include "layLayoutPropertiesForm.h" -#include "layLayoutStatisticsForm.h" #include "layMacroController.h" #include "layInit.h" #include "antObject.h" @@ -421,7 +418,7 @@ MainWindow::instance () MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const char *name, bool undo_enabled) : QMainWindow (0), - lay::Plugin (plugin_parent), + lay::Dispatcher (plugin_parent, false), m_text_progress (this, 10 /*verbosity threshold*/), m_mode (std::numeric_limits::max ()), mp_setup_form (0), @@ -433,13 +430,12 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha dm_exit (this, &MainWindow::exit), m_grid_micron (0.001), m_default_grids_updated (true), - m_new_cell_window_size (2.0), m_new_layout_current_panel (false), m_synchronized_views (false), m_synchronous (false), m_busy (false), mp_app (app), - m_manager (true) + m_manager (undo_enabled) { // ensures the deferred method scheduler is present tl::DeferredMethodScheduler::instance (); @@ -453,7 +449,7 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha lay::register_help_handler (this, SLOT (show_help (const QString &)), SLOT (show_modal_help (const QString &))); - mp_setup_form = new SettingsForm (0, plugin_root (), "setup_form"), + mp_setup_form = new SettingsForm (0, dispatcher (), "setup_form"), db::LibraryManager::instance ().changed_event.add (this, &MainWindow::libraries_changed); @@ -557,9 +553,9 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha QMenuBar *mbar = menuBar (); mbar->setObjectName (QString::fromUtf8 ("menubar")); - mp_menu->build (mbar, mp_tool_bar); + menu ()->build (mbar, mp_tool_bar); - connect (mp_menu, SIGNAL (changed ()), this, SLOT (menu_changed ())); + connect (menu (), SIGNAL (changed ()), this, SLOT (menu_changed ())); mp_status_bar = statusBar (); mp_status_bar->setObjectName (QString::fromUtf8 ("status_bar")); @@ -708,7 +704,7 @@ MainWindow::~MainWindow () // since the configuration actions unregister themselves, we need to do this before the main // window is gone: - m_ca_collection.clear (); + clear_configuration_actions (); mw_instance = 0; @@ -720,9 +716,6 @@ MainWindow::~MainWindow () // delete the Menu after the views because they may want to access them in the destructor - delete mp_menu; - mp_menu = 0; - delete mp_pr; mp_pr = 0; @@ -739,332 +732,17 @@ MainWindow::~MainWindow () void MainWindow::init_menu () { - // default menu layout - - MenuLayoutEntry secret_menu [] = { - MenuLayoutEntry ("paste_interactive:edit", tl::to_string (QObject::tr ("Paste Interactive")), SLOT (cm_paste_interactive ())), - MenuLayoutEntry ("duplicate_interactive:edit", tl::to_string (QObject::tr ("Duplicate Interactive")), SLOT (cm_duplicate_interactive ())), - MenuLayoutEntry ("sel_move_interactive", tl::to_string (QObject::tr ("Move Interactive")), SLOT (cm_sel_move_interactive ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry empty_menu [] = { - MenuLayoutEntry::last () - }; - - MenuLayoutEntry file_menu [] = { - MenuLayoutEntry ("new_layout:edit:edit_mode", tl::to_string (QObject::tr ("New Layout")), SLOT (cm_new_layout ())), - MenuLayoutEntry ("new_panel:edit:edit_mode", tl::to_string (QObject::tr ("New Panel")), SLOT (cm_new_panel ())), - MenuLayoutEntry::separator ("post_new_group:edit_mode"), - MenuLayoutEntry ("open:edit", tl::to_string (QObject::tr ("Open")), SLOT (cm_open ())), - MenuLayoutEntry ("open_same_panel:edit", tl::to_string (QObject::tr ("Open In Same Panel(Shift+Ctrl+O)")), SLOT (cm_open_too ())), - MenuLayoutEntry ("open_new_panel", tl::to_string (QObject::tr ("Open In New Panel(Ctrl+O)")), SLOT (cm_open_new_view ())), - MenuLayoutEntry ("close:edit", tl::to_string (QObject::tr ("Close(Ctrl+W)")), SLOT (cm_close ())), - MenuLayoutEntry ("close_all:edit", tl::to_string (QObject::tr ("Close All(Shift+Ctrl+W)")), SLOT (cm_close_all ())), - MenuLayoutEntry ("clone", tl::to_string (QObject::tr ("Clone Panel")), SLOT (cm_clone ())), - MenuLayoutEntry ("reload:edit", tl::to_string (QObject::tr ("Reload(Ctrl+R)")), SLOT (cm_reload ())), - MenuLayoutEntry ("pull_in:edit", tl::to_string (QObject::tr ("Pull In Other Layout")), SLOT (cm_pull_in ())), - MenuLayoutEntry ("reader_options", tl::to_string (QObject::tr ("Reader Options")), SLOT (cm_reader_options ())), - MenuLayoutEntry::separator ("open_recent_group"), - MenuLayoutEntry ("open_recent_menu:edit", tl::to_string (QObject::tr ("Open Recent")), empty_menu), - MenuLayoutEntry::separator ("import_group"), - MenuLayoutEntry ("import_menu:edit", tl::to_string (QObject::tr ("Import")), empty_menu), - MenuLayoutEntry::separator ("save_group"), - MenuLayoutEntry ("save:hide_vo", tl::to_string (QObject::tr ("Save")), SLOT (cm_save ())), - MenuLayoutEntry ("save_as:hide_vo", tl::to_string (QObject::tr ("Save As")), SLOT (cm_save_as ())), - MenuLayoutEntry ("save_all:hide_vo", tl::to_string (QObject::tr ("Save All")), SLOT (cm_save_all ())), - MenuLayoutEntry ("writer_options:hide_vo", tl::to_string (QObject::tr ("Writer Options")), SLOT (cm_writer_options ())), - MenuLayoutEntry::separator ("setup_group"), - MenuLayoutEntry ("setup:edit", tl::to_string (QObject::tr ("Setup")), SLOT (cm_setup ())), - MenuLayoutEntry::separator ("misc_group"), - MenuLayoutEntry ("screenshot:edit", tl::to_string (QObject::tr ("Screenshot(Print)")), SLOT (cm_screenshot ())), - MenuLayoutEntry ("layout_props:edit", tl::to_string (QObject::tr ("Layout Properties")), SLOT (cm_layout_props ())), - MenuLayoutEntry ("layout_stats:edit", tl::to_string (QObject::tr ("Layout Statistics")), SLOT (cm_layout_stats ())), - MenuLayoutEntry::separator ("layer_group"), - MenuLayoutEntry ("load_layer_props:edit", tl::to_string (QObject::tr ("Load Layer Properties")), SLOT (cm_load_layer_props ())), - MenuLayoutEntry ("save_layer_props:edit", tl::to_string (QObject::tr ("Save Layer Properties")), SLOT (cm_save_layer_props ())), - MenuLayoutEntry::separator ("session_group"), - MenuLayoutEntry ("restore_session:edit", tl::to_string (QObject::tr ("Restore Session")), SLOT (cm_restore_session ())), - MenuLayoutEntry ("save_session", tl::to_string (QObject::tr ("Save Session")), SLOT (cm_save_session ())), - MenuLayoutEntry::separator ("log_group"), - MenuLayoutEntry ("view_log", tl::to_string (QObject::tr ("Log Viewer")), SLOT (cm_view_log ())), - MenuLayoutEntry::separator ("print_group"), - MenuLayoutEntry ("print", tl::to_string (QObject::tr ("Print(Ctrl+P)")), SLOT (cm_print ())), - MenuLayoutEntry::separator ("exit_group"), - MenuLayoutEntry ("exit", tl::to_string (QObject::tr ("Exit(Ctrl+Q)")), SLOT (cm_exit ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry edit_utilities_menu [] = { - MenuLayoutEntry::last () - }; - - MenuLayoutEntry edit_layout_menu [] = { - MenuLayoutEntry ("lay_flip_x:edit_mode", tl::to_string (QObject::tr ("Flip Horizontally")), SLOT (cm_lay_flip_x ())), - MenuLayoutEntry ("lay_flip_y:edit_mode", tl::to_string (QObject::tr ("Flip Vertically")), SLOT (cm_lay_flip_y ())), - MenuLayoutEntry ("lay_rot_cw:edit_mode", tl::to_string (QObject::tr ("Rotate Clockwise")), SLOT (cm_lay_rot_cw ())), - MenuLayoutEntry ("lay_rot_ccw:edit_mode", tl::to_string (QObject::tr ("Rotate Counterclockwise")), SLOT (cm_lay_rot_ccw ())), - MenuLayoutEntry ("lay_free_rot:edit_mode", tl::to_string (QObject::tr ("Rotation By Angle")), SLOT (cm_lay_free_rot ())), - MenuLayoutEntry ("lay_scale:edit_mode", tl::to_string (QObject::tr ("Scale")), SLOT (cm_lay_scale ())), - MenuLayoutEntry ("lay_move:edit_mode", tl::to_string (QObject::tr ("Move By")), SLOT (cm_lay_move ())), - MenuLayoutEntry::separator ("cellop_group"), - MenuLayoutEntry ("lay_convert_to_static:edit_mode", tl::to_string (QObject::tr ("Convert All Cells To Static")), SLOT (cm_lay_convert_to_static ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry edit_cell_menu [] = { - MenuLayoutEntry ("new_cell:edit:edit_mode", tl::to_string (QObject::tr ("New Cell")), SLOT (cm_new_cell ())), - MenuLayoutEntry ("delete_cell:edit:edit_mode", tl::to_string (QObject::tr ("Delete Cell")), SLOT (cm_cell_delete ())), - MenuLayoutEntry ("rename_cell:edit:edit_mode", tl::to_string (QObject::tr ("Rename Cell")), SLOT (cm_cell_rename ())), - MenuLayoutEntry ("replace_cell:edit:edit_mode", tl::to_string (QObject::tr ("Replace Cell")), SLOT (cm_cell_replace ())), - MenuLayoutEntry ("flatten_cell:edit:edit_mode", tl::to_string (QObject::tr ("Flatten Cell")), SLOT (cm_cell_flatten ())), - MenuLayoutEntry::separator ("ops_group"), - MenuLayoutEntry ("adjust_cell_origin:edit:edit_mode", tl::to_string (QObject::tr ("Adjust Origin")), SLOT (cm_adjust_origin ())), - MenuLayoutEntry ("convert_cell_to_static:edit_mode", tl::to_string (QObject::tr ("Convert Cell To Static")), SLOT (cm_cell_convert_to_static ())), - MenuLayoutEntry::separator ("props_group"), - MenuLayoutEntry ("user_properties", tl::to_string (QObject::tr ("User Properties")), SLOT (cm_cell_user_properties ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry edit_layer_menu [] = { - MenuLayoutEntry ("new_layer:edit:edit_mode", tl::to_string (QObject::tr ("New Layer")), SLOT (cm_new_layer ())), - MenuLayoutEntry ("clear_layer:edit:edit_mode", tl::to_string (QObject::tr ("Clear Layer")), SLOT (cm_clear_layer ())), - MenuLayoutEntry ("delete_layer:edit:edit_mode", tl::to_string (QObject::tr ("Delete Layer")), SLOT (cm_delete_layer ())), - MenuLayoutEntry ("copy_layer:edit:edit_mode", tl::to_string (QObject::tr ("Copy Layer")), SLOT (cm_copy_layer ())), - MenuLayoutEntry ("edit_layer:edit:edit_mode", tl::to_string (QObject::tr ("Edit Layer Specification")), SLOT (cm_edit_layer ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry edit_selection_menu [] = { - MenuLayoutEntry ("sel_flip_x", tl::to_string (QObject::tr ("Flip Horizontally")), SLOT (cm_sel_flip_x ())), - MenuLayoutEntry ("sel_flip_y", tl::to_string (QObject::tr ("Flip Vertically")), SLOT (cm_sel_flip_y ())), - MenuLayoutEntry ("sel_rot_cw", tl::to_string (QObject::tr ("Rotate Clockwise")), SLOT (cm_sel_rot_cw ())), - MenuLayoutEntry ("sel_rot_ccw", tl::to_string (QObject::tr ("Rotate Counterclockwise")), SLOT (cm_sel_rot_ccw ())), - MenuLayoutEntry ("sel_free_rot", tl::to_string (QObject::tr ("Rotation By Angle")), SLOT (cm_sel_free_rot ())), - MenuLayoutEntry ("sel_scale", tl::to_string (QObject::tr ("Scale")), SLOT (cm_sel_scale ())), - MenuLayoutEntry ("sel_move", tl::to_string (QObject::tr ("Move By")), SLOT (cm_sel_move ())), - MenuLayoutEntry ("sel_move_to", tl::to_string (QObject::tr ("Move To")), SLOT (cm_sel_move_to ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry view_menu [] = { - MenuLayoutEntry ("show_grid", tl::to_string (QObject::tr ("Show Grid")), std::make_pair (cfg_grid_visible, "?")), - MenuLayoutEntry ("default_grid:default_grids_group", tl::to_string (QObject::tr ("Grid")), empty_menu), - MenuLayoutEntry::separator ("layout_group"), - MenuLayoutEntry ("show_markers", tl::to_string (QObject::tr ("Show Markers")), std::make_pair (cfg_markers_visible, "?")), - MenuLayoutEntry ("show_texts", tl::to_string (QObject::tr ("Show Texts")), std::make_pair (cfg_text_visible, "?")), - MenuLayoutEntry ("show_cell_boxes", tl::to_string (QObject::tr ("Show Cell Frames")), std::make_pair (cfg_cell_box_visible, "?")), - MenuLayoutEntry ("no_stipples", tl::to_string (QObject::tr ("Show Layers Without Fill")), std::make_pair (cfg_no_stipple, "?")), - MenuLayoutEntry ("synchronized_views", tl::to_string (QObject::tr ("Synchronized Views")), std::make_pair (cfg_synchronized_views, "?")), - MenuLayoutEntry ("edit_top_level_selection:edit_mode", tl::to_string (QObject::tr ("Select Top Level Objects")), std::make_pair (edt::cfg_edit_top_level_selection, "?")), - MenuLayoutEntry::separator ("panels_group"), - MenuLayoutEntry ("show_toolbar", tl::to_string (QObject::tr ("Toolbar")), std::make_pair (cfg_show_toolbar, "?")), - MenuLayoutEntry ("show_navigator", tl::to_string (QObject::tr ("Navigator")), std::make_pair (cfg_show_navigator, "?")), - MenuLayoutEntry ("show_layer_panel", tl::to_string (QObject::tr ("Layers")), std::make_pair (cfg_show_layer_panel, "?")), - MenuLayoutEntry ("show_layer_toolbox", tl::to_string (QObject::tr ("Layer Toolbox")), std::make_pair (cfg_show_layer_toolbox, "?")), - MenuLayoutEntry ("show_hierarchy_panel", tl::to_string (QObject::tr ("Cells")), std::make_pair (cfg_show_hierarchy_panel, "?")), - MenuLayoutEntry ("show_libraries_view", tl::to_string (QObject::tr ("Libraries")), std::make_pair (cfg_show_libraries_view, "?")), - MenuLayoutEntry ("show_bookmarks_view", tl::to_string (QObject::tr ("Bookmarks")), std::make_pair (cfg_show_bookmarks_view, "?")), - MenuLayoutEntry ("reset_window_state", tl::to_string (QObject::tr ("Restore Window")), SLOT (cm_reset_window_state ())), - MenuLayoutEntry::separator ("selection_group"), - MenuLayoutEntry ("transient_selection", tl::to_string (QObject::tr ("Highlight Object Under Mouse")), std::make_pair (cfg_sel_transient_mode, "?")), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry edit_select_menu [] = { - MenuLayoutEntry ("select_all", tl::to_string (QObject::tr ("Select All")), SLOT (cm_select_all ())), - MenuLayoutEntry ("unselect_all", tl::to_string (QObject::tr ("Unselect All")), SLOT (cm_unselect_all ())), - MenuLayoutEntry::separator ("edit_select_basic_group"), - MenuLayoutEntry ("enable_all", tl::to_string (QObject::tr ("Enable All")), SLOT (enable_all ())), - MenuLayoutEntry ("disable_all", tl::to_string (QObject::tr ("Disable All")), SLOT (disable_all ())), - MenuLayoutEntry::separator ("edit_select_individual_group"), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry edit_menu [] = { - MenuLayoutEntry ("undo:edit", tl::to_string (QObject::tr ("Undo(Ctrl+Z)")), SLOT (cm_undo ())), - MenuLayoutEntry ("redo:edit", tl::to_string (QObject::tr ("Redo(Ctrl+Y)")), SLOT (cm_redo ())), - MenuLayoutEntry::separator ("basic_group"), - MenuLayoutEntry ("layout_menu:edit:edit_mode", tl::to_string (QObject::tr ("Layout")), edit_layout_menu), - MenuLayoutEntry ("cell_menu:edit:edit_mode", tl::to_string (QObject::tr ("Cell")), edit_cell_menu), - MenuLayoutEntry ("layer_menu:edit:edit_mode", tl::to_string (QObject::tr ("Layer")), edit_layer_menu), - MenuLayoutEntry ("selection_menu:edit", tl::to_string (QObject::tr ("Selection")), edit_selection_menu), - MenuLayoutEntry::separator ("utils_group"), - MenuLayoutEntry ("utils_menu:edit:edit_mode", tl::to_string (QObject::tr ("Utilities")), edit_utilities_menu), - MenuLayoutEntry::separator ("misc_group") , - MenuLayoutEntry ("delete:edit", tl::to_string (QObject::tr ("Delete(Del)")), SLOT (cm_delete ())), - MenuLayoutEntry ("show_properties:edit", tl::to_string (QObject::tr ("Properties(Q)")), SLOT (cm_show_properties ())), - MenuLayoutEntry::separator ("cpc_group"), - MenuLayoutEntry ("copy:edit", tl::to_string (QObject::tr ("Copy(Ctrl+C)")), SLOT (cm_copy ())), - MenuLayoutEntry ("cut:edit", tl::to_string (QObject::tr ("Cut(Ctrl+X)")), SLOT (cm_cut ())), - MenuLayoutEntry ("paste:edit", tl::to_string (QObject::tr ("Paste(Ctrl+V)")), SLOT (cm_paste ())), - MenuLayoutEntry ("duplicate:edit", tl::to_string (QObject::tr ("Duplicate(Ctrl+B)")), SLOT (cm_duplicate ())), - MenuLayoutEntry::separator ("modes_group"), - MenuLayoutEntry ("mode_menu", tl::to_string (QObject::tr ("Mode")), empty_menu), - MenuLayoutEntry ("select_menu", tl::to_string (QObject::tr ("Select")), edit_select_menu), - MenuLayoutEntry::separator ("cancel_group"), - MenuLayoutEntry ("cancel", tl::to_string (QObject::tr ("Cancel(Esc)")), SLOT (cm_cancel ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry bookmark_menu [] = { - MenuLayoutEntry ("goto_bookmark_menu", tl::to_string (QObject::tr ("Goto Bookmark")), empty_menu), - MenuLayoutEntry ("bookmark_view", tl::to_string (QObject::tr ("Bookmark This View")), SLOT (cm_bookmark_view ())), - MenuLayoutEntry::separator ("bookmark_mgm_group"), - MenuLayoutEntry ("manage_bookmarks", tl::to_string (QObject::tr ("Manage Bookmarks")), SLOT (cm_manage_bookmarks ())), - MenuLayoutEntry ("load_bookmarks", tl::to_string (QObject::tr ("Load Bookmarks")), SLOT (cm_load_bookmarks ())), - MenuLayoutEntry ("save_bookmarks", tl::to_string (QObject::tr ("Save Bookmarks")), SLOT (cm_save_bookmarks ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry global_trans_menu [] = { - MenuLayoutEntry ("r0", tl::to_string (QObject::tr ("\\(r0\\)<:/r0.png>")), std::make_pair (cfg_global_trans, "?r0 *1 0,0")), - MenuLayoutEntry ("r90", tl::to_string (QObject::tr ("\\(r90\\)<:/r90.png>")), std::make_pair (cfg_global_trans, "?r90 *1 0,0")), - MenuLayoutEntry ("r180", tl::to_string (QObject::tr ("\\(r180\\)<:/r180.png>")), std::make_pair (cfg_global_trans, "?r180 *1 0,0")), - MenuLayoutEntry ("r270", tl::to_string (QObject::tr ("\\(r270\\)<:/r270.png>")), std::make_pair (cfg_global_trans, "?r270 *1 0,0")), - MenuLayoutEntry ("m0", tl::to_string (QObject::tr ("\\(m0\\)<:/m0.png>")), std::make_pair (cfg_global_trans, "?m0 *1 0,0")), - MenuLayoutEntry ("m45", tl::to_string (QObject::tr ("\\(m45\\)<:/m45.png>")), std::make_pair (cfg_global_trans, "?m45 *1 0,0")), - MenuLayoutEntry ("m90", tl::to_string (QObject::tr ("\\(m90\\)<:/m90.png>")), std::make_pair (cfg_global_trans, "?m90 *1 0,0")), - MenuLayoutEntry ("m135", tl::to_string (QObject::tr ("\\(m135\\)<:/m135.png>")), std::make_pair (cfg_global_trans, "?m135 *1 0,0")), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry zoom_menu [] = { - MenuLayoutEntry ("global_trans", tl::to_string (QObject::tr ("Global Transformation")), global_trans_menu), - MenuLayoutEntry ("synchronized_views", tl::to_string (QObject::tr ("Synchronized Views")), std::make_pair (cfg_synchronized_views, "?")), - MenuLayoutEntry::separator ("hier_group"), - MenuLayoutEntry ("max_hier", tl::to_string (QObject::tr ("Full Hierarchy(*)")), SLOT (cm_max_hier ())), - MenuLayoutEntry ("max_hier_0", tl::to_string (QObject::tr ("Box Only(0)")), SLOT (cm_max_hier_0 ())), - MenuLayoutEntry ("max_hier_1", tl::to_string (QObject::tr ("Top Level Only(1)")), SLOT (cm_max_hier_1 ())), - MenuLayoutEntry ("inc_max_hier", tl::to_string (QObject::tr ("Increment Hierarchy(+)")), SLOT (cm_inc_max_hier ())), - MenuLayoutEntry ("dec_max_hier", tl::to_string (QObject::tr ("Decrement Hierarchy(-)")), SLOT (cm_dec_max_hier ())), - MenuLayoutEntry::separator ("zoom_group"), - MenuLayoutEntry ("zoom_fit", tl::to_string (QObject::tr ("Zoom Fit(F2)")), SLOT (cm_zoom_fit ())), - MenuLayoutEntry ("zoom_fit_sel", tl::to_string (QObject::tr ("Zoom Fit Selection(Shift+F2)")), SLOT (cm_zoom_fit_sel ())), - MenuLayoutEntry ("zoom_in", tl::to_string (QObject::tr ("Zoom In(Return)")), SLOT (cm_zoom_in ())), - MenuLayoutEntry ("zoom_out", tl::to_string (QObject::tr ("Zoom Out(Shift+Return)")), SLOT (cm_zoom_out ())), - /* disabled because that interferes with the use of the arrow keys for moving the selection - MenuLayoutEntry::separator ("pan_group"), - MenuLayoutEntry ("pan_up", tl::to_string (QObject::tr ("Pan Up(Up)")), SLOT (cm_pan_up ())), - MenuLayoutEntry ("pan_down", tl::to_string (QObject::tr ("Pan Down(Down)")), SLOT (cm_pan_down ())), - MenuLayoutEntry ("pan_left", tl::to_string (QObject::tr ("Pan Left(Left)")), SLOT (cm_pan_left ())), - MenuLayoutEntry ("pan_right", tl::to_string (QObject::tr ("Pan Right(Right)")), SLOT (cm_pan_right ())), - */ - MenuLayoutEntry::separator ("redraw_group"), - MenuLayoutEntry ("redraw", tl::to_string (QObject::tr ("Redraw")), SLOT (cm_redraw ())), - MenuLayoutEntry::separator ("state_group"), - MenuLayoutEntry ("prev_display_state", tl::to_string (QObject::tr ("Back(Shift+Tab)<:/back.png>")), SLOT (cm_prev_display_state ())), - MenuLayoutEntry ("next_display_state", tl::to_string (QObject::tr ("Forward(Tab)<:/forward.png>")), SLOT (cm_next_display_state ())), - MenuLayoutEntry::separator ("select_group"), - MenuLayoutEntry ("select_cell:edit", tl::to_string (QObject::tr ("Select Cell")), SLOT (cm_select_cell ())), - MenuLayoutEntry ("select_current_cell", tl::to_string (QObject::tr ("Show As New Top(Ctrl+S)")), SLOT (cm_select_current_cell ())), - MenuLayoutEntry ("goto_position", tl::to_string (QObject::tr ("Goto Position(Ctrl+G)")), SLOT (cm_goto_position ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry help_menu [] = { - MenuLayoutEntry ("show_all_tips", tl::to_string (QObject::tr ("Show All Tips")), SLOT (cm_show_all_tips ())), - MenuLayoutEntry::separator ("help_topics_group"), - MenuLayoutEntry ("assistant", tl::to_string (QObject::tr ("Assistant")), SLOT (cm_show_assistant ())), - MenuLayoutEntry ("about", tl::to_string (QObject::tr ("About")), SLOT (cm_help_about ())), - MenuLayoutEntry ("about_qt", tl::to_string (QObject::tr ("About Qt")), SLOT (cm_help_about_qt ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry tools_menu [] = { - MenuLayoutEntry ("packages", tl::to_string (QObject::tr ("Manage Packages")), SLOT (cm_packages ())), - MenuLayoutEntry ("technologies", tl::to_string (QObject::tr ("Manage Technologies")), SLOT (cm_technologies ())), - MenuLayoutEntry::separator ("verification_group"), - MenuLayoutEntry::separator ("post_verification_group"), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry macros_menu [] = { - MenuLayoutEntry ("macro_development", tl::to_string (QObject::tr ("Macro Development(F5)")), SLOT (cm_macro_editor ())), - MenuLayoutEntry::separator ("macros_group"), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry toolbar_entries [] = { - MenuLayoutEntry ("prev_display_state", "-", SLOT (cm_prev_display_state ())), - MenuLayoutEntry ("next_display_state", "-", SLOT (cm_next_display_state ())), - MenuLayoutEntry::separator ("toolbar_post_navigation_group"), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry main_menu [] = { - MenuLayoutEntry ("file_menu", tl::to_string (QObject::tr ("&File")), file_menu), - MenuLayoutEntry ("edit_menu", tl::to_string (QObject::tr ("&Edit")), edit_menu), - MenuLayoutEntry ("view_menu", tl::to_string (QObject::tr ("&View")), view_menu), - MenuLayoutEntry ("bookmark_menu", tl::to_string (QObject::tr ("&Bookmarks")), bookmark_menu), - MenuLayoutEntry ("zoom_menu", tl::to_string (QObject::tr ("&Display")), zoom_menu), - MenuLayoutEntry ("tools_menu", tl::to_string (QObject::tr ("&Tools")), tools_menu), - MenuLayoutEntry ("macros_menu", tl::to_string (QObject::tr ("&Macros")), macros_menu), - MenuLayoutEntry::separator ("help_group"), - MenuLayoutEntry ("help_menu", tl::to_string (QObject::tr ("&Help")), help_menu), - MenuLayoutEntry ("@secrets", tl::to_string (QObject::tr ("Secret Features")), secret_menu), - MenuLayoutEntry ("@toolbar", "", toolbar_entries), - MenuLayoutEntry::last () - }; - - mp_menu = new AbstractMenu (this); - mp_menu->init (main_menu); - - lay::LayoutView::init_menu (*mp_menu); - lay::Navigator::init_menu (*mp_menu); - - // Fill the mode menu file items from the intrinsic mouse modes - // TODO: map the intrinsic modes to standard plugins and remove this code along - // with related code in LayoutView. After this we can simplify the menu inititialization - // inside PluginDeclaration as well. - - std::vector mode_titles; - lay::LayoutView::intrinsic_mouse_modes (&mode_titles); - - int mode_id = 0; - for (std::vector ::const_iterator t = mode_titles.begin (); t != mode_titles.end (); ++t, --mode_id) { - - if (! t->empty ()) { - - // extract first part, which is the name, separated by a tab from the title. - std::string name = tl::sprintf ("mode_i%d", 1 - mode_id); - std::string title = *t; - const char *tab = strchr (t->c_str (), '\t'); - if (tab) { - name = std::string (*t, 0, tab - t->c_str ()); - title = tab + 1; - } - - Action action (title); - action.set_checkable (true); - action.qaction ()->setData (QVariant (mode_id)); - action.add_to_exclusive_group (mp_menu, "mouse_mode_exclusive_group"); - - mp_menu->insert_item ("edit_menu.mode_menu.end", name, action); - mp_menu->insert_item ("@toolbar.end", name, action); - - gtf::action_connect (action.qaction (), SIGNAL (triggered ()), this, SLOT (intrinsic_mode_triggered ())); - - } - - } - - // Add a hook for inserting new items after the modes - Action end_modes; - end_modes.set_separator (true); - mp_menu->insert_item ("@toolbar.end", "end_modes", end_modes); - // make the plugins create their menu items for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { // TODO: get rid of the const_cast hack - const_cast (&*cls)->init_menu (); + const_cast (&*cls)->init_menu (this); } // if in "viewer-only mode", hide all entries in the "hide_vo" group if ((lay::ApplicationBase::instance () && lay::ApplicationBase::instance ()->is_vo_mode ())) { - std::vector hide_vo_grp = mp_menu->group ("hide_vo"); + std::vector hide_vo_grp = menu ()->group ("hide_vo"); for (std::vector::const_iterator g = hide_vo_grp.begin (); g != hide_vo_grp.end (); ++g) { - mp_menu->action (*g).set_visible (false); + menu ()->action (*g).set_visible (false); } } @@ -1072,14 +750,14 @@ MainWindow::init_menu () // TODO: later do this on each change of the view - each view might get it's own editable mode bool view_mode = (lay::ApplicationBase::instance () && !lay::ApplicationBase::instance ()->is_editable ()); - std::vector edit_mode_grp = mp_menu->group ("edit_mode"); + std::vector edit_mode_grp = menu ()->group ("edit_mode"); for (std::vector::const_iterator g = edit_mode_grp.begin (); g != edit_mode_grp.end (); ++g) { - mp_menu->action (*g).set_visible (! view_mode); + menu ()->action (*g).set_visible (! view_mode); } - std::vector view_mode_grp = mp_menu->group ("view_mode"); + std::vector view_mode_grp = menu ()->group ("view_mode"); for (std::vector::const_iterator g = view_mode_grp.begin (); g != view_mode_grp.end (); ++g) { - mp_menu->action (*g).set_visible (view_mode); + menu ()->action (*g).set_visible (view_mode); } } @@ -1087,17 +765,17 @@ void MainWindow::dock_widget_visibility_changed (bool /*visible*/) { if (sender () == mp_lp_dock_widget) { - plugin_root ()->config_set (cfg_show_layer_panel, tl::to_string (!mp_lp_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_layer_panel, tl::to_string (!mp_lp_dock_widget->isHidden ())); } else if (sender () == mp_hp_dock_widget) { - plugin_root ()->config_set (cfg_show_hierarchy_panel, tl::to_string (!mp_hp_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_hierarchy_panel, tl::to_string (!mp_hp_dock_widget->isHidden ())); } else if (sender () == mp_libs_dock_widget) { - plugin_root ()->config_set (cfg_show_libraries_view, tl::to_string (!mp_libs_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_libraries_view, tl::to_string (!mp_libs_dock_widget->isHidden ())); } else if (sender () == mp_bm_dock_widget) { - plugin_root ()->config_set (cfg_show_bookmarks_view, tl::to_string (!mp_bm_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_bookmarks_view, tl::to_string (!mp_bm_dock_widget->isHidden ())); } else if (sender () == mp_navigator_dock_widget) { - plugin_root ()->config_set (cfg_show_navigator, tl::to_string (!mp_navigator_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_navigator, tl::to_string (!mp_navigator_dock_widget->isHidden ())); } else if (sender () == mp_layer_toolbox_dock_widget) { - plugin_root ()->config_set (cfg_show_layer_toolbox, tl::to_string (!mp_layer_toolbox_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_layer_toolbox, tl::to_string (!mp_layer_toolbox_dock_widget->isHidden ())); } } @@ -1294,7 +972,7 @@ MainWindow::about_to_exec () lay::TipDialog::button_type button = lay::TipDialog::null_button; if (td.exec_dialog (button)) { if (button == lay::TipDialog::yes_button) { - plugin_root ()->config_set (cfg_full_hier_new_cell, true); + dispatcher ()->config_set (cfg_full_hier_new_cell, true); } // Don't bother the user with more dialogs. return; @@ -1489,12 +1167,7 @@ MainWindow::config_finalize () bool MainWindow::configure (const std::string &name, const std::string &value) { - std::map >::iterator ca = m_configuration_actions.find (name); - if (ca != m_configuration_actions.end ()) { - for (std::vector::const_iterator a = ca->second.begin (); a != ca->second.end (); ++a) { - (*a)->configure (value); - } - } + lay::Dispatcher::configure (name, value); if (name == cfg_grid) { @@ -1814,16 +1487,16 @@ MainWindow::edits_enabled_changed () { bool enable = edits_enabled (); - std::vector edit_grp = mp_menu->group ("edit"); + std::vector edit_grp = menu ()->group ("edit"); for (std::vector::const_iterator g = edit_grp.begin (); g != edit_grp.end (); ++g) { - mp_menu->action (*g).set_enabled (enable); + menu ()->action (*g).set_enabled (enable); } } void MainWindow::menu_needs_update () { - lay::LayoutView::update_menu (current_view (), *mp_menu); + lay::LayoutView::update_menu (current_view (), *menu ()); } void @@ -1840,12 +1513,12 @@ MainWindow::libraries_changed () void MainWindow::read_dock_widget_state () { - plugin_root ()->config_set (cfg_show_layer_panel, tl::to_string (!mp_lp_dock_widget->isHidden ())); - plugin_root ()->config_set (cfg_show_hierarchy_panel, tl::to_string (!mp_hp_dock_widget->isHidden ())); - plugin_root ()->config_set (cfg_show_libraries_view, tl::to_string (!mp_libs_dock_widget->isHidden ())); - plugin_root ()->config_set (cfg_show_bookmarks_view, tl::to_string (!mp_bm_dock_widget->isHidden ())); - plugin_root ()->config_set (cfg_show_navigator, tl::to_string (!mp_navigator_dock_widget->isHidden ())); - plugin_root ()->config_set (cfg_show_layer_toolbox, tl::to_string (!mp_layer_toolbox_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_layer_panel, tl::to_string (!mp_lp_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_hierarchy_panel, tl::to_string (!mp_hp_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_libraries_view, tl::to_string (!mp_libs_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_bookmarks_view, tl::to_string (!mp_bm_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_navigator, tl::to_string (!mp_navigator_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_layer_toolbox, tl::to_string (!mp_layer_toolbox_dock_widget->isHidden ())); } void @@ -1970,7 +1643,7 @@ MainWindow::can_close () for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { lay::PluginDeclaration *pd = const_cast (&*cls); - if (! pd->can_exit (plugin_root ())) { + if (! pd->can_exit (dispatcher ())) { return false; } } @@ -2015,8 +1688,8 @@ MainWindow::save_state_to_config () { // save the dock widget state with all views closed (that state can be // used for staring klayout without any layout) - plugin_root ()->config_set (cfg_window_geometry, (const char *) saveGeometry ().toBase64 ().data ()); - plugin_root ()->config_set (cfg_window_state, (const char *) saveState ().toBase64 ().data ()); + dispatcher ()->config_set (cfg_window_geometry, (const char *) saveGeometry ().toBase64 ().data ()); + dispatcher ()->config_set (cfg_window_state, (const char *) saveState ().toBase64 ().data ()); } void @@ -2040,29 +1713,23 @@ MainWindow::closeEvent (QCloseEvent *event) void MainWindow::cm_navigator_freeze () { - BEGIN_PROTECTED if (mp_navigator) { mp_navigator->freeze_clicked (); } - END_PROTECTED } void MainWindow::cm_navigator_close () { - BEGIN_PROTECTED if (mp_navigator) { mp_navigator->close (); } - END_PROTECTED } void MainWindow::cm_view_log () { - BEGIN_PROTECTED mp_log_viewer_dialog->show (); - END_PROTECTED } void @@ -2070,8 +1737,6 @@ MainWindow::cm_print () { // TODO: move to lay::LayoutView - BEGIN_PROTECTED - // Late-initialize the printer to save time on startup if (! mp_printer.get ()) { mp_printer.reset (new QPrinter ()); @@ -2134,16 +1799,12 @@ MainWindow::cm_print () } } - - END_PROTECTED } void MainWindow::cm_exit () { - BEGIN_PROTECTED exit (); - END_PROTECTED } lay::LayoutView * @@ -2190,205 +1851,6 @@ MainWindow::current_view () const return lay::LayoutView::current (); } -void -MainWindow::cm_show_properties () -{ - if (current_view ()) { - current_view ()->show_properties (this); - } -} - -void -MainWindow::cm_delete () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->del (); - // because a "delete" might involve objects currently edited, we cancel the edit after we have deleted the object - current_view ()->cancel (); - current_view ()->clear_selection (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_paste () -{ - BEGIN_PROTECTED - current_view ()->cm_layer_paste (); - END_PROTECTED -} - -void -MainWindow::cm_lv_cut () -{ - BEGIN_PROTECTED - current_view ()->cm_layer_cut (); - END_PROTECTED -} - -void -MainWindow::cm_lv_copy () -{ - BEGIN_PROTECTED - current_view ()->cm_layer_copy (); - END_PROTECTED -} - -void -MainWindow::cm_cell_paste () -{ - BEGIN_PROTECTED - current_view ()->cm_cell_paste (); - END_PROTECTED -} - -void -MainWindow::cm_cell_cut () -{ - BEGIN_PROTECTED - current_view ()->cm_cell_cut (); - END_PROTECTED -} - -void -MainWindow::cm_cell_copy () -{ - BEGIN_PROTECTED - current_view ()->cm_cell_copy (); - END_PROTECTED -} - -void -MainWindow::do_cm_duplicate (bool interactive) -{ - BEGIN_PROTECTED - - if (current_view ()) { - - // Do duplicate simply by concatenating copy & paste currently. - // Save the clipboard state before in order to preserve the current content - db::Clipboard saved_clipboard; - db::Clipboard::instance ().swap (saved_clipboard); - - try { - current_view ()->copy (); - current_view ()->clear_selection (); - current_view ()->cancel (); - if (interactive) { - current_view ()->paste_interactive (); - } else { - current_view ()->paste (); - } - db::Clipboard::instance ().swap (saved_clipboard); - } catch (...) { - db::Clipboard::instance ().swap (saved_clipboard); - throw; - } - - } - - END_PROTECTED -} - -void -MainWindow::cm_duplicate () -{ - BEGIN_PROTECTED - - do_cm_duplicate (false); - - END_PROTECTED -} - -void -MainWindow::cm_duplicate_interactive () -{ - BEGIN_PROTECTED - - do_cm_duplicate (true); - - END_PROTECTED -} - -void -MainWindow::cm_copy () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->copy (); - current_view ()->clear_selection (); - } - - END_PROTECTED -} - -void -MainWindow::do_cm_paste (bool interactive) -{ - BEGIN_PROTECTED - - if (current_view () && ! db::Clipboard::instance ().empty ()) { - current_view ()->cancel (); - current_view ()->clear_selection (); - if (interactive) { - current_view ()->paste_interactive (); - } else { - current_view ()->paste (); - } - } - - END_PROTECTED -} - -void -MainWindow::cm_paste () -{ - do_cm_paste (false); -} - -void -MainWindow::cm_paste_interactive () -{ - do_cm_paste (true); -} - -void -MainWindow::cm_cut () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cut (); - current_view ()->cancel (); // see del() for reason why cancel is after cut - current_view ()->clear_selection (); - } - - END_PROTECTED -} - -void -MainWindow::intrinsic_mode_triggered () -{ - BEGIN_PROTECTED - - QAction *action = dynamic_cast (sender ()); - if (action) { - - int mode = action->data ().toInt (); - - plugin_root ()->select_mode (mode); - - action->setChecked (true); - - } - - END_PROTECTED -} - void MainWindow::select_mode (int m) { @@ -2418,37 +1880,17 @@ MainWindow::select_mode (int m) void MainWindow::enable_all () { - BEGIN_PROTECTED - for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { cls->set_editable_enabled (true); } - - END_PROTECTED } void MainWindow::disable_all () { - BEGIN_PROTECTED - for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { cls->set_editable_enabled (false); } - - END_PROTECTED -} - -void -MainWindow::cm_unselect_all () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->select (db::DBox (), lay::Editable::Reset); - } - - END_PROTECTED } void @@ -2458,25 +1900,9 @@ MainWindow::cm_reset_window_state () restoreGeometry (m_default_window_geometry); } -void -MainWindow::cm_select_all () -{ - BEGIN_PROTECTED - - if (current_view ()) { - // TODO: "select all" with an empty box is not well implemented in most services. - // Hence we use the overlapp box currently. - current_view ()->select (current_view ()->full_box (), lay::Editable::Replace); - } - - END_PROTECTED -} - void MainWindow::cm_undo () { - BEGIN_PROTECTED - if (current_view () && m_manager.available_undo ().first) { for (std::vector ::iterator vp = mp_views.begin (); vp != mp_views.end (); ++vp) { (*vp)->clear_selection (); @@ -2484,15 +1910,11 @@ MainWindow::cm_undo () } m_manager.undo (); } - - END_PROTECTED } void MainWindow::cm_redo () { - BEGIN_PROTECTED - if (current_view () && m_manager.available_redo ().first) { for (std::vector ::iterator vp = mp_views.begin (); vp != mp_views.end (); ++vp) { (*vp)->clear_selection (); @@ -2500,15 +1922,11 @@ MainWindow::cm_redo () } m_manager.redo (); } - - END_PROTECTED } void MainWindow::cm_goto_position () { - BEGIN_PROTECTED - if (current_view ()) { while (true) { @@ -2585,141 +2003,31 @@ MainWindow::cm_goto_position () } } - - END_PROTECTED } void MainWindow::cm_manage_bookmarks () { - BEGIN_PROTECTED - if (current_view ()) { current_view ()->manage_bookmarks (); } - - END_PROTECTED } void MainWindow::cm_bookmark_view () { - BEGIN_PROTECTED - if (current_view ()) { current_view ()->bookmark_current_view (); } - - END_PROTECTED } void MainWindow::update_content () { - BEGIN_PROTECTED - mp_setup_form->setup (); if (current_view ()) { current_view ()->update_content (); } - - END_PROTECTED -} - -void -MainWindow::cm_zoom_fit_sel () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->zoom_fit_sel (); - } - - END_PROTECTED -} - -void -MainWindow::cm_zoom_fit () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->zoom_fit (); - } - - END_PROTECTED -} - -void -MainWindow::cm_pan_left () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->pan_left (); - } - - END_PROTECTED -} - -void -MainWindow::cm_pan_right () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->pan_right (); - } - - END_PROTECTED -} - -void -MainWindow::cm_pan_up () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->pan_up (); - } - - END_PROTECTED -} - -void -MainWindow::cm_pan_down () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->pan_down (); - } - - END_PROTECTED -} - -void -MainWindow::cm_zoom_in () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->zoom_in (); - } - - END_PROTECTED -} - -void -MainWindow::cm_zoom_out () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->zoom_out (); - } - - END_PROTECTED } void @@ -2727,9 +2035,9 @@ MainWindow::update_action_states () { try { - if (mp_menu->is_valid ("edit_menu.undo")) { + if (menu ()->is_valid ("edit_menu.undo")) { - Action undo_action = mp_menu->action ("edit_menu.undo"); + Action undo_action = menu ()->action ("edit_menu.undo"); std::string undo_txt (tl::to_string (QObject::tr ("&Undo"))); bool undo_enable = false; @@ -2742,9 +2050,9 @@ MainWindow::update_action_states () } - if (mp_menu->is_valid ("edit_menu.redo")) { + if (menu ()->is_valid ("edit_menu.redo")) { - Action redo_action = mp_menu->action ("edit_menu.redo"); + Action redo_action = menu ()->action ("edit_menu.redo"); std::string redo_txt (tl::to_string (QObject::tr ("&Redo"))); bool redo_enable = false; @@ -2757,18 +2065,18 @@ MainWindow::update_action_states () } - if (mp_menu->is_valid ("edit_menu.paste")) { - Action paste_action = mp_menu->action ("edit_menu.paste"); + if (menu ()->is_valid ("edit_menu.paste")) { + Action paste_action = menu ()->action ("edit_menu.paste"); paste_action.set_enabled (! db::Clipboard::instance ().empty () && edits_enabled ()); } - if (mp_menu->is_valid ("zoom_menu.next_display_state")) { - Action next_display_state_action = mp_menu->action ("zoom_menu.next_display_state"); + if (menu ()->is_valid ("zoom_menu.next_display_state")) { + Action next_display_state_action = menu ()->action ("zoom_menu.next_display_state"); next_display_state_action.set_enabled (has_next_display_state ()); } - if (mp_menu->is_valid ("zoom_menu.prev_display_state")) { - Action prev_display_state_action = mp_menu->action ("zoom_menu.prev_display_state"); + if (menu ()->is_valid ("zoom_menu.prev_display_state")) { + Action prev_display_state_action = menu ()->action ("zoom_menu.prev_display_state"); prev_display_state_action.set_enabled (has_prev_display_state ()); } @@ -2777,14 +2085,6 @@ MainWindow::update_action_states () } } -void -MainWindow::cm_redraw () -{ - BEGIN_PROTECTED - redraw (); - END_PROTECTED -} - void MainWindow::redraw () { @@ -2796,9 +2096,7 @@ MainWindow::redraw () void MainWindow::cm_cancel () { - BEGIN_PROTECTED cancel (); - END_PROTECTED } /** @@ -2820,23 +2118,6 @@ MainWindow::cancel () select_mode (lay::LayoutView::default_mode ()); } -void -MainWindow::cm_save_layer_props () -{ - BEGIN_PROTECTED - - if (current_view ()) { - std::string fn; - if (mp_lprops_fdia->get_save (fn, tl::to_string (QObject::tr ("Save Layer Properties File")))) { - current_view ()->save_layer_props (fn); - } - } else { - throw tl::Exception (tl::to_string (QObject::tr ("No view open to save the layer properties from"))); - } - - END_PROTECTED -} - void MainWindow::load_layer_properties (const std::string &fn, bool all_views, bool add_default) { @@ -2893,11 +2174,22 @@ MainWindow::is_single_cv_layer_properties_file (const std::string &fn) return (cv.size () == 1); } +void +MainWindow::cm_save_layer_props () +{ + if (current_view ()) { + std::string fn; + if (mp_lprops_fdia->get_save (fn, tl::to_string (QObject::tr ("Save Layer Properties File")))) { + current_view ()->save_layer_props (fn); + } + } else { + throw tl::Exception (tl::to_string (QObject::tr ("No view open to save the layer properties from"))); + } +} + void MainWindow::cm_load_layer_props () { - BEGIN_PROTECTED - if (current_view ()) { std::string fn; if (mp_lprops_fdia->get_open (fn, tl::to_string (QObject::tr ("Load Layer Properties File")))) { @@ -2935,8 +2227,6 @@ MainWindow::cm_load_layer_props () } else { throw tl::Exception (tl::to_string (QObject::tr ("No view open to load the layer properties for"))); } - - END_PROTECTED } void @@ -2961,8 +2251,6 @@ MainWindow::restore_session (const std::string &fn) void MainWindow::cm_save_session () { - BEGIN_PROTECTED - std::string df_list; int dirty_layouts = dirty_files (df_list); @@ -2979,15 +2267,11 @@ MainWindow::cm_save_session () } } - - END_PROTECTED } void MainWindow::cm_restore_session () { - BEGIN_PROTECTED - std::string fn = m_current_session; if (mp_session_fdia->get_open (fn, tl::to_string (QObject::tr ("Load Session File")))) { @@ -3014,15 +2298,11 @@ MainWindow::cm_restore_session () } } - - END_PROTECTED } void MainWindow::cm_save_bookmarks () { - BEGIN_PROTECTED - if (current_view ()) { std::string fn; if (mp_bookmarks_fdia->get_save (fn, tl::to_string (QObject::tr ("Save Bookmarks File")))) { @@ -3031,15 +2311,11 @@ MainWindow::cm_save_bookmarks () } else { throw tl::Exception (tl::to_string (QObject::tr ("No view open to save the bookmarks from"))); } - - END_PROTECTED } void MainWindow::cm_load_bookmarks () { - BEGIN_PROTECTED - if (current_view ()) { std::string fn; if (mp_bookmarks_fdia->get_open (fn, tl::to_string (QObject::tr ("Load Bookmarks File")))) { @@ -3050,66 +2326,11 @@ MainWindow::cm_load_bookmarks () } else { throw tl::Exception (tl::to_string (QObject::tr ("No view open to load the bookmarks for"))); } - - END_PROTECTED -} - -void -MainWindow::cm_select_current_cell () -{ - BEGIN_PROTECTED - - lay::LayoutView *view = current_view (); - if (view && view->active_cellview_index () >= 0) { - lay::LayoutView::cell_path_type path; - int cvi = view->active_cellview_index (); - view->current_cell_path (path); - view->select_cell_fit (path, cvi); - } - - END_PROTECTED -} - -void -MainWindow::cm_open_current_cell () -{ - BEGIN_PROTECTED - - if (current_view () && current_view ()->active_cellview_index () >= 0) { - current_view ()->cm_open_current_cell (); - } - - END_PROTECTED -} - -void -MainWindow::cm_select_cell () -{ - BEGIN_PROTECTED - - if (current_view () && current_view ()->active_cellview_index () >= 0) { - - CellSelectionForm form (0, current_view (), "cell_selection_form"); - - if (form.exec () == QDialog::Accepted && - form.selected_cellview_index () >= 0) { - current_view ()->select_cell (form.selected_cellview ().combined_unspecific_path (), form.selected_cellview_index ()); - current_view ()->set_current_cell_path (form.selected_cellview_index (), form.selected_cellview ().combined_unspecific_path ()); - current_view ()->zoom_fit (); - } - - } else { - throw tl::Exception (tl::to_string (QObject::tr ("No view open to select a cell for"))); - } - - END_PROTECTED } void MainWindow::cm_screenshot () { - BEGIN_PROTECTED - if (current_view ()) { std::string fn; if (mp_screenshot_fdia->get_save (fn, tl::to_string (QObject::tr ("Save Screenshot")))) { @@ -3118,15 +2339,11 @@ MainWindow::cm_screenshot () } else { throw tl::Exception (tl::to_string (QObject::tr ("No view open to create a screenshot from"))); } - - END_PROTECTED } void MainWindow::cm_save_current_cell_as () { - BEGIN_PROTECTED - if (current_view ()) { int cv_index = current_view ()->active_cellview_index (); @@ -3174,8 +2391,6 @@ MainWindow::cm_save_current_cell_as () } } - - END_PROTECTED } void @@ -3193,8 +2408,6 @@ MainWindow::cm_save_as () void MainWindow::do_save (bool as) { - BEGIN_PROTECTED - if (current_view ()) { std::vector cv_indexes; @@ -3252,49 +2465,43 @@ MainWindow::do_save (bool as) } else { throw tl::Exception (tl::to_string (QObject::tr ("No view open to save"))); } - - END_PROTECTED } void MainWindow::cm_save_all () { - BEGIN_PROTECTED + for (int view_index = 0; view_index < int (views ()); ++view_index) { - for (int view_index = 0; view_index < int (views ()); ++view_index) { + for (unsigned int cv_index = 0; cv_index < view (view_index)->cellviews (); ++cv_index) { - for (unsigned int cv_index = 0; cv_index < view (view_index)->cellviews (); ++cv_index) { + const lay::CellView &cv = view (view_index)->cellview (cv_index); + std::string fn = cv->filename (); - const lay::CellView &cv = view (view_index)->cellview (cv_index); - std::string fn = cv->filename (); + if (! fn.empty () || mp_layout_fdia->get_save (fn, tl::to_string (tr ("Save Layout '%1'").arg (tl::to_qstring (cv->name ()))))) { - if (! fn.empty () || mp_layout_fdia->get_save (fn, tl::to_string (tr ("Save Layout '%1'").arg (tl::to_qstring (cv->name ()))))) { + db::SaveLayoutOptions options (cv->save_options ()); + options.set_dbu (cv->layout ().dbu ()); - db::SaveLayoutOptions options (cv->save_options ()); - options.set_dbu (cv->layout ().dbu ()); + options.set_format_from_filename (fn); - options.set_format_from_filename (fn); + tl::OutputStream::OutputStreamMode om = tl::OutputStream::OM_Auto; - tl::OutputStream::OutputStreamMode om = tl::OutputStream::OM_Auto; - - // initialize the specific options from the configuration if required - for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { - const StreamWriterPluginDeclaration *decl = dynamic_cast (&*cls); - if (decl) { - options.set_options (decl->create_specific_options ()); - } + // initialize the specific options from the configuration if required + for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { + const StreamWriterPluginDeclaration *decl = dynamic_cast (&*cls); + if (decl) { + options.set_options (decl->create_specific_options ()); } - - view (view_index)->save_as (cv_index, fn, om, options, true); - add_mru (fn, current_view ()->cellview (cv_index)->tech_name ()); - } + view (view_index)->save_as (cv_index, fn, om, options, true); + add_mru (fn, current_view ()->cellview (cv_index)->tech_name ()); + } } - END_PROTECTED + } } void @@ -3394,8 +2601,6 @@ MainWindow::cm_open () void MainWindow::cm_pull_in () { - BEGIN_PROTECTED - std::vector names; lay::LayoutHandle::get_names (names); @@ -3457,20 +2662,18 @@ MainWindow::cm_pull_in () } } - - END_PROTECTED } void MainWindow::cm_reader_options () { - mp_layout_load_options->edit_global_options (plugin_root (), db::Technologies::instance ()); + mp_layout_load_options->edit_global_options (dispatcher (), db::Technologies::instance ()); } void MainWindow::cm_writer_options () { - mp_layout_save_options->edit_global_options (plugin_root (), db::Technologies::instance ()); + mp_layout_save_options->edit_global_options (dispatcher (), db::Technologies::instance ()); } void @@ -3482,257 +2685,32 @@ MainWindow::cm_new_panel () void MainWindow::cm_new_layout () { - BEGIN_PROTECTED - std::string technology = m_initial_technology; + static std::string s_new_cell_cell_name; + static double s_new_cell_window_size = 2.0; double dbu = 0.0; lay::NewLayoutPropertiesDialog dialog (this); - if (dialog.exec_dialog (technology, m_new_cell_cell_name, dbu, m_new_cell_window_size, m_new_layout_current_panel)) { + if (dialog.exec_dialog (technology, s_new_cell_cell_name, dbu, s_new_cell_window_size, m_new_layout_current_panel)) { lay::CellViewRef cellview = create_or_load_layout (0, 0, technology, m_new_layout_current_panel ? 2 : 1 /*= new view*/); if (dbu > 1e-10) { cellview->layout ().dbu (dbu); } - db::cell_index_type new_ci = cellview->layout ().add_cell (m_new_cell_cell_name.empty () ? 0 : m_new_cell_cell_name.c_str ()); + db::cell_index_type new_ci = cellview->layout ().add_cell (s_new_cell_cell_name.empty () ? 0 : s_new_cell_cell_name.c_str ()); cellview.set_cell (new_ci); - current_view ()->zoom_box_and_set_hier_levels (db::DBox (-0.5 * m_new_cell_window_size, -0.5 * m_new_cell_window_size, 0.5 * m_new_cell_window_size, 0.5 * m_new_cell_window_size), std::make_pair (0, 1)); + current_view ()->zoom_box_and_set_hier_levels (db::DBox (-0.5 * s_new_cell_window_size, -0.5 * s_new_cell_window_size, 0.5 * s_new_cell_window_size, 0.5 * s_new_cell_window_size), std::make_pair (0, 1)); } - - END_PROTECTED -} - -void -MainWindow::call_on_current_view (void (lay::LayoutView::*func) (), const std::string &op_desc) -{ - BEGIN_PROTECTED - - lay::LayoutView *curr = current_view (); - if (! curr || curr->active_cellview_index () < 0) { - throw tl::Exception (tl::to_string (QObject::tr ("No view open for operation: ")) + op_desc); - } - - (curr->*func) (); - - END_PROTECTED -} - -void -MainWindow::cm_adjust_origin () -{ - call_on_current_view (&lay::LayoutView::cm_align_cell_origin, tl::to_string (QObject::tr ("adjust cell origin"))); -} - -void -MainWindow::cm_new_cell () -{ - // TODO: move this function to lay::LayoutView - - BEGIN_PROTECTED - - lay::LayoutView *curr = current_view (); - if (! curr || curr->active_cellview_index () < 0) { - throw tl::Exception (tl::to_string (QObject::tr ("No view open to create a new cell inside"))); - } - - NewCellPropertiesDialog cell_prop_dia (this); - if (cell_prop_dia.exec_dialog (& curr->cellview (curr->active_cellview_index ())->layout (), m_new_cell_cell_name, m_new_cell_window_size)) { - - db::cell_index_type new_ci = curr->new_cell (curr->active_cellview_index (), m_new_cell_cell_name.c_str ()); - curr->select_cell (new_ci, curr->active_cellview_index ()); - - db::DBox zoom_box = db::DBox (-0.5 * m_new_cell_window_size, -0.5 * m_new_cell_window_size, 0.5 * m_new_cell_window_size, 0.5 * m_new_cell_window_size); - if (curr->get_max_hier_levels () < 1 || curr->get_min_hier_levels () > 0) { - curr->zoom_box_and_set_hier_levels (zoom_box, std::make_pair (0, 1)); - } else { - curr->zoom_box (zoom_box); - } - - } - - END_PROTECTED -} - -void -MainWindow::cm_cell_convert_to_static () -{ - call_on_current_view (&lay::LayoutView::cm_cell_convert_to_static, tl::to_string (QObject::tr ("convert cell to static"))); -} - -void -MainWindow::cm_lay_convert_to_static () -{ - call_on_current_view (&lay::LayoutView::cm_lay_convert_to_static, tl::to_string (QObject::tr ("convert all cells to static"))); -} - -void -MainWindow::cm_lay_move () -{ - call_on_current_view (&lay::LayoutView::cm_lay_move, tl::to_string (QObject::tr ("move layout"))); -} - -void -MainWindow::cm_lay_scale () -{ - call_on_current_view (&lay::LayoutView::cm_lay_scale, tl::to_string (QObject::tr ("scale layout"))); -} - -void -MainWindow::cm_lay_free_rot () -{ - call_on_current_view (&lay::LayoutView::cm_lay_free_rot, tl::to_string (QObject::tr ("free rotation of layout"))); -} - -void -MainWindow::cm_lay_rot_ccw () -{ - call_on_current_view (&lay::LayoutView::cm_lay_rot_ccw, tl::to_string (QObject::tr ("counter clockwise rotation of layout"))); -} - -void -MainWindow::cm_lay_rot_cw () -{ - call_on_current_view (&lay::LayoutView::cm_lay_rot_cw, tl::to_string (QObject::tr ("clockwise rotation of layout"))); -} - -void -MainWindow::cm_lay_flip_y () -{ - call_on_current_view (&lay::LayoutView::cm_lay_flip_y, tl::to_string (QObject::tr ("vertical flip of layout"))); -} - -void -MainWindow::cm_lay_flip_x () -{ - call_on_current_view (&lay::LayoutView::cm_lay_flip_x, tl::to_string (QObject::tr ("horizontal flip of layout"))); -} - -void -MainWindow::cm_sel_move () -{ - call_on_current_view (&lay::LayoutView::cm_sel_move, tl::to_string (QObject::tr ("move selection"))); -} - -void -MainWindow::cm_sel_move_to () -{ - call_on_current_view (&lay::LayoutView::cm_sel_move_to, tl::to_string (QObject::tr ("move selection to position"))); -} - -void -MainWindow::cm_sel_move_interactive () -{ - call_on_current_view (&lay::LayoutView::cm_sel_move_interactive, tl::to_string (QObject::tr ("move selection interactively"))); -} - -void -MainWindow::cm_sel_scale () -{ - call_on_current_view (&lay::LayoutView::cm_sel_scale, tl::to_string (QObject::tr ("scale selection"))); -} - -void -MainWindow::cm_sel_free_rot () -{ - call_on_current_view (&lay::LayoutView::cm_sel_free_rot, tl::to_string (QObject::tr ("free rotation of selection"))); -} - -void -MainWindow::cm_sel_rot_ccw () -{ - call_on_current_view (&lay::LayoutView::cm_sel_rot_ccw, tl::to_string (QObject::tr ("counter clockwise rotation of selection"))); -} - -void -MainWindow::cm_sel_rot_cw () -{ - call_on_current_view (&lay::LayoutView::cm_sel_rot_cw, tl::to_string (QObject::tr ("clockwise rotation of selection"))); -} - -void -MainWindow::cm_sel_flip_y () -{ - call_on_current_view (&lay::LayoutView::cm_sel_flip_y, tl::to_string (QObject::tr ("vertical flip of selection"))); -} - -void -MainWindow::cm_sel_flip_x () -{ - call_on_current_view (&lay::LayoutView::cm_sel_flip_x, tl::to_string (QObject::tr ("horizontal flip of selection"))); -} - -void -MainWindow::cm_edit_layer () -{ - call_on_current_view (&lay::LayoutView::cm_edit_layer, tl::to_string (QObject::tr ("edit a layer specification"))); -} - -void -MainWindow::cm_delete_layer () -{ - call_on_current_view (&lay::LayoutView::cm_delete_layer, tl::to_string (QObject::tr ("delete a layer"))); -} - -void -MainWindow::cm_clear_layer () -{ - call_on_current_view (&lay::LayoutView::cm_clear_layer, tl::to_string (QObject::tr ("clear a layer"))); -} - -void -MainWindow::cm_copy_layer () -{ - call_on_current_view (&lay::LayoutView::cm_copy_layer, tl::to_string (QObject::tr ("copy layer"))); -} - -void -MainWindow::cm_new_layer () -{ - call_on_current_view (&lay::LayoutView::cm_new_layer, tl::to_string (QObject::tr ("create a new layer"))); -} - -void -MainWindow::cm_layout_props () -{ - BEGIN_PROTECTED - - lay::LayoutView *curr = current_view (); - if (! curr) { - throw tl::Exception (tl::to_string (QObject::tr ("No view open to show layout properties for"))); - } - - LayoutPropertiesForm lp_form (this, curr, "layout_props_form"); - lp_form.exec (); - - END_PROTECTED -} - -void -MainWindow::cm_layout_stats () -{ - BEGIN_PROTECTED - - lay::LayoutView *curr = current_view (); - if (! curr) { - throw tl::Exception (tl::to_string (QObject::tr ("No view open to show layout statistics for"))); - } - - LayoutStatisticsForm lp_form (this, curr, "layout_props_form"); - lp_form.exec (); - - END_PROTECTED } void MainWindow::cm_clone () { - BEGIN_PROTECTED clone_current_view (); - END_PROTECTED } void @@ -3745,7 +2723,7 @@ MainWindow::clone_current_view () } // create a new view - view = new lay::LayoutView (current_view (), &m_manager, lay::ApplicationBase::instance ()->is_editable (), plugin_root (), mp_view_stack); + view = new lay::LayoutView (current_view (), &m_manager, lay::ApplicationBase::instance ()->is_editable (), dispatcher (), mp_view_stack); add_view (view); // set initial attributes @@ -4059,83 +3037,6 @@ MainWindow::close_view (int index) } } -void -MainWindow::cm_reload () -{ - BEGIN_PROTECTED - - if (current_view ()) { - - std::vector selected; - - if (current_view ()->cellviews () > 1) { - - SelectCellViewForm form (0, current_view (), tl::to_string (QObject::tr ("Select Layouts To Reload"))); - form.select_all (); - - if (form.exec () == QDialog::Accepted) { - selected = form.selected_cellviews (); - } - - } else if (current_view ()->cellviews () > 0) { - selected.push_back (0); - } - - if (selected.size () > 0) { - - int dirty_layouts = 0; - std::string dirty_files; - - for (std::vector ::const_iterator i = selected.begin (); i != selected.end (); ++i) { - - const lay::CellView &cv = current_view ()->cellview (*i); - - if (cv->layout ().is_editable () && cv->is_dirty ()) { - ++dirty_layouts; - if (dirty_layouts == max_dirty_files) { - dirty_files += "\n..."; - } else if (dirty_layouts < max_dirty_files) { - if (! dirty_files.empty ()) { - dirty_files += "\n"; - } - dirty_files += cv->name (); - } - } - - } - - bool can_reload = true; - if (dirty_layouts != 0) { - - QMessageBox mbox (this); - mbox.setText (tl::to_qstring (tl::to_string (QObject::tr ("The following layouts need saving:\n\n")) + dirty_files + "\n\nPress 'Reload Without Saving' to reload anyhow and discard changes.")); - mbox.setWindowTitle (QObject::tr ("Save Needed")); - mbox.setIcon (QMessageBox::Warning); - QAbstractButton *yes_button = mbox.addButton (QObject::tr ("Reload Without Saving"), QMessageBox::YesRole); - mbox.addButton (QMessageBox::Cancel); - - mbox.exec (); - - can_reload = (mbox.clickedButton() == yes_button); - - } - - if (can_reload) { - - // Actually reload - for (std::vector ::const_iterator i = selected.begin (); i != selected.end (); ++i) { - reload_layout (*i); - } - - } - - } - - } - - END_PROTECTED -} - void MainWindow::add_mru (const std::string &fn_rel) { @@ -4173,7 +3074,7 @@ MainWindow::add_mru (const std::string &fn_rel, const std::string &tech) } } - plugin_root ()->config_set (cfg_mru, config_str); + dispatcher ()->config_set (cfg_mru, config_str); } void @@ -4181,15 +3082,15 @@ MainWindow::do_update_file_menu () { std::string mru_menu = "file_menu.open_recent_menu"; - if (mp_menu->is_valid (mru_menu)) { + if (menu ()->is_valid (mru_menu)) { - Action open_recent_action = mp_menu->action (mru_menu); + Action open_recent_action = menu ()->action (mru_menu); open_recent_action.set_enabled (true); if (m_mru.size () > 0 && edits_enabled ()) { // rebuild MRU menu - mp_menu->clear_menu (mru_menu); + menu ()->clear_menu (mru_menu); for (std::vector >::iterator mru = m_mru.end (); mru != m_mru.begin (); ) { --mru; @@ -4198,7 +3099,7 @@ MainWindow::do_update_file_menu () gtf::action_connect (action.qaction (), SIGNAL (triggered ()), this, SLOT (open_recent ())); action.set_title (mru->first); action.qaction ()->setData (QVariant (int (i))); - mp_menu->insert_item (mru_menu + ".end", tl::sprintf ("open_recent_%d", i + 1), action); + menu ()->insert_item (mru_menu + ".end", tl::sprintf ("open_recent_%d", i + 1), action); } } else { @@ -4226,7 +3127,7 @@ MainWindow::open_recent () return; } - if (mp_layout_load_options->show_always () && !mp_layout_load_options->edit_global_options (plugin_root (), db::Technologies::instance ())) { + if (mp_layout_load_options->show_always () && !mp_layout_load_options->edit_global_options (dispatcher (), db::Technologies::instance ())) { return; } @@ -4275,7 +3176,7 @@ MainWindow::open (int mode) return; } - if (mp_layout_load_options->show_always () && !mp_layout_load_options->edit_global_options (plugin_root (), db::Technologies::instance ())) { + if (mp_layout_load_options->show_always () && !mp_layout_load_options->edit_global_options (dispatcher (), db::Technologies::instance ())) { return; } @@ -4366,7 +3267,7 @@ int MainWindow::do_create_view () { // create a new view - lay::LayoutView *view = new lay::LayoutView (&m_manager, lay::ApplicationBase::instance ()->is_editable (), plugin_root (), mp_view_stack); + lay::LayoutView *view = new lay::LayoutView (&m_manager, lay::ApplicationBase::instance ()->is_editable (), dispatcher (), mp_view_stack); add_view (view); // set initial attributes @@ -4571,56 +3472,6 @@ MainWindow::grid_micron () const return m_grid_micron; } -void -MainWindow::cm_inc_max_hier () -{ - BEGIN_PROTECTED - - int new_to = get_max_hier_levels () + 1; - set_hier_levels (std::make_pair (get_min_hier_levels (), new_to)); - - END_PROTECTED -} - -void -MainWindow::cm_dec_max_hier () -{ - BEGIN_PROTECTED - - int new_to = get_max_hier_levels () > 0 ? get_max_hier_levels () - 1 : 0; - set_hier_levels (std::make_pair (std::min (get_min_hier_levels (), new_to), new_to)); - - END_PROTECTED -} - -void -MainWindow::cm_max_hier () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->max_hier (); - } - - END_PROTECTED -} - -void -MainWindow::cm_max_hier_0 () -{ - BEGIN_PROTECTED - set_hier_levels (std::make_pair (std::min (get_min_hier_levels (), 0), 0)); - END_PROTECTED -} - -void -MainWindow::cm_max_hier_1 () -{ - BEGIN_PROTECTED - set_hier_levels (std::make_pair (std::min (get_min_hier_levels (), 0), 1)); - END_PROTECTED -} - void MainWindow::set_hier_levels (std::pair l) { @@ -4641,18 +3492,6 @@ MainWindow::get_hier_levels () const } } -void -MainWindow::cm_prev_display_state () -{ - BEGIN_PROTECTED - - if (has_prev_display_state ()) { - current_view ()->prev_display_state (); - } - - END_PROTECTED -} - bool MainWindow::has_prev_display_state () { @@ -4663,18 +3502,6 @@ MainWindow::has_prev_display_state () } } -void -MainWindow::cm_next_display_state () -{ - BEGIN_PROTECTED - - if (has_next_display_state ()) { - current_view ()->next_display_state (); - } - - END_PROTECTED -} - bool MainWindow::has_next_display_state () { @@ -4903,7 +3730,7 @@ MainWindow::show_assistant_topic (const std::string &s, bool modal) void MainWindow::cm_show_all_tips () { - plugin_root ()->config_set (cfg_tip_window_hidden, ""); + dispatcher ()->config_set (cfg_tip_window_hidden, ""); } void @@ -4919,71 +3746,110 @@ MainWindow::cm_help_about_qt () QApplication::aboutQt (); } -lay::Action & -MainWindow::action_for_slot (const char *slot) +std::vector +MainWindow::menu_symbols () { - std::map::iterator a = m_actions_for_slot.find (std::string (slot)); - if (a != m_actions_for_slot.end ()) { - return a->second; - } else { - Action a = Action::create_free_action (this); - gtf::action_connect (a.qaction (), SIGNAL (triggered ()), this, slot); - return m_actions_for_slot.insert (std::make_pair (std::string (slot), a)).first->second; - } -} - -lay::Action * -MainWindow::create_config_action (const std::string &title, const std::string &cname, const std::string &cvalue) -{ - lay::ConfigureAction *ca = new lay::ConfigureAction(plugin_root (), title, cname, cvalue); - m_ca_collection.push_back (ca); - return ca; -} - -lay::Action * -MainWindow::create_config_action (const std::string &cname, const std::string &cvalue) -{ - lay::ConfigureAction *ca = new lay::ConfigureAction(plugin_root (), std::string (), cname, cvalue); - m_ca_collection.push_back (ca); - return ca; -} - -void -MainWindow::register_config_action (const std::string &name, lay::ConfigureAction *action) -{ - std::map >::iterator ca = m_configuration_actions.insert (std::make_pair (name, std::vector ())).first; - for (std::vector::iterator a = ca->second.begin (); a != ca->second.end (); ++a) { - if (*a == action) { - return; // already registered - } - } - - ca->second.push_back (action); -} - -void -MainWindow::unregister_config_action (const std::string &name, lay::ConfigureAction *action) -{ - std::map >::iterator ca = m_configuration_actions.find (name); - if (ca != m_configuration_actions.end ()) { - for (std::vector::iterator a = ca->second.begin (); a != ca->second.end (); ++a) { - if (*a == action) { - ca->second.erase (a); - return; - } - } - } + // TODO: currently these are all symbols from all plugins + return lay::PluginDeclaration::menu_symbols (); } void MainWindow::menu_activated (const std::string &symbol) { - // TODO: this can be part of the Plugin scheme, but the plugin root has no idea which is the active - // view. - if (current_view ()) { - current_view ()->menu_activated (symbol); + if (symbol == "cm_navigator_freeze") { + cm_navigator_freeze (); + } else if (symbol == "cm_navigator_close") { + cm_navigator_close (); + } else if (symbol == "cm_view_log") { + cm_view_log (); + } else if (symbol == "cm_print") { + cm_print (); + } else if (symbol == "cm_exit") { + cm_exit (); + } else if (symbol == "cm_reset_window_state") { + cm_reset_window_state (); + } else if (symbol == "cm_undo") { + cm_undo (); + } else if (symbol == "cm_redo") { + cm_redo (); + } else if (symbol == "cm_goto_position") { + cm_goto_position (); + } else if (symbol == "cm_manage_bookmarks") { + cm_manage_bookmarks (); + } else if (symbol == "cm_bookmark_view") { + cm_bookmark_view (); + } else if (symbol == "cm_cancel") { + cm_cancel (); + } else if (symbol == "cm_save_layer_props") { + cm_save_layer_props (); + } else if (symbol == "cm_load_layer_props") { + cm_load_layer_props (); + } else if (symbol == "cm_save_session") { + cm_save_session (); + } else if (symbol == "cm_restore_session") { + cm_restore_session (); + } else if (symbol == "cm_save_bookmarks") { + cm_save_bookmarks (); + } else if (symbol == "cm_load_bookmarks") { + cm_load_bookmarks (); + } else if (symbol == "cm_screenshot") { + cm_screenshot (); + } else if (symbol == "cm_save_current_cell_as") { + cm_save_current_cell_as (); + } else if (symbol == "cm_save") { + cm_save (); + } else if (symbol == "cm_save_as") { + cm_save_as (); + } else if (symbol == "cm_save_all") { + cm_save_all (); + } else if (symbol == "cm_setup") { + cm_setup (); + } else if (symbol == "cm_open_too") { + cm_open_too (); + } else if (symbol == "cm_open_new_view") { + cm_open_new_view (); + } else if (symbol == "cm_open") { + cm_open (); + } else if (symbol == "cm_pull_in") { + cm_pull_in (); + } else if (symbol == "cm_reader_options") { + cm_reader_options (); + } else if (symbol == "cm_writer_options") { + cm_writer_options (); + } else if (symbol == "cm_new_panel") { + cm_new_panel (); + } else if (symbol == "cm_new_layout") { + cm_new_layout (); + } else if (symbol == "cm_clone") { + cm_clone (); + } else if (symbol == "cm_close_all") { + cm_close_all (); + } else if (symbol == "cm_close") { + cm_close (); + } else if (symbol == "cm_packages") { + cm_packages (); + } else if (symbol == "cm_technologies") { + cm_technologies (); + } else if (symbol == "cm_macro_editor") { + cm_macro_editor (); + } else if (symbol == "cm_show_assistant") { + cm_show_assistant (); + } else if (symbol == "cm_show_all_tips") { + cm_show_all_tips (); + } else if (symbol == "cm_help_about") { + cm_help_about (); + } else if (symbol == "cm_help_about_qt") { + cm_help_about_qt (); } else { - throw tl::Exception (tl::to_string (QObject::tr ("No view is active"))); + + // TODO: this can be part of the Plugin scheme, but the plugin root has no idea which is the active + // view. + if (current_view ()) { + current_view ()->menu_activated (symbol); + } else { + throw tl::Exception (tl::to_string (QObject::tr ("No view is active"))); + } + } } @@ -4997,463 +3863,13 @@ MainWindow::menu_changed () void MainWindow::do_update_menu () { - mp_menu->build (menuBar (), mp_tool_bar); + menu ()->build (menuBar (), mp_tool_bar); lay::GuiApplication *app = dynamic_cast (qApp); if (app) { app->force_update_app_menu (); } } -void -MainWindow::cm_cell_user_properties () -{ - call_on_current_view (&lay::LayoutView::cm_cell_user_properties, tl::to_string (QObject::tr ("edit cell's user properties"))); -} - -void -MainWindow::cm_cell_delete () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_cell_delete (); - } - - END_PROTECTED -} - -void -MainWindow::cm_cell_replace () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_cell_replace (); - } - - END_PROTECTED -} - -void -MainWindow::cm_cell_rename () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_cell_rename (); - } - - END_PROTECTED -} - -void -MainWindow::cm_cell_flatten () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_cell_flatten (); - } - - END_PROTECTED -} - -void -MainWindow::cm_cell_select () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_cell_select (); - } - - END_PROTECTED -} - -void -MainWindow::cm_cell_hide () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_cell_hide (); - } - - END_PROTECTED -} - -void -MainWindow::cm_cell_show () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_cell_show (); - } - - END_PROTECTED -} - -void -MainWindow::cm_cell_show_all () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_cell_show_all (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_select_all () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_select_all (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_new_tab () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_new_tab (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_rename_tab () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_rename_tab (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_remove_tab () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_remove_tab (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_make_invalid () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_make_invalid (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_make_valid () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_make_valid (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_hide_all () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_hide_all (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_hide () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_hide (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_show_only () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_show_only (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_show_all () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_show_all (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_show () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_show (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_rename () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_rename (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_delete () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_delete (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_insert () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_insert (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_group () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_group (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_ungroup () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_ungroup (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_source () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_source (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_sort_by_name () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_sort_by_name (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_sort_by_ild () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_sort_by_ild (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_sort_by_idl () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_sort_by_idl (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_sort_by_ldi () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_sort_by_ldi (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_sort_by_dli () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_sort_by_dli (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_regroup_by_index () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_regroup_by_index (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_regroup_by_datatype () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_regroup_by_datatype (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_regroup_by_layer () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_regroup_by_layer (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_regroup_flatten () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_regroup_flatten (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_expand_all () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_expand_all (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_add_missing () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_add_missing (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_remove_unused () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_remove_unused (); - } - - END_PROTECTED -} - void MainWindow::dragEnterEvent(QDragEnterEvent *event) { @@ -5637,11 +4053,11 @@ MainWindow::plugin_registered (lay::PluginDeclaration *cls) // store current state in configuration save_state_to_config (); - cls->init_menu (); + cls->init_menu (dispatcher ()); // recreate all plugins for (std::vector ::iterator vp = mp_views.begin (); vp != mp_views.end (); ++vp) { - (*vp)->create_plugins (plugin_root ()); + (*vp)->create_plugins (); } } @@ -5652,27 +4068,29 @@ MainWindow::plugin_removed (lay::PluginDeclaration *cls) // recreate all plugins except the one that got removed for (std::vector ::iterator vp = mp_views.begin (); vp != mp_views.end (); ++vp) { - (*vp)->create_plugins (plugin_root (), cls); + (*vp)->create_plugins (cls); } } // ------------------------------------------------------------ // Implementation of the PluginRootToMainWindow bride -PluginRootToMainWindow::PluginRootToMainWindow () - : mp_main_window (0) +DispatcherToMainWindow::DispatcherToMainWindow () + : lay::Dispatcher (0, false), + mp_main_window (0) + { // .. nothing yet .. } void -PluginRootToMainWindow::attach_to (lay::MainWindow *main_window) +DispatcherToMainWindow::attach_to (lay::MainWindow *main_window) { mp_main_window = main_window; } void -PluginRootToMainWindow::plugin_registered (lay::PluginDeclaration *cls) +DispatcherToMainWindow::plugin_registered (lay::PluginDeclaration *cls) { if (mp_main_window.get ()) { mp_main_window->plugin_registered (cls); @@ -5683,7 +4101,7 @@ PluginRootToMainWindow::plugin_registered (lay::PluginDeclaration *cls) } void -PluginRootToMainWindow::plugin_removed (lay::PluginDeclaration *cls) +DispatcherToMainWindow::plugin_removed (lay::PluginDeclaration *cls) { if (mp_main_window.get ()) { mp_main_window->plugin_removed (cls); @@ -5694,7 +4112,7 @@ PluginRootToMainWindow::plugin_removed (lay::PluginDeclaration *cls) } void -PluginRootToMainWindow::select_mode (int mode) +DispatcherToMainWindow::select_mode (int mode) { if (mp_main_window.get ()) { mp_main_window->select_mode (mode); @@ -5702,7 +4120,7 @@ PluginRootToMainWindow::select_mode (int mode) } void -PluginRootToMainWindow::menu_activated (const std::string &symbol) +DispatcherToMainWindow::menu_activated (const std::string &symbol) { if (mp_main_window.get ()) { mp_main_window->menu_activated (symbol); @@ -5811,5 +4229,118 @@ HelpAboutDialog::~HelpAboutDialog () mp_ui = 0; } +// ------------------------------------------------------------ +// Declaration of the "plugin" for the menu entries + +class MainWindowPluginDeclaration + : public lay::PluginDeclaration +{ +public: + virtual void get_menu_entries (std::vector &menu_entries) const + { + std::string at; + + at = ".end"; + menu_entries.push_back (lay::submenu ("file_menu", at, tl::to_string (QObject::tr ("&File")))); + menu_entries.push_back (lay::submenu ("edit_menu", at, tl::to_string (QObject::tr ("&Edit")))); + menu_entries.push_back (lay::submenu ("view_menu", at, tl::to_string (QObject::tr ("&View")))); + menu_entries.push_back (lay::submenu ("bookmark_menu", at, tl::to_string (QObject::tr ("&Bookmarks")))); + menu_entries.push_back (lay::submenu ("zoom_menu", at, tl::to_string (QObject::tr ("&Display")))); + menu_entries.push_back (lay::submenu ("tools_menu", at, tl::to_string (QObject::tr ("&Tools")))); + menu_entries.push_back (lay::submenu ("macros_menu", at, tl::to_string (QObject::tr ("&Macros")))); + menu_entries.push_back (lay::separator ("help_group", at)); + menu_entries.push_back (lay::submenu ("help_menu", at, tl::to_string (QObject::tr ("&Help")))); + menu_entries.push_back (lay::submenu ("@secrets", at, tl::to_string (QObject::tr ("Secret Features")))); + menu_entries.push_back (lay::submenu ("@toolbar", at, std::string ())); + + at = "file_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_new_layout", "new_layout:edit:edit_mode", at, tl::to_string (QObject::tr ("New Layout")))); + menu_entries.push_back (lay::menu_item ("cm_new_panel", "new_panel:edit:edit_mode", at, tl::to_string (QObject::tr ("New Panel")))); + menu_entries.push_back (lay::separator ("post_new_group:edit_mode", at)); + menu_entries.push_back (lay::menu_item ("cm_open", "open:edit", at, tl::to_string (QObject::tr ("Open")))); + menu_entries.push_back (lay::menu_item ("cm_open_too", "open_same_panel:edit", at, tl::to_string (QObject::tr ("Open In Same Panel(Shift+Ctrl+O)")))); + menu_entries.push_back (lay::menu_item ("cm_open_new_view", "open_new_panel", at, tl::to_string (QObject::tr ("Open In New Panel(Ctrl+O)")))); + menu_entries.push_back (lay::menu_item ("cm_close", "close:edit", at, tl::to_string (QObject::tr ("Close(Ctrl+W)")))); + menu_entries.push_back (lay::menu_item ("cm_close_all", "close_all:edit", at, tl::to_string (QObject::tr ("Close All(Shift+Ctrl+W)")))); + menu_entries.push_back (lay::menu_item ("cm_clone", "clone", at, tl::to_string (QObject::tr ("Clone Panel")))); + menu_entries.push_back (lay::menu_item ("cm_reload", "reload:edit", at, tl::to_string (QObject::tr ("Reload(Ctrl+R)")))); + menu_entries.push_back (lay::menu_item ("cm_pull_in", "pull_in:edit", at, tl::to_string (QObject::tr ("Pull In Other Layout")))); + menu_entries.push_back (lay::menu_item ("cm_reader_options", "reader_options", at, tl::to_string (QObject::tr ("Reader Options")))); + menu_entries.push_back (lay::separator ("open_recent_group", at)); + menu_entries.push_back (lay::submenu ("open_recent_menu:edit", at, tl::to_string (QObject::tr ("Open Recent")))); + menu_entries.push_back (lay::separator ("import_group", at)); + menu_entries.push_back (lay::submenu ("import_menu:edit", at, tl::to_string (QObject::tr ("Import")))); + menu_entries.push_back (lay::separator ("save_group", at)); + menu_entries.push_back (lay::menu_item ("cm_save", "save:hide_vo", at, tl::to_string (QObject::tr ("Save")))); + menu_entries.push_back (lay::menu_item ("cm_save_as", "save_as:hide_vo", at, tl::to_string (QObject::tr ("Save As")))); + menu_entries.push_back (lay::menu_item ("cm_save_all", "save_all:hide_vo", at, tl::to_string (QObject::tr ("Save All")))); + menu_entries.push_back (lay::menu_item ("cm_writer_options", "writer_options:hide_vo", at, tl::to_string (QObject::tr ("Writer Options")))); + menu_entries.push_back (lay::separator ("setup_group", at)); + menu_entries.push_back (lay::menu_item ("cm_setup", "setup:edit", at, tl::to_string (QObject::tr ("Setup")))); + menu_entries.push_back (lay::separator ("misc_group", at)); + menu_entries.push_back (lay::menu_item ("cm_screenshot", "screenshot:edit", at, tl::to_string (QObject::tr ("Screenshot(Print)")))); + menu_entries.push_back (lay::menu_item ("cm_layout_props", "layout_props:edit", at, tl::to_string (QObject::tr ("Layout Properties")))); + menu_entries.push_back (lay::menu_item ("cm_layout_stats", "layout_stats:edit", at, tl::to_string (QObject::tr ("Layout Statistics")))); + menu_entries.push_back (lay::separator ("layer_group", at)); + menu_entries.push_back (lay::menu_item ("cm_load_layer_props", "load_layer_props:edit", at, tl::to_string (QObject::tr ("Load Layer Properties")))); + menu_entries.push_back (lay::menu_item ("cm_save_layer_props", "save_layer_props:edit", at, tl::to_string (QObject::tr ("Save Layer Properties")))); + menu_entries.push_back (lay::separator ("session_group", at)); + menu_entries.push_back (lay::menu_item ("cm_restore_session", "restore_session:edit", at, tl::to_string (QObject::tr ("Restore Session")))); + menu_entries.push_back (lay::menu_item ("cm_save_session", "save_session", at, tl::to_string (QObject::tr ("Save Session")))); + menu_entries.push_back (lay::separator ("log_group", at)); + menu_entries.push_back (lay::menu_item ("cm_view_log", "view_log", at, tl::to_string (QObject::tr ("Log Viewer")))); + menu_entries.push_back (lay::separator ("print_group", at)); + menu_entries.push_back (lay::menu_item ("cm_print", "print", at, tl::to_string (QObject::tr ("Print(Ctrl+P)")))); + menu_entries.push_back (lay::separator ("exit_group", at)); + menu_entries.push_back (lay::menu_item ("cm_exit", "exit", at, tl::to_string (QObject::tr ("Exit(Ctrl+Q)")))); + + at = "view_menu.end"; + menu_entries.push_back (lay::config_menu_item ("show_grid", at, tl::to_string (QObject::tr ("Show Grid")), cfg_grid_visible, "?")), + menu_entries.push_back (lay::submenu ("default_grid:default_grids_group", at, tl::to_string (QObject::tr ("Grid")))); + menu_entries.push_back (lay::separator ("layout_group", at)); + menu_entries.push_back (lay::config_menu_item ("show_markers", at, tl::to_string (QObject::tr ("Show Markers")), cfg_markers_visible, "?")); + menu_entries.push_back (lay::config_menu_item ("show_texts", at, tl::to_string (QObject::tr ("Show Texts")), cfg_text_visible, "?")); + menu_entries.push_back (lay::config_menu_item ("show_cell_boxes", at, tl::to_string (QObject::tr ("Show Cell Frames")), cfg_cell_box_visible, "?")); + menu_entries.push_back (lay::config_menu_item ("no_stipples", at, tl::to_string (QObject::tr ("Show Layers Without Fill")), cfg_no_stipple, "?")); + menu_entries.push_back (lay::config_menu_item ("synchronized_views", at, tl::to_string (QObject::tr ("Synchronized Views")), cfg_synchronized_views, "?")); + menu_entries.push_back (lay::config_menu_item ("edit_top_level_selection:edit_mode", at, tl::to_string (QObject::tr ("Select Top Level Objects")), edt::cfg_edit_top_level_selection, "?")); + menu_entries.push_back (lay::separator ("panels_group", at)); + menu_entries.push_back (lay::config_menu_item ("show_toolbar", at, tl::to_string (QObject::tr ("Toolbar")), cfg_show_toolbar, "?")); + menu_entries.push_back (lay::config_menu_item ("show_navigator", at, tl::to_string (QObject::tr ("Navigator")), cfg_show_navigator, "?")); + menu_entries.push_back (lay::config_menu_item ("show_layer_panel", at, tl::to_string (QObject::tr ("Layers")), cfg_show_layer_panel, "?")); + menu_entries.push_back (lay::config_menu_item ("show_layer_toolbox", at, tl::to_string (QObject::tr ("Layer Toolbox")), cfg_show_layer_toolbox, "?")); + menu_entries.push_back (lay::config_menu_item ("show_hierarchy_panel", at, tl::to_string (QObject::tr ("Cells")), cfg_show_hierarchy_panel, "?")); + menu_entries.push_back (lay::config_menu_item ("show_libraries_view", at, tl::to_string (QObject::tr ("Libraries")), cfg_show_libraries_view, "?")); + menu_entries.push_back (lay::config_menu_item ("show_bookmarks_view", at, tl::to_string (QObject::tr ("Bookmarks")), cfg_show_bookmarks_view, "?")); + menu_entries.push_back (lay::menu_item ("cm_reset_window_state", "reset_window_state", at, tl::to_string (QObject::tr ("Restore Window")))), + menu_entries.push_back (lay::separator ("selection_group", at)); + menu_entries.push_back (lay::config_menu_item ("transient_selection", at, tl::to_string (QObject::tr ("Highlight Object Under Mouse")), cfg_sel_transient_mode, "?")); + + at = "help_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_show_all_tips", "show_all_tips", at, tl::to_string (QObject::tr ("Show All Tips")))); + menu_entries.push_back (lay::separator ("help_topics_group", at)); + menu_entries.push_back (lay::menu_item ("cm_show_assistant", "assistant", at, tl::to_string (QObject::tr ("Assistant")))); + menu_entries.push_back (lay::menu_item ("cm_help_about", "about", at, tl::to_string (QObject::tr ("About")))); + menu_entries.push_back (lay::menu_item ("cm_help_about_qt", "about_qt", at, tl::to_string (QObject::tr ("About Qt")))); + + at = "tools_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_packages", "packages", at, tl::to_string (QObject::tr ("Manage Packages")))); + menu_entries.push_back (lay::menu_item ("cm_technologies", "technologies", at, tl::to_string (QObject::tr ("Manage Technologies")))); + menu_entries.push_back (lay::separator ("verification_group", at)); + menu_entries.push_back (lay::separator ("post_verification_group", at)); + + at = "macros_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_macro_editor", "macro_development", at, tl::to_string (QObject::tr ("Macro Development(F5)")))); + menu_entries.push_back (lay::separator ("macros_group", at)); + + at = "@toolbar.end"; + menu_entries.push_back (lay::menu_item ("cm_prev_display_state", "prev_display_state", at, "-")); + menu_entries.push_back (lay::menu_item ("cm_next_display_state", "next_display_state", at, "-")); + menu_entries.push_back (lay::separator ("toolbar_post_navigation_group", at)); + } +}; + +static tl::RegisteredClass config_decl (new MainWindowPluginDeclaration (), -100, "MainWindowPlugin"); + } // namespace lay diff --git a/src/lay/lay/layMainWindow.h b/src/lay/lay/layMainWindow.h index 4429ee394..78d133f7f 100644 --- a/src/lay/lay/layMainWindow.h +++ b/src/lay/lay/layMainWindow.h @@ -40,7 +40,7 @@ #include "dbManager.h" #include "dbLoadLayoutOptions.h" #include "layAbstractMenu.h" -#include "layAbstractMenuProvider.h" +#include "layDispatcher.h" #include "layLayoutView.h" #include "layPlugin.h" #include "layProgress.h" @@ -118,8 +118,7 @@ private: class LAY_PUBLIC MainWindow : public QMainWindow, - public lay::Plugin, - public lay::AbstractMenuProvider + public lay::Dispatcher { Q_OBJECT public: @@ -140,21 +139,13 @@ public: ~MainWindow (); /** - * @brief Implementation of the AbstractMenuProvider interface + * @brief Implementation of the Dispatcher interface */ QWidget *menu_parent_widget () { return this; } - /** - * @brief Get the main menu abstraction object - */ - AbstractMenu *menu () - { - return mp_menu; - } - /** * @brief Shows the window * @@ -407,12 +398,12 @@ public: bool show_progress_bar (bool show); /** - * @brief Implementation of the PluginRoot interface + * @brief Implementation of the Plugin interface */ bool configure (const std::string &name, const std::string &value); /** - * @brief Implementation of the PluginRoot interface + * @brief Implementation of the Plugin interface */ void config_finalize (); @@ -536,6 +527,11 @@ public: */ void menu_activated (const std::string &symbol); + /** + * @brief Gets the available menu symbols + */ + static std::vector menu_symbols (); + /** * @brief Get the action for a slot */ @@ -664,11 +660,6 @@ public slots: */ void select_mode (int m); - /** - * @brief Called when one of the built-in modes (i.e. select, move) is selected - */ - void intrinsic_mode_triggered (); - void update_action_states (); void cancel (); void redraw (); @@ -681,157 +672,6 @@ public slots: void view_selected (int index); void view_title_changed (); - // menu callbacks for main window - void cm_reset_window_state (); - void cm_select_all (); - void cm_unselect_all (); - void cm_undo (); - void cm_redo (); - void cm_delete (); - void cm_show_properties (); - void cm_copy (); - void cm_paste (); - void cm_paste_interactive (); - void cm_duplicate (); - void cm_duplicate_interactive (); - void cm_cut (); - void cm_zoom_fit_sel (); - void cm_zoom_fit (); - void cm_zoom_in (); - void cm_zoom_out (); - void cm_pan_up (); - void cm_pan_down (); - void cm_pan_left (); - void cm_pan_right (); - void cm_save_session (); - void cm_restore_session (); - void cm_setup (); - void cm_save_as (); - void cm_save_all (); - void cm_save (); - void cm_reload (); - void cm_close (); - void cm_close_all (); - void cm_clone (); - void cm_layout_props (); - void cm_layout_stats (); - void cm_inc_max_hier (); - void cm_dec_max_hier (); - void cm_max_hier (); - void cm_max_hier_0 (); - void cm_max_hier_1 (); - void cm_prev_display_state (); - void cm_next_display_state (); - void cm_cancel (); - void cm_redraw (); - void cm_screenshot (); - void cm_save_layer_props (); - void cm_load_layer_props (); - void cm_save_bookmarks (); - void cm_load_bookmarks (); - void cm_select_cell (); - void cm_select_current_cell (); - void cm_print (); - void cm_exit (); - void cm_view_log (); - void cm_bookmark_view (); - void cm_manage_bookmarks (); - void cm_goto_position (); - void cm_show_all_tips (); - void cm_help_about (); - void cm_help_about_qt (); - void cm_macro_editor (); - void cm_packages (); - void cm_technologies (); - void cm_open_too (); - void cm_open_new_view (); - void cm_open (); - void cm_pull_in (); - void cm_reader_options (); - void cm_writer_options (); - void cm_new_layout (); - void cm_new_panel (); - void cm_adjust_origin (); - void cm_new_cell (); - void cm_new_layer (); - void cm_clear_layer (); - void cm_delete_layer (); - void cm_edit_layer (); - void cm_copy_layer (); - void cm_lay_convert_to_static (); - void cm_lay_flip_x (); - void cm_lay_flip_y (); - void cm_lay_rot_cw (); - void cm_lay_rot_ccw (); - void cm_lay_free_rot (); - void cm_lay_scale (); - void cm_lay_move (); - void cm_sel_flip_x (); - void cm_sel_flip_y (); - void cm_sel_rot_cw (); - void cm_sel_rot_ccw (); - void cm_sel_free_rot (); - void cm_sel_scale (); - void cm_sel_move (); - void cm_sel_move_to (); - void cm_sel_move_interactive (); - void cm_show_assistant (); - - // forwarded to the current view: layer list context menu - void cm_lv_new_tab (); - void cm_lv_remove_tab (); - void cm_lv_rename_tab (); - void cm_lv_make_valid (); - void cm_lv_make_invalid (); - void cm_lv_hide (); - void cm_lv_hide_all (); - void cm_lv_show (); - void cm_lv_show_all (); - void cm_lv_show_only (); - void cm_lv_rename (); - void cm_lv_select_all (); - void cm_lv_delete (); - void cm_lv_insert (); - void cm_lv_group (); - void cm_lv_ungroup (); - void cm_lv_source (); - void cm_lv_sort_by_name (); - void cm_lv_sort_by_ild (); - void cm_lv_sort_by_idl (); - void cm_lv_sort_by_ldi (); - void cm_lv_sort_by_dli (); - void cm_lv_regroup_by_index (); - void cm_lv_regroup_by_datatype (); - void cm_lv_regroup_by_layer (); - void cm_lv_regroup_flatten (); - void cm_lv_expand_all (); - void cm_lv_add_missing (); - void cm_lv_remove_unused (); - void cm_lv_copy (); - void cm_lv_cut (); - void cm_lv_paste (); - - // forwarded to the current view: cell list context menu - void cm_cell_user_properties (); - void cm_cell_delete (); - void cm_cell_replace (); - void cm_cell_rename (); - void cm_cell_flatten (); - void cm_cell_convert_to_static (); - void cm_cell_copy (); - void cm_cell_cut (); - void cm_cell_paste (); - void cm_cell_select (); - void cm_open_current_cell (); - void cm_save_current_cell_as (); - void cm_cell_hide (); - void cm_cell_show (); - void cm_cell_show_all (); - - // forwarded to the navigator - void cm_navigator_freeze (); - void cm_navigator_close (); - /** * @brief shows the given URL as a non-modal help window * Intended as a connection target for QLabel linkVisisted signals. @@ -865,12 +705,11 @@ protected: void do_update_file_menu (); private: - friend class PluginRootToMainWindow; + friend class DispatcherToMainWindow; TextProgressDelegate m_text_progress; // Main menu - AbstractMenu *mp_menu; QTabBar *mp_tab_bar; QToolBar *mp_tool_bar; QDockWidget *mp_navigator_dock_widget; @@ -922,9 +761,7 @@ private: bool m_default_grids_updated; std::vector m_default_grid_actions; std::vector > m_key_bindings; - double m_new_cell_window_size; bool m_new_layout_current_panel; - std::string m_new_cell_cell_name; bool m_synchronized_views; bool m_synchronous; bool m_busy; @@ -935,10 +772,6 @@ private: std::auto_ptr mp_printer; std::vector m_changed_files; - std::map m_actions_for_slot; - std::map > m_configuration_actions; - tl::shared_collection m_ca_collection; - // the object manager (undo/redo mechanism and others) db::Manager m_manager; @@ -949,8 +782,48 @@ private: void closeEvent (QCloseEvent *event); void resizeEvent (QResizeEvent *event); - void do_cm_paste (bool interactive); - void do_cm_duplicate (bool interactive); + void cm_navigator_freeze (); + void cm_navigator_close (); + void cm_view_log (); + void cm_print (); + void cm_exit (); + void cm_reset_window_state (); + void cm_undo (); + void cm_redo (); + void cm_goto_position (); + void cm_manage_bookmarks (); + void cm_bookmark_view (); + void cm_cancel (); + void cm_save_layer_props (); + void cm_load_layer_props (); + void cm_save_session (); + void cm_restore_session (); + void cm_save_bookmarks (); + void cm_load_bookmarks (); + void cm_screenshot (); + void cm_save_current_cell_as (); + void cm_save (); + void cm_save_as (); + void cm_save_all (); + void cm_setup (); + void cm_open_too (); + void cm_open_new_view (); + void cm_open (); + void cm_pull_in (); + void cm_reader_options (); + void cm_writer_options (); + void cm_new_panel (); + void cm_new_layout (); + void cm_clone (); + void cm_close_all (); + void cm_close (); + void cm_packages (); + void cm_technologies (); + void cm_macro_editor (); + void cm_show_assistant (); + void cm_show_all_tips (); + void cm_help_about (); + void cm_help_about_qt (); void format_message (); @@ -982,11 +855,11 @@ private: void apply_hidden (const std::vector > &hidden); }; -class LAY_PUBLIC PluginRootToMainWindow - : public lay::PluginRoot +class LAY_PUBLIC DispatcherToMainWindow + : public lay::Dispatcher { public: - PluginRootToMainWindow (); + DispatcherToMainWindow (); void attach_to (lay::MainWindow *main_window); @@ -996,8 +869,8 @@ public: virtual void menu_activated (const std::string &symbol); private: - PluginRootToMainWindow (const PluginRootToMainWindow &); - PluginRootToMainWindow &operator= (const PluginRootToMainWindow &); + DispatcherToMainWindow (const DispatcherToMainWindow &); + DispatcherToMainWindow &operator= (const DispatcherToMainWindow &); tl::weak_ptr mp_main_window; }; diff --git a/src/lay/lay/layNavigator.cc b/src/lay/lay/layNavigator.cc index 3fe535075..3b7d6801b 100644 --- a/src/lay/lay/layNavigator.cc +++ b/src/lay/lay/layNavigator.cc @@ -503,32 +503,6 @@ Navigator::~Navigator () } } -void -Navigator::init_menu (AbstractMenu &menu) -{ - MenuLayoutEntry navigator_main_menu [] = { - MenuLayoutEntry ("navigator_show_images", tl::to_string (QObject::tr ("Show Images")), std::make_pair (cfg_navigator_show_images, "?")), - MenuLayoutEntry ("navigator_all_hier_levels", tl::to_string (QObject::tr ("Show All Hierarchy Levels")), std::make_pair (cfg_navigator_all_hier_levels, "?")), - MenuLayoutEntry::separator ("navigator_options_group"), - MenuLayoutEntry ("navigator_freeze", tl::to_string (QObject::tr ("Freeze")), SLOT (cm_navigator_freeze ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry navigator_menu [] = { - MenuLayoutEntry ("navigator_main_menu", tl::to_string (QObject::tr ("Options")), navigator_main_menu), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry navigator_detached_menu [] = { - MenuLayoutEntry ("@@navigator_menu", "", navigator_menu), - MenuLayoutEntry::last () - }; - - menu.init (navigator_detached_menu); - - menu.action (freeze_action_path).set_checkable (true); -} - void Navigator::menu_changed () { @@ -598,8 +572,8 @@ Navigator::showEvent (QShowEvent *) void Navigator::closeEvent (QCloseEvent *) { - lay::PluginRoot::instance ()->config_set (cfg_show_navigator, "false"); - lay::PluginRoot::instance ()->config_end (); + mp_main_window->config_set (cfg_show_navigator, "false"); + mp_main_window->config_end (); } void @@ -793,5 +767,33 @@ Navigator::update () mp_service->update_marker (); } +// ------------------------------------------------------------ +// Declaration of the "plugin" for the menu entries + +class NavigatorPluginDeclaration + : public lay::PluginDeclaration +{ +public: + virtual void get_menu_entries (std::vector &menu_entries) const + { + std::string at; + + at = ".end"; + menu_entries.push_back (lay::submenu ("@@navigator_menu", at, std::string ())); + + at = "@@navigator_menu.end"; + menu_entries.push_back (lay::submenu ("navigator_main_menu", at, tl::to_string (QObject::tr ("Options")))); + + at = "@@navigator_menu.navigator_main_menu.end"; + menu_entries.push_back (lay::config_menu_item ("navigator_show_images", at, tl::to_string (QObject::tr ("Show Images")), cfg_navigator_show_images, "?")); + menu_entries.push_back (lay::config_menu_item ("navigator_all_hier_levels", at, tl::to_string (QObject::tr ("Show All Hierarchy Levels")), cfg_navigator_all_hier_levels, "?")); + menu_entries.push_back (lay::separator ("navigator_options_group", at)); + menu_entries.push_back (lay::menu_item ("cm_navigator_freeze", "navigator_freeze", at, tl::to_string (QObject::tr ("Freeze")))); + menu_entries.back ().checkable = true; + } +}; + +static tl::RegisteredClass config_decl (new NavigatorPluginDeclaration (), -1, "NavigatorPlugin"); + } diff --git a/src/lay/lay/layNavigator.h b/src/lay/lay/layNavigator.h index a3571c951..7b1702582 100644 --- a/src/lay/lay/layNavigator.h +++ b/src/lay/lay/layNavigator.h @@ -84,8 +84,6 @@ public: void all_hier_levels (bool f); void show_images (bool f); - static void init_menu (AbstractMenu &menu); - protected: virtual void closeEvent (QCloseEvent *event); virtual void showEvent (QShowEvent *event); diff --git a/src/lay/lay/laySaltController.h b/src/lay/lay/laySaltController.h index 882fcbb25..b4e2d6792 100644 --- a/src/lay/lay/laySaltController.h +++ b/src/lay/lay/laySaltController.h @@ -69,17 +69,17 @@ public: /** * @brief Reimplementation of the PluginDeclaration interface */ - virtual void initialize (lay::PluginRoot *root); + virtual void initialize (lay::Dispatcher *root); /** * @brief Reimplementation of the PluginDeclaration interface */ - virtual void initialized (lay::PluginRoot *root); + virtual void initialized (lay::Dispatcher *root); /** * @brief Reimplementation of the PluginDeclaration interface */ - virtual void uninitialize (lay::PluginRoot *root); + virtual void uninitialize (lay::Dispatcher *root); /** * @brief Reimplementation of the PluginDeclaration interface @@ -104,7 +104,7 @@ public: /** * @brief Reimplementation of the PluginDeclaration interface */ - bool can_exit (lay::PluginRoot *root) const; + bool can_exit (lay::Dispatcher *root) const; /** * @brief Reimplementation of the PluginDeclaration interface @@ -191,7 +191,7 @@ signals: private: lay::SaltManagerDialog *mp_salt_dialog; lay::MainWindow *mp_mw; - lay::PluginRoot * mp_plugin_root; + lay::Dispatcher * mp_plugin_root; std::string m_salt_mine_url; lay::Salt m_salt; tl::FileSystemWatcher *m_file_watcher; diff --git a/src/lay/lay/laySettingsForm.cc b/src/lay/lay/laySettingsForm.cc index 3d43062e2..cc8fcb394 100644 --- a/src/lay/lay/laySettingsForm.cc +++ b/src/lay/lay/laySettingsForm.cc @@ -40,9 +40,9 @@ namespace lay // ------------------------------------------------------------- -SettingsForm::SettingsForm (QWidget *parent, lay::PluginRoot *plugin_root, const char *name) +SettingsForm::SettingsForm (QWidget *parent, lay::Dispatcher *dispatcher, const char *name) : QDialog (parent), Ui::SettingsForm (), - mp_plugin_root (plugin_root), m_finalize_recursion (false) + mp_plugin_root (dispatcher), m_finalize_recursion (false) { setObjectName (QString::fromUtf8 (name)); diff --git a/src/lay/lay/laySettingsForm.h b/src/lay/lay/laySettingsForm.h index 166dcb422..504d40c2f 100644 --- a/src/lay/lay/laySettingsForm.h +++ b/src/lay/lay/laySettingsForm.h @@ -37,7 +37,7 @@ namespace lay { -class PluginRoot; +class Dispatcher; class ConfigPage; class SettingsForm @@ -46,7 +46,7 @@ class SettingsForm Q_OBJECT public: - SettingsForm (QWidget *parent, lay::PluginRoot *plugin_root, const char *name); + SettingsForm (QWidget *parent, lay::Dispatcher *dispatcher, const char *name); void setup (); void commit (); @@ -58,7 +58,7 @@ public slots: void item_changed (QTreeWidgetItem *, QTreeWidgetItem *); private: - lay::PluginRoot *mp_plugin_root; + lay::Dispatcher *mp_dispatcher; std::vector m_config_pages; bool m_finalize_recursion; }; diff --git a/src/lay/lay/layTechnologyController.h b/src/lay/lay/layTechnologyController.h index 63e57e0dc..aeae6f5f0 100644 --- a/src/lay/lay/layTechnologyController.h +++ b/src/lay/lay/layTechnologyController.h @@ -54,9 +54,9 @@ public: */ TechnologyController (); - void initialize (lay::PluginRoot *root); - void initialized (lay::PluginRoot *root); - void uninitialize (lay::PluginRoot *root); + void initialize (lay::Dispatcher *root); + void initialized (lay::Dispatcher *root); + void uninitialize (lay::Dispatcher *root); void get_options (std::vector < std::pair > &options) const; void get_menu_entries (std::vector &menu_entries) const; @@ -132,7 +132,7 @@ private: bool m_technologies_configured; lay::TechSetupDialog *mp_editor; lay::MainWindow *mp_mw; - lay::PluginRoot *mp_plugin_root; + lay::Dispatcher *mp_plugin_root; std::vector m_paths; std::vector m_temp_tech; db::Technology *mp_active_technology; diff --git a/src/lay/lay/LayoutStatistics.ui b/src/laybasic/laybasic/LayoutStatistics.ui similarity index 100% rename from src/lay/lay/LayoutStatistics.ui rename to src/laybasic/laybasic/LayoutStatistics.ui diff --git a/src/lay/lay/SelectCellViewForm.ui b/src/laybasic/laybasic/SelectCellViewForm.ui similarity index 100% rename from src/lay/lay/SelectCellViewForm.ui rename to src/laybasic/laybasic/SelectCellViewForm.ui diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc index 7d6081638..b409a7740 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc @@ -533,6 +533,18 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This method has been introduced in version 0.27\n" ) + #endif + gsi::method ("call_menu", &lay::LayoutView::menu_activated, + "@brief Calls the menu item with the provided symbol.\n" + "To obtain all symbols, use get_menu_symbols.\n" + "\n" + "This method has been introduced in version 0.27." + ) + + gsi::method ("get_menu_symbols", &lay::LayoutView::get_menu_symbols, + "@brief Calls the menu item with the provided symbol.\n" + "To obtain all available symbols, use get_menu_symbols.\n" + "\n" + "This method has been introduced in version 0.27." + ) + gsi::method ("current", &lay::LayoutView::current, "@brief Returns the current view\n" "The current view is the one that is shown in the current tab. Returns nil if no layout is loaded.\n" diff --git a/src/laybasic/laybasic/gsiDeclLayPlugin.cc b/src/laybasic/laybasic/gsiDeclLayPlugin.cc index 1c87df4f4..4c81d652e 100644 --- a/src/laybasic/laybasic/gsiDeclLayPlugin.cc +++ b/src/laybasic/laybasic/gsiDeclLayPlugin.cc @@ -56,14 +56,14 @@ namespace gsi // of the factory, this hack is a quick but dirty workaround. static bool s_in_create_plugin = false; static lay::LayoutView *sp_view = 0; -static lay::PluginRoot *sp_root = 0; +static lay::Dispatcher *sp_dispatcher = 0; class PluginBase : public lay::Plugin, public lay::ViewService { public: PluginBase () - : lay::Plugin (sp_root), lay::ViewService (sp_view ? sp_view->view_object_widget () : 0) + : lay::Plugin (sp_dispatcher), lay::ViewService (sp_view ? sp_view->view_object_widget () : 0) { if (! s_in_create_plugin) { throw tl::Exception (tl::to_string (QObject::tr ("A PluginBase object can only be created in the PluginFactory's create_plugin method"))); @@ -334,7 +334,7 @@ public: } } - virtual void initialize (lay::PluginRoot *root) + virtual void initialize (lay::Dispatcher *root) { if (f_initialize.can_issue ()) { f_initialize.issue (&lay::PluginDeclaration::initialize, root); @@ -343,7 +343,7 @@ public: } } - virtual void uninitialize (lay::PluginRoot *root) + virtual void uninitialize (lay::Dispatcher *root) { if (f_uninitialize.can_issue ()) { f_uninitialize.issue (&lay::PluginDeclaration::uninitialize, root); @@ -352,7 +352,7 @@ public: } } - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::PluginRoot *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const { if (f_create_plugin.can_issue ()) { return create_plugin_gsi (manager, root, view); @@ -361,22 +361,22 @@ public: } } - virtual gsi::PluginBase *create_plugin_gsi (db::Manager *manager, lay::PluginRoot *root, lay::LayoutView *view) const + virtual gsi::PluginBase *create_plugin_gsi (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const { // TODO: this is a hack. See notes above at s_in_create_plugin s_in_create_plugin = true; sp_view = view; - sp_root = root; + sp_dispatcher = root; gsi::PluginBase *ret = 0; try { - ret = f_create_plugin.issue (&PluginFactoryBase::create_plugin_gsi, manager, root, view); + ret = f_create_plugin.issue (&PluginFactoryBase::create_plugin_gsi, manager, root, view); s_in_create_plugin = false; sp_view = 0; - sp_root = 0; + sp_dispatcher = 0; } catch (...) { s_in_create_plugin = false; sp_view = 0; - sp_root = 0; + sp_dispatcher = 0; } return ret; @@ -394,17 +394,31 @@ public: void add_menu_entry1 (const std::string &menu_name, const std::string &insert_pos) { - m_menu_entries.push_back (lay::MenuEntry (menu_name, insert_pos)); + m_menu_entries.push_back (lay::separator (menu_name, insert_pos)); } void add_menu_entry2 (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &title) { - m_menu_entries.push_back (lay::MenuEntry (symbol, menu_name, insert_pos, title)); + m_menu_entries.push_back (lay::menu_item (symbol, menu_name, insert_pos, title)); + } + + void add_submenu (const std::string &menu_name, const std::string &insert_pos, const std::string &title) + { + m_menu_entries.push_back (lay::submenu (menu_name, insert_pos, title)); + } + + void add_config_menu_item (const std::string &menu_name, const std::string &insert_pos, const std::string &title, const std::string &cname, const std::string &cvalue) + { + m_menu_entries.push_back (lay::config_menu_item (menu_name, insert_pos, title, cname, cvalue)); } void add_menu_entry3 (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &title, bool sub_menu) { - m_menu_entries.push_back (lay::MenuEntry (symbol, menu_name, insert_pos, title, sub_menu)); + if (sub_menu) { + m_menu_entries.push_back (lay::submenu (symbol, menu_name, insert_pos, title)); + } else { + m_menu_entries.push_back (lay::menu_item (symbol, menu_name, insert_pos, title)); + } } void add_option (const std::string &name, const std::string &default_value) @@ -439,9 +453,8 @@ private: }; Class decl_PluginFactory ("lay", "PluginFactory", - method ("register", &PluginFactoryBase::register_gsi, + method ("register", &PluginFactoryBase::register_gsi, gsi::arg ("position"), gsi::arg ("name"), gsi::arg ("title"), "@brief Registers the plugin factory\n" - "@args position, name, title\n" "@param position An integer that determines the order in which the plugins are created. The internal plugins use the values from 1000 to 50000.\n" "@param name The plugin name. This is an arbitrary string which should be unique. Hence it is recommended to use a unique prefix, i.e. \"myplugin::ThePluginClass\".\n" "@param title The title string which is supposed to appear in the tool bar and menu related to this plugin.\n" @@ -449,9 +462,8 @@ Class decl_PluginFactory ("lay", "PluginFactory", "Registration of the plugin factory makes the object known to the system. Registration requires that the menu items have been set " "already. Hence it is recommended to put the registration at the end of the initialization method of the factory class.\n" ) + - method ("register", &PluginFactoryBase::register_gsi2, + method ("register", &PluginFactoryBase::register_gsi2, gsi::arg ("position"), gsi::arg ("name"), gsi::arg ("title"), gsi::arg ("icon"), "@brief Registers the plugin factory\n" - "@args position, name, title, icon\n" "@param position An integer that determines the order in which the plugins are created. The internal plugins use the values from 1000 to 50000.\n" "@param name The plugin name. This is an arbitrary string which should be unique. Hence it is recommended to use a unique prefix, i.e. \"myplugin::ThePluginClass\".\n" "@param title The title string which is supposed to appear in the tool bar and menu related to this plugin.\n" @@ -462,9 +474,8 @@ Class decl_PluginFactory ("lay", "PluginFactory", "Registration of the plugin factory makes the object known to the system. Registration requires that the menu items have been set " "already. Hence it is recommended to put the registration at the end of the initialization method of the factory class.\n" ) + - callback ("configure", &gsi::PluginFactoryBase::configure, &gsi::PluginFactoryBase::f_configure, + callback ("configure", &gsi::PluginFactoryBase::configure, &gsi::PluginFactoryBase::f_configure, gsi::arg ("name"), gsi::arg ("value"), "@brief Gets called for configuration events for the plugin singleton\n" - "@args name, value\n" "This method can be reimplemented to receive configuration events " "for the plugin singleton. Before a configuration can be received it must be " "registered by calling \\add_option in the plugin factories' constructor.\n" @@ -479,14 +490,12 @@ Class decl_PluginFactory ("lay", "PluginFactory", ) + callback ("config_finalize", &gsi::PluginFactoryBase::config_finalize, &gsi::PluginFactoryBase::f_config_finalize, "@brief Gets called after a set of configuration events has been sent\n" - "@args\n" "This method can be reimplemented and is called after a set of configuration events " "has been sent to the plugin factory singleton with \\configure. It can be used to " "set up user interfaces properly for example.\n" ) + - callback ("menu_activated", &gsi::PluginFactoryBase::menu_activated, &gsi::PluginFactoryBase::f_menu_activated, + callback ("menu_activated", &gsi::PluginFactoryBase::menu_activated, &gsi::PluginFactoryBase::f_menu_activated, gsi::arg ("symbol"), "@brief Gets called when a menu item is selected\n" - "@args symbol\n" "\n" "Usually, menu-triggered functionality is implemented in the per-view instance of the plugin. " "However, using this method it is possible to implement functionality globally for all plugin " @@ -496,37 +505,32 @@ Class decl_PluginFactory ("lay", "PluginFactory", "If this method was handling the menu event, it should return true. This indicates that the event " "will not be propagated to other plugins hence avoiding duplicate calls.\n" ) + - callback ("initialized", &gsi::PluginFactoryBase::initialize, &gsi::PluginFactoryBase::f_initialize, + callback ("initialized", &gsi::PluginFactoryBase::initialize, &gsi::PluginFactoryBase::f_initialize, gsi::arg ("dispatcher"), "@brief Gets called when the plugin singleton is initialized, i.e. when the application has been started.\n" - "@args root\n" - "@param root The reference to the \\MainWindow object\n" + "@param dispatcher The reference to the \\MainWindow object\n" ) + - callback ("uninitialized", &gsi::PluginFactoryBase::uninitialize, &gsi::PluginFactoryBase::f_uninitialize, + callback ("uninitialized", &gsi::PluginFactoryBase::uninitialize, &gsi::PluginFactoryBase::f_uninitialize, gsi::arg ("dispatcher"), "@brief Gets called when the application shuts down and the plugin is unregistered\n" "This event can be used to free resources allocated with this factory singleton.\n" - "@args root\n" - "@param root The reference to the \\MainWindow object\n" + "@param dispatcher The reference to the \\MainWindow object\n" ) + - factory_callback ("create_plugin", &gsi::PluginFactoryBase::create_plugin_gsi, &gsi::PluginFactoryBase::f_create_plugin, + factory_callback ("create_plugin", &gsi::PluginFactoryBase::create_plugin_gsi, &gsi::PluginFactoryBase::f_create_plugin, gsi::arg ("manager"), gsi::arg ("dispatcher"), gsi::arg ("view"), "@brief Creates the plugin\n" "This is the basic functionality that the factory must provide. This method must create a plugin of the " "specific type.\n" - "@args manager, root, view\n" "@param manager The database manager object responsible for handling database transactions\n" - "@param root The reference to the \\MainWindow object\n" + "@param dispatcher The reference to the \\MainWindow object\n" "@param view The \\LayoutView that is plugin is created for\n" "@return The new \\Plugin implementation object\n" ) + - method ("add_menu_entry", &gsi::PluginFactoryBase::add_menu_entry1, + method ("add_menu_entry", &gsi::PluginFactoryBase::add_menu_entry1, gsi::arg ("menu_name"), gsi::arg ("insert_pos"), "@brief Specifies a separator\n" - "@args menu_name, insert_pos\n" "Call this method in the factory constructor to build the menu items that this plugin shall create.\n" "This specific call inserts a separator at the given position (insert_pos). The position uses abstract menu item paths " "and \"menu_name\" names the component that will be created. See \\AbstractMenu for a description of the path.\n" ) + - method ("add_menu_entry", &gsi::PluginFactoryBase::add_menu_entry2, + method ("add_menu_entry", &gsi::PluginFactoryBase::add_menu_entry2, gsi::arg ("symbol"), gsi::arg ("menu_name"), gsi::arg ("insert_pos"), gsi::arg ("title"), "@brief Specifies a menu item\n" - "@args symbol, menu_name, insert_pos, title\n" "Call this method in the factory constructor to build the menu items that this plugin shall create.\n" "This specific call inserts a menu item at the specified position (insert_pos). The position uses abstract menu item paths " "and \"menu_name\" names the component that will be created. See \\AbstractMenu for a description of the path.\n" @@ -537,15 +541,28 @@ Class decl_PluginFactory ("lay", "PluginFactory", "@param insert_pos The position where to create the entry\n" "@param title The title string for the item. The title can contain a keyboard shortcut in round braces after the title text, i.e. \"My Menu Item(F12)\"\n" ) + - method ("add_menu_entry", &gsi::PluginFactoryBase::add_menu_entry3, + method ("#add_menu_entry", &gsi::PluginFactoryBase::add_menu_entry3, gsi::arg ("symbol"), gsi::arg ("menu_name"), gsi::arg ("insert_pos"), gsi::arg ("title"), gsi::arg ("sub_menu"), "@brief Specifies a menu item or sub-menu\n" - "@args symbol, menu_name, insert_pos, title, sub_menu\n" "Similar to the previous form of \"add_menu_entry\", but this version allows also to create sub-menus by setting the " - "last parameter to \"true\"" + "last parameter to \"true\".\n" + "\n" + "With version 0.27 it's more convenient to use \\add_submenu." ) + - method ("add_option", &gsi::PluginFactoryBase::add_option, + method ("add_submenu", &gsi::PluginFactoryBase::add_submenu, gsi::arg ("menu_name"), gsi::arg ("insert_pos"), gsi::arg ("title"), + "@brief Specifies a menu item or sub-menu\n" + "\n" + "This method has been introduced in version 0.27." + ) + + method ("add_config_menu_item", &gsi::PluginFactoryBase::add_config_menu_item, gsi::arg ("menu_name"), gsi::arg ("insert_pos"), gsi::arg ("title"), gsi::arg ("cname"), gsi::arg ("cvalue"), + "@brief Adds a configuration menu item\n" + "\n" + "Menu items created this way will send a configuration request with 'cname' as the configuration parameter name " + "and 'cvalue' as the configuration parameter value.\n" + "\n" + "This method has been introduced in version 0.27." + ) + + method ("add_option", &gsi::PluginFactoryBase::add_option, gsi::arg ("name"), gsi::arg ("default_value"), "@brief Specifies configuration variables.\n" - "@args name, default_value\n" "Call this method in the factory constructor to add configuration key/value pairs to the configuration repository. " "Without specifying configuration variables, the status of a plugin cannot be persisted. " "\n\n" @@ -555,9 +572,8 @@ Class decl_PluginFactory ("lay", "PluginFactory", "doing so has the advantage that it is guaranteed that a variable with this keys exists and has the given default value initially." "\n\n" ) + - method ("has_tool_entry=", &gsi::PluginFactoryBase::has_tool_entry, + method ("has_tool_entry=", &gsi::PluginFactoryBase::has_tool_entry, gsi::arg ("f"), "@brief Enables or disables the tool bar entry\n" - "@args f\n" "Initially this property is set to true. This means that the plugin will have a visible entry in the toolbar. " "This property can be set to false to disable this feature. In that case, the title and icon given on registration will be ignored. " ), @@ -601,7 +617,7 @@ Class decl_PluginFactory ("lay", "PluginFactory", " end\n" " \n" " # Create a new plugin instance of the custom type\n" - " def create_plugin(manager, root, view)\n" + " def create_plugin(manager, dispatcher, view)\n" " return PluginTest.new\n" " end\n" "\n" @@ -849,22 +865,22 @@ Class decl_ButtonState ("lay", "ButtonState", ); static std::vector -get_config_names (lay::PluginRoot *root) +get_config_names (lay::Dispatcher *dispatcher) { std::vector names; - root->get_config_names (names); + dispatcher->get_config_names (names); return names; } -static lay::PluginRoot *config_root_instance () +static lay::Dispatcher *dispatcher_instance () { - return lay::PluginRoot::instance (); + return lay::Dispatcher::instance (); } -static tl::Variant get_config (lay::PluginRoot *root, const std::string &name) +static tl::Variant get_config (lay::Dispatcher *dispatcher, const std::string &name) { std::string value; - if (root->config_get (name, value)) { + if (dispatcher->config_get (name, value)) { return tl::Variant (value); } else { return tl::Variant (); @@ -872,54 +888,50 @@ static tl::Variant get_config (lay::PluginRoot *root, const std::string &name) } /** - * @brief Exposes the PluginRoot interface + * @brief Exposes the Dispatcher interface * * This interface is intentionally not derived from Plugin. It is used currently to - * identify the plugin root node for configuration. The Plugin nature of this interface + * identify the dispatcher node for configuration. The Plugin nature of this interface * is somewhat artificial and may be removed later. * * TODO: this is a duplicate of the respective methods in LayoutView and Application. * This is intentional since we don't want to spend the only derivation path on this. * Once there is a mixin concept, provide a path through that concept. */ -Class decl_PluginRoot ("lay", "PluginRoot", - method ("clear_config", &lay::PluginRoot::clear_config, +Class decl_Dispatcher ("lay", "Dispatcher", + method ("clear_config", &lay::Dispatcher::clear_config, "@brief Clears the configuration parameters\n" ) + - method ("instance", &config_root_instance, + method ("instance", &dispatcher_instance, "@brief Gets the singleton instance of the PluginRoot object\n" "\n" "@return The instance\n" ) + - method ("write_config", &lay::PluginRoot::write_config, + method ("write_config", &lay::Dispatcher::write_config, gsi::arg ("file_name"), "@brief Writes configuration to a file\n" - "@args file_name\n" "@return A value indicating whether the operation was successful\n" "\n" "If the configuration file cannot be written, false \n" "is returned but no exception is thrown.\n" ) + - method ("read_config", &lay::PluginRoot::read_config, + method ("read_config", &lay::Dispatcher::read_config, gsi::arg ("file_name"), "@brief Reads the configuration from a file\n" - "@args file_name\n" "@return A value indicating whether the operation was successful\n" "\n" "This method siletly does nothing, if the config file does not\n" "exist. If it does and an error occurred, the error message is printed\n" "on stderr. In both cases, false is returned.\n" ) + - method_ext ("get_config", &get_config, + method_ext ("get_config", &get_config, gsi::arg ("name"), "@brief Gets the value of a local configuration parameter\n" "\n" - "@args name\n" "@param name The name of the configuration parameter whose value shall be obtained (a string)\n" "\n" "@return The value of the parameter or nil if there is no such parameter\n" ) + - method ("set_config", (void (lay::PluginRoot::*) (const std::string &, const std::string &)) &lay::PluginRoot::config_set, + method ("set_config", (void (lay::Dispatcher::*) (const std::string &, const std::string &)) &lay::Dispatcher::config_set, gsi::arg ("name"), gsi::arg ("value"), "@brief Set a local configuration parameter with the given name to the given value\n" "\n" - "@args name, value\n" "@param name The name of the configuration parameter to set\n" "@param value The value to which to set the configuration parameter\n" "\n" @@ -937,14 +949,14 @@ Class decl_PluginRoot ("lay", "PluginRoot", "This method returns the names of all known configuration parameters. These names can be used to " "get and set configuration parameter values.\n" ) + - method ("commit_config", &lay::PluginRoot::config_end, + method ("commit_config", &lay::Dispatcher::config_end, "@brief Commits the configuration settings\n" "\n" "Some configuration options are queued for performance reasons and become active only after 'commit_config' has been called. " "After a sequence of \\set_config calls, this method should be called to activate the " "settings made by these calls.\n" ), - "@brief Root of the configuration space in the plugin context\n" + "@brief Root of the configuration space in the plugin context and menu dispatcher\n" "\n" "This class provides access to the root configuration space in the context " "of plugin programming. You can use this class to obtain configuration parameters " @@ -952,12 +964,12 @@ Class decl_PluginRoot ("lay", "PluginRoot", "preferred way of plugin configuration is through \\Plugin#configure.\n" "\n" "Currently, the application object provides an identical entry point for configuration modification. " - "For example, \"Application::instance.set_config\" is identical to \"PluginRoot::instance.set_config\". " - "Hence there is little motivation for the PluginRoot class currently and " + "For example, \"Application::instance.set_config\" is identical to \"Dispatcher::instance.set_config\". " + "Hence there is little motivation for the Dispatcher class currently and " "this interface may be modified or removed in the future." "\n" - "\n" - "This class has been introduced in version 0.25.\n" + "This class has been introduced in version 0.25 as 'PluginRoot'.\n" + "It is renamed and enhanced as 'Dispatcher' in 0.27." ); } diff --git a/src/laybasic/laybasic/layAbstractMenu.cc b/src/laybasic/laybasic/layAbstractMenu.cc index 5c0089904..5c63d1d24 100644 --- a/src/laybasic/laybasic/layAbstractMenu.cc +++ b/src/laybasic/laybasic/layAbstractMenu.cc @@ -22,9 +22,9 @@ #include "layAbstractMenu.h" -#include "layAbstractMenuProvider.h" -#include "tlExceptions.h" +#include "layDispatcher.h" #include "layPlugin.h" +#include "tlExceptions.h" #include "tlAssert.h" #include "gtf.h" #include "gsi.h" @@ -574,8 +574,8 @@ ActionHandle::get_key_sequence_for (const std::string &sc) const Action::Action () : mp_handle (0) { - if (lay::AbstractMenuProvider::instance ()) { - mp_handle = new ActionHandle (lay::AbstractMenuProvider::instance ()->menu_parent_widget ()); + if (lay::Dispatcher::instance ()) { + mp_handle = new ActionHandle (lay::Dispatcher::instance ()->menu_parent_widget ()); gtf::action_connect (mp_handle->ptr (), SIGNAL (triggered ()), this, SLOT (triggered_slot ())); mp_handle->add_ref (); } @@ -920,14 +920,14 @@ Action::set_object_name (const std::string &name) // --------------------------------------------------------------- // ConfigureAction implementation -ConfigureAction::ConfigureAction (lay::PluginRoot *pr) - : Action (), m_pr (pr), m_type (ConfigureAction::setter_type) +ConfigureAction::ConfigureAction (lay::Dispatcher *dispatcher) + : Action (), m_dispatcher (dispatcher), m_type (ConfigureAction::setter_type) { // .. nothing yet .. } -ConfigureAction::ConfigureAction (lay::PluginRoot *pr, const std::string &cname, const std::string &cvalue) - : Action (), m_pr (pr), m_cname (cname), m_cvalue (cvalue), m_type (ConfigureAction::setter_type) +ConfigureAction::ConfigureAction (lay::Dispatcher *dispatcher, const std::string &cname, const std::string &cvalue) + : Action (), m_dispatcher (dispatcher), m_cname (cname), m_cvalue (cvalue), m_type (ConfigureAction::setter_type) { if (cvalue == "?") { m_type = boolean_type; @@ -937,8 +937,8 @@ ConfigureAction::ConfigureAction (lay::PluginRoot *pr, const std::string &cname, reg (); } -ConfigureAction::ConfigureAction (lay::PluginRoot *pr, const std::string &title, const std::string &cname, const std::string &cvalue) - : Action (title), m_pr (pr), m_cname (cname), m_cvalue (cvalue), m_type (ConfigureAction::setter_type) +ConfigureAction::ConfigureAction (lay::Dispatcher *dispatcher, const std::string &title, const std::string &cname, const std::string &cvalue) + : Action (title), m_dispatcher (dispatcher), m_cname (cname), m_cvalue (cvalue), m_type (ConfigureAction::setter_type) { if (cvalue == "?") { // A "?" notation indicates a boolean toogle entry @@ -966,23 +966,19 @@ ConfigureAction::triggered () m_cvalue = tl::to_string (is_checked ()); } - m_pr->config_set (m_cname, m_cvalue); + m_dispatcher->config_set (m_cname, m_cvalue); } void ConfigureAction::reg () { - if (lay::AbstractMenuProvider::instance ()) { - lay::AbstractMenuProvider::instance ()->register_config_action (m_cname, this); - } + m_dispatcher->register_config_action (m_cname, this); } void ConfigureAction::unreg () { - if (lay::AbstractMenuProvider::instance ()) { - lay::AbstractMenuProvider::instance ()->unregister_config_action (m_cname, this); - } + m_dispatcher->unregister_config_action (m_cname, this); } void @@ -1008,13 +1004,8 @@ ConfigureAction::configure (const std::string &value) // AbstractMenu implementation ActionHandle * -AbstractMenu::create_action (const std::string &s, AbstractMenuProvider *provider) +AbstractMenu::create_action (const std::string &s, lay::Dispatcher *dispatcher) { - if (! provider) { - provider = lay::AbstractMenuProvider::instance (); - } - tl_assert (provider != 0); - std::string title; std::string shortcut; std::string res; @@ -1022,7 +1013,7 @@ AbstractMenu::create_action (const std::string &s, AbstractMenuProvider *provide parse_menu_title (s, title, shortcut, res, tool_tip); - ActionHandle *ah = new ActionHandle (provider->menu_parent_widget ()); + ActionHandle *ah = new ActionHandle (dispatcher->menu_parent_widget ()); ah->ptr ()->setText (tl::to_qstring (title)); if (! tool_tip.empty ()) { @@ -1040,8 +1031,8 @@ AbstractMenu::create_action (const std::string &s, AbstractMenuProvider *provide return ah; } -AbstractMenu::AbstractMenu (AbstractMenuProvider *provider) - : mp_provider (provider) +AbstractMenu::AbstractMenu (Dispatcher *dispatcher) + : mp_dispatcher (dispatcher) { // .. nothing yet .. } @@ -1051,13 +1042,6 @@ AbstractMenu::~AbstractMenu () // .. nothing yet .. } -void -AbstractMenu::init (const MenuLayoutEntry *layout) -{ - m_root.set_has_submenu (); - transfer (layout, m_root); -} - QActionGroup * AbstractMenu::make_exclusive_group (const std::string &name) { @@ -1167,8 +1151,8 @@ AbstractMenu::build (QMenuBar *mbar, QToolBar *tbar) // Otherwise, the keyboard shortcuts do not work for menu items inside such a // popup menu. It seems not to have a negative effect to add the menu to the // main widget. - if (mp_provider) { - mp_provider->menu_parent_widget ()->addAction (menu->menuAction ()); + if (mp_dispatcher->menu_parent_widget ()) { + mp_dispatcher->menu_parent_widget ()->addAction (menu->menuAction ()); } c->set_action (Action (new ActionHandle (menu)), true); } @@ -1379,27 +1363,32 @@ AbstractMenu::items (const std::string &path) const void AbstractMenu::insert_item (const std::string &p, const std::string &name, const Action &action) { - typedef std::vector::iterator > > path_type; - path_type path = find_item (p); - if (! path.empty ()) { + tl::Extractor extr (p.c_str ()); + while (! extr.at_end ()) { - AbstractMenuItem *parent = path.back ().first; - std::list::iterator iter = path.back ().second; + typedef std::vector::iterator > > path_type; + path_type path = find_item (extr); + if (! path.empty ()) { - // insert the new item - parent->children.insert (iter, AbstractMenuItem ()); - --iter; + AbstractMenuItem *parent = path.back ().first; + std::list::iterator iter = path.back ().second; - iter->setup_item (parent->name (), name, action); + // insert the new item + parent->children.insert (iter, AbstractMenuItem ()); + --iter; - // find any items with the same name and remove them - for (std::list::iterator existing = parent->children.begin (); existing != parent->children.end (); ) { - std::list::iterator existing_next = existing; - ++existing_next; - if (existing->name () == iter->name () && existing != iter) { - parent->children.erase (existing); + iter->setup_item (parent->name (), name, action); + + // find any items with the same name and remove them + for (std::list::iterator existing = parent->children.begin (); existing != parent->children.end (); ) { + std::list::iterator existing_next = existing; + ++existing_next; + if (existing->name () == iter->name () && existing != iter) { + parent->children.erase (existing); + } + existing = existing_next; } - existing = existing_next; + } } @@ -1411,7 +1400,8 @@ void AbstractMenu::insert_separator (const std::string &p, const std::string &name) { typedef std::vector::iterator > > path_type; - path_type path = find_item (p); + tl::Extractor extr (p.c_str ()); + path_type path = find_item (extr); if (! path.empty ()) { AbstractMenuItem *parent = path.back ().first; @@ -1419,7 +1409,7 @@ AbstractMenu::insert_separator (const std::string &p, const std::string &name) parent->children.insert (iter, AbstractMenuItem ()); --iter; - Action action (new ActionHandle (mp_provider ? mp_provider->menu_parent_widget () : 0)); + Action action (new ActionHandle (mp_dispatcher->menu_parent_widget ())); action.set_separator (true); iter->setup_item (parent->name (), name, action); @@ -1432,7 +1422,8 @@ void AbstractMenu::insert_menu (const std::string &p, const std::string &name, const Action &action) { typedef std::vector::iterator > > path_type; - path_type path = find_item (p); + tl::Extractor extr (p.c_str ()); + path_type path = find_item (extr); if (! path.empty ()) { AbstractMenuItem *parent = path.back ().first; @@ -1461,14 +1452,15 @@ AbstractMenu::insert_menu (const std::string &p, const std::string &name, const void AbstractMenu::insert_menu (const std::string &path, const std::string &name, const std::string &title) { - insert_menu (path, name, create_action (title, mp_provider)); + insert_menu (path, name, create_action (title, mp_dispatcher)); } void AbstractMenu::clear_menu (const std::string &p) { typedef std::vector::iterator > > path_type; - path_type path = find_item (p); + tl::Extractor extr (p.c_str ()); + path_type path = find_item (extr); if (! path.empty () && ! path.back ().second->children.empty ()) { path.back ().second->children.clear (); emit changed (); @@ -1479,7 +1471,8 @@ void AbstractMenu::delete_item (const std::string &p) { typedef std::vector::iterator > > path_type; - path_type path = find_item (p); + tl::Extractor extr (p.c_str ()); + path_type path = find_item (extr); if (! path.empty ()) { for (path_type::const_reverse_iterator p = path.rbegin (); p != path.rend (); ++p) { @@ -1588,18 +1581,21 @@ AbstractMenu::find_item_exact (const std::string &path) } std::vector::iterator> > -AbstractMenu::find_item (const std::string &p) +AbstractMenu::find_item (tl::Extractor &extr) { typedef std::vector::iterator> > path_type; path_type path; - tl::Extractor extr (p.c_str ()); AbstractMenuItem *parent = &m_root; std::list::iterator iter = m_root.children.end (); while (parent && ! extr.at_end ()) { - if (extr.test ("#")) { + if (extr.test (";")) { + + break; + + } else if (extr.test ("#")) { unsigned int n = 0; extr.try_read (n); @@ -1721,71 +1717,6 @@ AbstractMenu::find_item (const std::string &p) return path; } -void -AbstractMenu::transfer (const MenuLayoutEntry *layout, AbstractMenuItem &item) -{ - while (layout->name) { - - item.children.push_back (AbstractMenuItem ()); - AbstractMenuItem &new_item = item.children.back (); - - lay::Action a; - - if (! mp_provider) { - a = lay::Action (new ActionHandle ((QWidget *) 0)); - } else if (layout->slot) { - // reuse any actions already registered for this slot - a = mp_provider->action_for_slot (layout->slot); - } else if (! layout->kv_pair.first.empty ()) { - a = *mp_provider->create_config_action (layout->kv_pair.first, layout->kv_pair.second); - } else { - a = lay::Action (new ActionHandle (mp_provider->menu_parent_widget ())); - } - - if (layout->title == "-") { - - // reuse title from other entry - - } else if (! layout->title.empty ()) { - - std::string title; - std::string shortcut; - std::string res; - std::string tool_tip; - - parse_menu_title (layout->title, title, shortcut, res, tool_tip); - - a.set_separator (false); - a.set_title (title); - - if (! shortcut.empty ()) { - a.set_default_shortcut (shortcut); - } - - if (! tool_tip.empty ()) { - a.set_tool_tip (tool_tip); - } - - if (! res.empty ()) { - a.set_icon (res); - } - - } else { - a.set_separator (true); - } - - new_item.setup_item (item.name (), layout->name, a); - - if (layout->submenu) { - new_item.set_has_submenu (); - transfer (layout->submenu, item.children.back ()); - } - - ++layout; - - } -} - std::vector AbstractMenu::group (const std::string &name) const { diff --git a/src/laybasic/laybasic/layAbstractMenu.h b/src/laybasic/laybasic/layAbstractMenu.h index 588d60afd..728e5f343 100644 --- a/src/laybasic/laybasic/layAbstractMenu.h +++ b/src/laybasic/laybasic/layAbstractMenu.h @@ -50,10 +50,9 @@ class QMenu; namespace lay { -class AbstractMenuProvider; class Action; class AbstractMenu; -class PluginRoot; +class Dispatcher; /** * @brief A utility function to convert the packed key binding in the cfg_key_bindings string to a vector @@ -406,7 +405,7 @@ private: /** * @brief A specialisation for the Action to issue a "configure" request on "triggered" * - * When this action is triggered, a "configure" request is issued to the PluginRoot instance + * When this action is triggered, a "configure" request is issued to the Dispatcher instance * (which is the root of the configuration hierarchy). The name and value is given by the * respective parameters passed to the constructor or set with the write accessors. */ @@ -420,21 +419,21 @@ public: /** * @brief The default constructor * - * @param pr The reference to the plugin root object which receives the configure request + * @param dispatcher The reference to the dispatcher object which receives the configure request */ - ConfigureAction (lay::PluginRoot *pr); + ConfigureAction (lay::Dispatcher *dispatcher); /** * @brief Create an configure action with the given name and value * - * @param pr The reference to the plugin root object which receives the configure request + * @param dispatcher The reference to the dispatcher object which receives the configure request * @param cname The name of the configuration parameter to set * @param cvalue The value to set "cname" to * * The value can be "?" in which case the configuration action describes * a boolean parameter which is mapped to a checkable action. */ - ConfigureAction (lay::PluginRoot *pr, const std::string &cname, const std::string &value); + ConfigureAction (lay::Dispatcher *dispatcher, const std::string &cname, const std::string &value); /** * @brief Create an configure action with the given title (icon, keyboard shortcut), name and value @@ -449,7 +448,7 @@ public: * The value can be "?" in which case the configuration action describes * a boolean parameter which is mapped to a checkable action. */ - ConfigureAction (lay::PluginRoot *pr, const std::string &title, const std::string &cname, const std::string &value); + ConfigureAction (lay::Dispatcher *dispatcher, const std::string &title, const std::string &cname, const std::string &value); /** * @brief Destructor @@ -505,63 +504,11 @@ private: ConfigureAction (const ConfigureAction &action); ConfigureAction &operator= (const ConfigureAction &action); - lay::PluginRoot *m_pr; + lay::Dispatcher *m_dispatcher; std::string m_cname, m_cvalue; type m_type; }; -/** - * @brief A menu layout entry for static initialisation - * - * These objects act as the "source" for creating the initial AbstractLayout setup. - */ -struct LAYBASIC_PUBLIC MenuLayoutEntry { - - MenuLayoutEntry (const char *_name, - const std::string &_title, - const std::pair &_kv_pair) - : name (_name), title (_title), slot (0), kv_pair (_kv_pair), submenu (0) - { } - - MenuLayoutEntry (const char *_name, - const std::string &_title, - const char *_slot, - const MenuLayoutEntry *_submenu = 0) - : name (_name), title (_title), slot (_slot), submenu (_submenu) - { } - - MenuLayoutEntry (const char *_name, - const std::string &_title, - const MenuLayoutEntry *_submenu = 0) - : name (_name), title (_title), slot (0), submenu (_submenu) - { } - - MenuLayoutEntry (const char *_name) - : name (_name), slot (0), submenu (0) - { } - - MenuLayoutEntry () - : name (0), slot (0), submenu (0) - { } - - static MenuLayoutEntry separator (const char *name) - { - return MenuLayoutEntry (name); - } - - static MenuLayoutEntry last () - { - return MenuLayoutEntry (); - } - - const char *name; - std::string title; - const char *slot; - std::pair kv_pair; - const MenuLayoutEntry *submenu; - -}; - /** * @brief One item in the abstract menu */ @@ -636,11 +583,6 @@ private: * Each item can be associated with a Action, which delivers a title, enabled/disable state etc. * The Action is either provided when new entries are inserted or created upon initialisation. * - * An abstract menu is initialised from a initialisation sequence given by a list of - * MenuLayoutEntry objects terminated with a MenuLayoutEntry::last() item. - * Each of these entries may provide a submenu. Beside for initialisation, these entries - * are not used further. - * * The abstract menu class provides methods to manipulate the menu structure (the state of the * menu items, their title and shortcut key is provided and manipulated through the Action object). * @@ -684,18 +626,13 @@ public: /** * @brief Create the abstract menu object attached to the given main window */ - AbstractMenu (AbstractMenuProvider *provider); + AbstractMenu (Dispatcher *dispatcher); /** * @brief Destroy the abstract menu object */ ~AbstractMenu (); - /** - * @brief Initialise from a sequence of MenuLayoutEntry objects - */ - void init (const MenuLayoutEntry *layout); - /** * @brief Rebuild the QMenu's and refill the QMenuBar object */ @@ -873,10 +810,9 @@ signals: private: friend class Action; - std::vector::iterator> > find_item (const std::string &path); + std::vector::iterator> > find_item (tl::Extractor &extr); const AbstractMenuItem *find_item_exact (const std::string &path) const; AbstractMenuItem *find_item_exact (const std::string &path); - void transfer (const MenuLayoutEntry *layout, AbstractMenuItem &item); void build (QMenu *menu, std::list &items); void build (QToolBar *tbar, std::list &items); void collect_group (std::vector &grp, const std::string &name, const AbstractMenuItem &item) const; @@ -890,9 +826,9 @@ private: * @param provider The abstract menu provider (the global one will be used if this instance is 0) * @return The ActionHandle object created */ - static ActionHandle *create_action (const std::string &s, lay::AbstractMenuProvider *provider); + static ActionHandle *create_action (const std::string &s, lay::Dispatcher *dispatcher); - AbstractMenuProvider *mp_provider; + Dispatcher *mp_dispatcher; AbstractMenuItem m_root; tl::stable_vector m_helper_menu_items; std::map m_action_groups; diff --git a/src/laybasic/laybasic/layAbstractMenuProvider.cc b/src/laybasic/laybasic/layAbstractMenuProvider.cc deleted file mode 100644 index 543a6f84e..000000000 --- a/src/laybasic/laybasic/layAbstractMenuProvider.cc +++ /dev/null @@ -1,51 +0,0 @@ - -/* - - KLayout Layout Viewer - Copyright (C) 2006-2020 Matthias Koefferlein - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - - -#include "layAbstractMenuProvider.h" - -namespace lay -{ - -static AbstractMenuProvider *ms_instance = 0; - -AbstractMenuProvider::AbstractMenuProvider (bool reg_inst) -{ - if (reg_inst && ! ms_instance) { - ms_instance = this; - } -} - -AbstractMenuProvider::~AbstractMenuProvider () -{ - if (ms_instance == this) { - ms_instance = 0; - } -} - -AbstractMenuProvider *AbstractMenuProvider::instance () -{ - return ms_instance; -} - -} - diff --git a/src/laybasic/laybasic/layAbstractMenuProvider.h b/src/laybasic/laybasic/layAbstractMenuProvider.h deleted file mode 100644 index 4c2d6b26e..000000000 --- a/src/laybasic/laybasic/layAbstractMenuProvider.h +++ /dev/null @@ -1,107 +0,0 @@ - -/* - - KLayout Layout Viewer - Copyright (C) 2006-2020 Matthias Koefferlein - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - - -#ifndef HDR_layAbstractMenuProvider -#define HDR_layAbstractMenuProvider - -#include "laybasicCommon.h" - -#include - -class QWidget; - -namespace lay -{ - -class AbstractMenu; -class Action; -class ConfigureAction; - -/** - * @brief An interface for the supplier of the abstract menu object - */ -class LAYBASIC_PUBLIC AbstractMenuProvider -{ -public: - /** - * @brief Constructor - * If "reg_inst" is true, this instance will become the global instance - */ - AbstractMenuProvider (bool reg_inst = true); - - /** - * @brief Destructor - */ - virtual ~AbstractMenuProvider (); - - /** - * @brief Gets the AbstractMenu object - */ - virtual AbstractMenu *menu () = 0; - - /** - * @brief Gets the parent widget - */ - virtual QWidget *menu_parent_widget () = 0; - - /** - * @brief Get the action for a slot - */ - virtual lay::Action &action_for_slot (const char *slot) = 0; - - /** - * @brief Create a configuration action with the given title, parameter name and value - * - * The action will be owned by the abstract menu provider but can be deleted to remove it from there. - */ - virtual lay::Action *create_config_action (const std::string &title, const std::string &cname, const std::string &cvalue) = 0; - - /** - * @brief Create a configuration action with the given parameter name and value - * - * The action will be owned by the abstract menu provider but can be deleted to remove it from there. - * This version is provided for applications, where the title is set later. - */ - virtual lay::Action *create_config_action (const std::string &cname, const std::string &cvalue) = 0; - - /** - * @brief Register a configuration action with the given name - */ - virtual void register_config_action (const std::string &name, lay::ConfigureAction *action) = 0; - - /** - * @brief Unregister a configuration action with the given name - */ - virtual void unregister_config_action (const std::string &name, lay::ConfigureAction *action) = 0; - - /** - * @brief Gets the singleton instance of the AbstractMenuProvider object - */ - static AbstractMenuProvider *instance (); -}; - -} - -#endif - - diff --git a/src/laybasic/laybasic/layBookmarksView.cc b/src/laybasic/laybasic/layBookmarksView.cc index 57831e651..2898a702f 100644 --- a/src/laybasic/laybasic/layBookmarksView.cc +++ b/src/laybasic/laybasic/layBookmarksView.cc @@ -134,26 +134,6 @@ BookmarksView::follow_selection (bool f) m_follow_selection = f; } -void -BookmarksView::init_menu (lay::AbstractMenu &menu) -{ - MenuLayoutEntry context_menu [] = { - MenuLayoutEntry ("follow_selection", tl::to_string (QObject::tr ("Follow Selection")), std::make_pair (cfg_bookmarks_follow_selection, "?")), - MenuLayoutEntry::separator ("ops_group"), - MenuLayoutEntry ("manage_bookmarks", tl::to_string (QObject::tr ("Manage Bookmarks")), SLOT (cm_manage_bookmarks ())), - MenuLayoutEntry ("load_bookmarks", tl::to_string (QObject::tr ("Load Bookmarks")), SLOT (cm_load_bookmarks ())), - MenuLayoutEntry ("save_bookmarks", tl::to_string (QObject::tr ("Save Bookmarks")), SLOT (cm_save_bookmarks ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry main_menu [] = { - MenuLayoutEntry ("@bookmarks_context_menu", "", context_menu), - MenuLayoutEntry::last () - }; - - menu.init (main_menu); -} - void BookmarksView::set_background_color (QColor c) { @@ -209,5 +189,30 @@ BookmarksView::bookmark_triggered (const QModelIndex &index) } } +// ------------------------------------------------------------ +// Declaration of the "plugin" for the menu entries + +class BookmarksViewPluginDeclaration + : public lay::PluginDeclaration +{ +public: + virtual void get_menu_entries (std::vector &menu_entries) const + { + std::string at; + + at = ".end"; + menu_entries.push_back (lay::submenu ("@bookmarks_context_menu", at, std::string ())); + + at = "@bookmarks_context_menu.end"; + menu_entries.push_back (lay::config_menu_item ("follow_selection", at, tl::to_string (QObject::tr ("Follow Selection")), cfg_bookmarks_follow_selection, "?")), + menu_entries.push_back (lay::separator ("ops_group", at)); + menu_entries.push_back (lay::menu_item ("cm_manage_bookmarks", "manage_bookmarks", at, tl::to_string (QObject::tr ("Manage Bookmarks"))); + menu_entries.push_back (lay::menu_item ("cm_load_bookmarks", "load_bookmarks", at, tl::to_string (QObject::tr ("Load Bookmarks"))); + menu_entries.push_back (lay::menu_item ("cm_save_bookmarks", "save_bookmarks", at, tl::to_string (QObject::tr ("Save Bookmarks"))); + } +}; + +static tl::RegisteredClass config_decl (new BookmarksViewPluginDeclaration (), -7, "BookmarksViewPlugin"); + } diff --git a/src/laybasic/laybasic/layBookmarksView.h b/src/laybasic/laybasic/layBookmarksView.h index e8398931c..8ee811345 100644 --- a/src/laybasic/laybasic/layBookmarksView.h +++ b/src/laybasic/laybasic/layBookmarksView.h @@ -59,8 +59,6 @@ public: void refresh (); - static void init_menu (lay::AbstractMenu &menu); - public slots: void bookmark_triggered (const QModelIndex &index); void current_bookmark_changed (const QModelIndex &index); diff --git a/src/laybasic/laybasic/layDispatcher.cc b/src/laybasic/laybasic/layDispatcher.cc new file mode 100644 index 000000000..3c74de4e1 --- /dev/null +++ b/src/laybasic/laybasic/layDispatcher.cc @@ -0,0 +1,282 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2020 Matthias Koefferlein + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + + +#include "layDispatcher.h" + +#include "tlXMLParser.h" +#include "tlXMLWriter.h" + +namespace lay +{ + +// ---------------------------------------------------------------- +// Dispatcher implementation + +static Dispatcher *ms_dispatcher_instance = 0; + +Dispatcher::Dispatcher (Plugin *parent, bool standalone) + : Plugin (parent, standalone), + m_menu (this) +{ + if (! parent) { + ms_dispatcher_instance = this; + } +} + +Dispatcher::~Dispatcher () +{ + if (ms_dispatcher_instance == this) { + ms_dispatcher_instance = 0; + } +} + +lay::Action * +Dispatcher::create_config_action (const std::string &title, const std::string &cname, const std::string &cvalue) +{ + lay::ConfigureAction *ca = new lay::ConfigureAction (this, title, cname, cvalue); + m_ca_collection.push_back (ca); + return ca; +} + +lay::Action * +Dispatcher::create_config_action (const std::string &cname, const std::string &cvalue) +{ + lay::ConfigureAction *ca = new lay::ConfigureAction (this, std::string (), cname, cvalue); + m_ca_collection.push_back (ca); + return ca; +} + +void +Dispatcher::register_config_action (const std::string &name, lay::ConfigureAction *action) +{ + std::map >::iterator ca = m_configuration_actions.insert (std::make_pair (name, std::vector ())).first; + for (std::vector::iterator a = ca->second.begin (); a != ca->second.end (); ++a) { + if (*a == action) { + return; // already registered + } + } + + ca->second.push_back (action); +} + +void +Dispatcher::unregister_config_action (const std::string &name, lay::ConfigureAction *action) +{ + std::map >::iterator ca = m_configuration_actions.find (name); + if (ca != m_configuration_actions.end ()) { + for (std::vector::iterator a = ca->second.begin (); a != ca->second.end (); ++a) { + if (*a == action) { + ca->second.erase (a); + return; + } + } + } +} + +void +Dispatcher::clear_configuration_actions () +{ + m_ca_collection.clear (); + m_configuration_actions.clear (); +} + +bool +Dispatcher::configure (const std::string &name, const std::string &value) +{ + std::map >::iterator ca = m_configuration_actions.find (name); + if (ca != m_configuration_actions.end ()) { + for (std::vector::const_iterator a = ca->second.begin (); a != ca->second.end (); ++a) { + (*a)->configure (value); + } + } + + return false; +} + +// Writing and Reading of configuration + +struct ConfigGetAdaptor +{ + ConfigGetAdaptor (const std::string &name) + : mp_owner (0), m_done (false), m_name (name) + { + // .. nothing yet .. + } + + std::string operator () () const + { + std::string s; + mp_owner->config_get (m_name, s); + return s; + } + + bool at_end () const + { + return m_done; + } + + void start (const lay::Dispatcher &owner) + { + mp_owner = &owner; + m_done = false; + } + + void next () + { + m_done = true; + } + +private: + const lay::Dispatcher *mp_owner; + bool m_done; + std::string m_name; +}; + +struct ConfigGetNullAdaptor +{ + ConfigGetNullAdaptor () + { + // .. nothing yet .. + } + + std::string operator () () const + { + return std::string (); + } + + bool at_end () const + { + return true; + } + + void start (const lay::Dispatcher & /*owner*/) { } + void next () { } +}; + +struct ConfigNamedSetAdaptor +{ + ConfigNamedSetAdaptor () + { + // .. nothing yet .. + } + + void operator () (lay::Dispatcher &w, tl::XMLReaderState &reader, const std::string &name) const + { + tl::XMLObjTag tag; + w.config_set (name, *reader.back (tag)); + } +}; + +struct ConfigSetAdaptor +{ + ConfigSetAdaptor (const std::string &name) + : m_name (name) + { + // .. nothing yet .. + } + + void operator () (lay::Dispatcher &w, tl::XMLReaderState &reader) const + { + tl::XMLObjTag tag; + w.config_set (m_name, *reader.back (tag)); + } + +private: + std::string m_name; +}; + +// the configuration file's XML structure is built dynamically +static tl::XMLStruct +config_structure (const lay::Dispatcher *plugin) +{ + tl::XMLElementList body; + std::string n_with_underscores; + + std::vector names; + plugin->get_config_names (names); + + for (std::vector ::const_iterator n = names.begin (); n != names.end (); ++n) { + + body.append (tl::XMLMember > ( + ConfigGetAdaptor (*n), ConfigSetAdaptor (*n), *n)); + + // for compatibility, provide an alternative with underscores (i.e. 0.20->0.21 because of default_grids) + n_with_underscores.clear (); + for (const char *c = n->c_str (); *c; ++c) { + n_with_underscores += (*c == '-' ? '_' : *c); + } + + body.append (tl::XMLMember > ( + ConfigGetNullAdaptor (), ConfigSetAdaptor (*n), n_with_underscores)); + + } + + // add a wildcard member to read all others unspecifically into the repository + body.append (tl::XMLWildcardMember > (ConfigNamedSetAdaptor ())); + + return tl::XMLStruct ("config", body); +} + + +bool +Dispatcher::write_config (const std::string &config_file) +{ + try { + tl::OutputStream os (config_file, tl::OutputStream::OM_Plain); + config_structure (this).write (os, *this); + return true; + } catch (...) { + return false; + } +} + +bool +Dispatcher::read_config (const std::string &config_file) +{ + std::auto_ptr file; + + try { + file.reset (new tl::XMLFileSource (config_file)); + } catch (...) { + return false; + } + + try { + config_structure (this).parse (*file, *this); + } catch (tl::Exception &ex) { + std::string msg = tl::to_string (QObject::tr ("Problem reading config file ")) + config_file + ": " + ex.msg (); + throw tl::Exception (msg); + } + + config_end (); + + return true; +} + +Dispatcher * +Dispatcher::instance () +{ + return ms_dispatcher_instance; +} + +} diff --git a/src/laybasic/laybasic/layDispatcher.h b/src/laybasic/laybasic/layDispatcher.h new file mode 100644 index 000000000..63c562f1a --- /dev/null +++ b/src/laybasic/laybasic/layDispatcher.h @@ -0,0 +1,175 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2020 Matthias Koefferlein + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + + +#ifndef HDR_layDispatcher +#define HDR_layDispatcher + +#include "laybasicCommon.h" + +#include "tlTypeTraits.h" +#include "tlObject.h" +#include "layPlugin.h" + +#include +#include +#include + +namespace lay +{ + +class AbstractMenu; +class Action; +class ConfigureAction; + +/** + * @brief The central menu event and configuration dispatcher class + * + * This class acts as the top level dispatcher for plugin events and the menu configuration. + * + */ +class LAYBASIC_PUBLIC Dispatcher + : public Plugin +{ +public: + /** + * @brief The constructor + * + * @param parent Usually 0, but a dispatcher may have parents. In this case, the dispatcher is not the actual dispatcher, but the real plugin chain's root is. + * @param standalone The standalone flag passed to the plugin constructor. + */ + Dispatcher (Plugin *parent, bool standalone = false); + + /** + * @brief Destructor + */ + ~Dispatcher (); + + /** + * @brief Write configuration to a file + * + * If the configuration file cannot be written, false + * is returned but no exception is thrown. + * + * @return false, if an error occurred. + */ + bool write_config (const std::string &config_file); + + /** + * @brief Read the configuration from a file + * + * This method siletly does nothing, if the config file does not + * exist. If it does and an error occurred, the error message is printed + * on stderr. In both cases, false is returned. + * + * @return false, if an error occurred. + */ + bool read_config (const std::string &config_file); + + /** + * @brief The singleton instance of the plugin root + */ + static Dispatcher *instance (); + + /** + * @brief Notifies the plugin root that a new plugin class has been registered + * + * This method is called when a plugin is loaded dynamically during runtime. + */ + virtual void plugin_registered (lay::PluginDeclaration * /*cls*/) { } + + /** + * @brief Notifies the plugin root that a plugin class is about to be removed + */ + virtual void plugin_removed (lay::PluginDeclaration * /*cls*/) { } + + /** + * @brief Selects the given mode + * + * The implementation is supposed to select the given mode on all related plugins. + */ + virtual void select_mode (int /*mode*/) { } + + /** + * @brief Gets the parent widget + */ + virtual QWidget *menu_parent_widget () { return 0; } + + /** + * @brief Gets the AbstractMenu object + */ + AbstractMenu *menu () { return &m_menu; } + + /** + * @brief Creates a configuration action with the given title, parameter name and value + * + * The action will be owned by the abstract menu provider but can be deleted to remove it from there. + */ + lay::Action *create_config_action (const std::string &title, const std::string &cname, const std::string &cvalue); + + /** + * @brief Creates a configuration action with the given parameter name and value + * + * The action will be owned by the abstract menu provider but can be deleted to remove it from there. + * This version is provided for applications, where the title is set later. + */ + lay::Action *create_config_action (const std::string &cname, const std::string &cvalue); + + /** + * @brief Registers a configuration action with the given name + */ + void register_config_action (const std::string &name, lay::ConfigureAction *action); + + /** + * @brief Unregisters a configuration action with the given name + */ + void unregister_config_action (const std::string &name, lay::ConfigureAction *action); + +protected: + // capture the configuration events so we can change the value of the configuration actions + virtual bool configure (const std::string &name, const std::string &value); + + void clear_configuration_actions (); + +private: + Dispatcher (const Dispatcher &); + Dispatcher &operator= (const Dispatcher &); + + lay::AbstractMenu m_menu; + std::map > m_configuration_actions; + tl::shared_collection m_ca_collection; +}; + +} + +namespace tl +{ + // disable copy ctor for Dispatcher + template <> struct type_traits : public type_traits { + typedef tl::false_tag has_copy_constructor; + typedef tl::false_tag has_default_constructor; + }; +} + +#endif + + diff --git a/src/laybasic/laybasic/layGridNet.cc b/src/laybasic/laybasic/layGridNet.cc index afb3188df..9c90f2144 100644 --- a/src/laybasic/laybasic/layGridNet.cc +++ b/src/laybasic/laybasic/layGridNet.cc @@ -105,7 +105,7 @@ GridNetPluginDeclaration::config_page (QWidget *parent, std::string &title) cons } lay::Plugin * -GridNetPluginDeclaration::create_plugin (db::Manager *, lay::PluginRoot *, lay::LayoutView *view) const +GridNetPluginDeclaration::create_plugin (db::Manager *, Dispatcher *, lay::LayoutView *view) const { return new lay::GridNet (view); } diff --git a/src/laybasic/laybasic/layGridNet.h b/src/laybasic/laybasic/layGridNet.h index 4121a986f..400796dae 100644 --- a/src/laybasic/laybasic/layGridNet.h +++ b/src/laybasic/laybasic/layGridNet.h @@ -44,7 +44,7 @@ class GridNetPluginDeclaration public: virtual void get_options (std::vector < std::pair > &options) const; virtual lay::ConfigPage *config_page (QWidget *parent, std::string &title) const; - virtual lay::Plugin *create_plugin (db::Manager *, lay::PluginRoot *, lay::LayoutView *view) const; + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *, lay::LayoutView *view) const; }; class GridNetConfigPage @@ -56,8 +56,8 @@ public: GridNetConfigPage (QWidget *parent); ~GridNetConfigPage (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::GridNetConfigPage *mp_ui; diff --git a/src/laybasic/laybasic/layHierarchyControlPanel.cc b/src/laybasic/laybasic/layHierarchyControlPanel.cc index 304445681..ba95960a0 100644 --- a/src/laybasic/laybasic/layHierarchyControlPanel.cc +++ b/src/laybasic/laybasic/layHierarchyControlPanel.cc @@ -194,52 +194,6 @@ HCPCellTreeWidget::mouseReleaseEvent (QMouseEvent *event) const int max_cellviews_in_split_mode = 5; -void -HierarchyControlPanel::init_menu (lay::AbstractMenu &menu) -{ - MenuLayoutEntry sorting_menu [] = { - MenuLayoutEntry ("by_name", tl::to_string (QObject::tr ("By Name")), std::make_pair (cfg_cell_list_sorting, "?by-name")), - MenuLayoutEntry ("by_area", tl::to_string (QObject::tr ("By Area - Small To Large")), std::make_pair (cfg_cell_list_sorting, "?by-area")), - MenuLayoutEntry ("by_area", tl::to_string (QObject::tr ("By Area - Large To Small")), std::make_pair (cfg_cell_list_sorting, "?by-area-reverse")), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry context_menu [] = { - MenuLayoutEntry ("flat_mode", tl::to_string (QObject::tr ("Flat Cell List")), std::make_pair (cfg_flat_cell_list, "?")), - MenuLayoutEntry ("split_mode", tl::to_string (QObject::tr ("Split Mode")), std::make_pair (cfg_split_cell_list, "?")), - MenuLayoutEntry ("sorting", tl::to_string (QObject::tr ("Sorting")), sorting_menu), - MenuLayoutEntry::separator ("operations_group"), - MenuLayoutEntry ("new_cell:edit:edit_mode", tl::to_string (QObject::tr ("New Cell")), SLOT (cm_new_cell ())), - MenuLayoutEntry ("delete_cell:edit:edit_mode", tl::to_string (QObject::tr ("Delete Cell")), SLOT (cm_cell_delete ())), - MenuLayoutEntry ("rename_cell:edit:edit_mode", tl::to_string (QObject::tr ("Rename Cell")), SLOT (cm_cell_rename ())), - MenuLayoutEntry ("replace_cell:edit:edit_mode", tl::to_string (QObject::tr ("Replace Cell")), SLOT (cm_cell_replace ())), - MenuLayoutEntry ("flatten_cell:edit:edit_mode", tl::to_string (QObject::tr ("Flatten Cell")), SLOT (cm_cell_flatten ())), - MenuLayoutEntry ("cell_user_properties", tl::to_string (QObject::tr ("User Properties")), SLOT (cm_cell_user_properties ())), - MenuLayoutEntry::separator ("clipboard_group:edit_mode"), - MenuLayoutEntry ("copy:edit_mode", tl::to_string (QObject::tr ("Copy")), SLOT (cm_cell_copy ())), - MenuLayoutEntry ("cut:edit_mode", tl::to_string (QObject::tr ("Cut")), SLOT (cm_cell_cut ())), - MenuLayoutEntry ("paste:edit_mode", tl::to_string (QObject::tr ("Paste")), SLOT (cm_cell_paste ())), - MenuLayoutEntry::separator ("select_group"), - MenuLayoutEntry ("show_as_top", tl::to_string (QObject::tr ("Show As New Top")), SLOT (cm_cell_select ())), - MenuLayoutEntry::separator ("visibility_group"), - MenuLayoutEntry ("hide_cell", tl::to_string (QObject::tr ("Hide")), SLOT (cm_cell_hide ())), - MenuLayoutEntry ("show_cell", tl::to_string (QObject::tr ("Show")), SLOT (cm_cell_show ())), - MenuLayoutEntry ("show_all", tl::to_string (QObject::tr ("Show All")), SLOT (cm_cell_show_all ())), - MenuLayoutEntry::separator ("utils_group"), - MenuLayoutEntry ("open_current", tl::to_string (QObject::tr ("Where Am I?")), SLOT (cm_open_current_cell ())), - MenuLayoutEntry::separator ("file_group"), - MenuLayoutEntry ("save_cell_as:hide_vo", tl::to_string (QObject::tr ("Save Selected Cells As")), SLOT (cm_save_current_cell_as ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry main_menu [] = { - MenuLayoutEntry ("@hcp_context_menu", "", context_menu), - MenuLayoutEntry::last () - }; - - menu.init (main_menu); -} - HierarchyControlPanel::HierarchyControlPanel (lay::LayoutView *view, QWidget *parent, const char *name) : QFrame (parent), m_enable_cb (true), @@ -1204,4 +1158,57 @@ HierarchyControlPanel::paste () } } +// ------------------------------------------------------------ +// Declaration of the "plugin" for the menu entries + +class HierarchyControlPanelPluginDeclaration + : public lay::PluginDeclaration +{ +public: + virtual void get_menu_entries (std::vector &menu_entries) const + { + std::string at; + + at = ".end"; + menu_entries.push_back (lay::submenu ("@hcp_context_menu", at, std::string ())); + + at = "@hcp_context_menu.end"; + + menu_entries.push_back (lay::config_menu_item ("flat_mode", at, tl::to_string (QObject::tr ("Flat Cell List")), cfg_flat_cell_list, "?")), + menu_entries.push_back (lay::config_menu_item ("split_mode", at, tl::to_string (QObject::tr ("Split Mode")), cfg_split_cell_list, "?")), + menu_entries.push_back (lay::submenu ("sorting", at, tl::to_string (QObject::tr ("Sorting")))); + + { + std::string at = "@hcp_context_menu.sorting.end"; + menu_entries.push_back (lay::config_menu_item ("by_name", at, tl::to_string (QObject::tr ("By Name")), cfg_cell_list_sorting, "?by-name")); + menu_entries.push_back (lay::config_menu_item ("by_area", at, tl::to_string (QObject::tr ("By Area - Small To Large")), cfg_cell_list_sorting, "?by-area")); + menu_entries.push_back (lay::config_menu_item ("by_area", at, tl::to_string (QObject::tr ("By Area - Large To Small")), cfg_cell_list_sorting, "?by-area-reverse")); + } + + menu_entries.push_back (lay::separator ("operations_group", at)); + menu_entries.push_back (lay::menu_item ("cm_new_cell", "new_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("New Cell"))); + menu_entries.push_back (lay::menu_item ("cm_cell_delete", "delete_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Delete Cell"))); + menu_entries.push_back (lay::menu_item ("cm_cell_rename", "rename_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Rename Cell"))); + menu_entries.push_back (lay::menu_item ("cm_cell_replace", "replace_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Replace Cell"))); + menu_entries.push_back (lay::menu_item ("cm_cell_flatten", "flatten_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Flatten Cell"))); + menu_entries.push_back (lay::menu_item ("cm_cell_user_properties", "cell_user_properties", at, tl::to_string (QObject::tr ("User Properties"))); + menu_entries.push_back (lay::separator ("clipboard_group:edit_mode", at)); + menu_entries.push_back (lay::menu_item ("cm_cell_copy", "copy:edit_mode", at, tl::to_string (QObject::tr ("Copy"))); + menu_entries.push_back (lay::menu_item ("cm_cell_cut", "cut:edit_mode", at, tl::to_string (QObject::tr ("Cut"))); + menu_entries.push_back (lay::menu_item ("cm_cell_paste", "paste:edit_mode", at, tl::to_string (QObject::tr ("Paste"))); + menu_entries.push_back (lay::separator ("select_group", at)); + menu_entries.push_back (lay::menu_item ("cm_cell_select", "show_as_top", at, tl::to_string (QObject::tr ("Show As New Top"))); + menu_entries.push_back (lay::separator ("visibility_group", at)); + menu_entries.push_back (lay::menu_item ("cm_cell_hide", "hide_cell", at, tl::to_string (QObject::tr ("Hide"))); + menu_entries.push_back (lay::menu_item ("cm_cell_show", "show_cell", at, tl::to_string (QObject::tr ("Show"))); + menu_entries.push_back (lay::menu_item ("cm_cell_show_all", "show_all", at, tl::to_string (QObject::tr ("Show All"))); + menu_entries.push_back (lay::separator ("utils_group", at)); + menu_entries.push_back (lay::menu_item ("cm_open_current_cell", "open_current", at, tl::to_string (QObject::tr ("Where Am I?"))); + menu_entries.push_back (lay::separator ("file_group", at)); + menu_entries.push_back (lay::menu_item ("cm_save_current_cell_as", "save_cell_as:hide_vo", at, tl::to_string (QObject::tr ("Save Selected Cells As"))); + } +}; + +static tl::RegisteredClass config_decl (new HierarchyControlPanelPluginDeclaration (), -8, "HierarchyControlPanelPlugin"); + } // namespace lay diff --git a/src/laybasic/laybasic/layHierarchyControlPanel.h b/src/laybasic/laybasic/layHierarchyControlPanel.h index 23af9d822..f990a6916 100644 --- a/src/laybasic/laybasic/layHierarchyControlPanel.h +++ b/src/laybasic/laybasic/layHierarchyControlPanel.h @@ -116,11 +116,6 @@ public: */ ~HierarchyControlPanel (); - /** - * @brief Perform the cell control panel's initialisations on the main menu - */ - static void init_menu (lay::AbstractMenu &menu); - /** * @brief The sizeHint implementation for Qt layout management */ diff --git a/src/laybasic/laybasic/layLayerControlPanel.cc b/src/laybasic/laybasic/layLayerControlPanel.cc index 152862370..1bd353eab 100644 --- a/src/laybasic/laybasic/layLayerControlPanel.cc +++ b/src/laybasic/laybasic/layLayerControlPanel.cc @@ -229,86 +229,6 @@ LCPTreeWidget::expand_all () // -------------------------------------------------------------------- // LayerControlPanel implementation -void -LayerControlPanel::init_menu (lay::AbstractMenu &menu) -{ - MenuLayoutEntry sort_by_menu [] = { - MenuLayoutEntry ("sort_ild", tl::to_string (QObject::tr ("Layout Index, Layer And Datatype")), SLOT (cm_lv_sort_by_ild ())), - MenuLayoutEntry ("sort_idl", tl::to_string (QObject::tr ("Layout Index, Datatype And Layer")), SLOT (cm_lv_sort_by_idl ())), - MenuLayoutEntry ("sort_ldi", tl::to_string (QObject::tr ("Layer, Datatype And Layout Index")), SLOT (cm_lv_sort_by_ldi ())), - MenuLayoutEntry ("sort_dli", tl::to_string (QObject::tr ("Datatype, Layer And Layout Index")), SLOT (cm_lv_sort_by_dli ())), - MenuLayoutEntry ("sort_name", tl::to_string (QObject::tr ("Name")), SLOT (cm_lv_sort_by_name ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry regroup_menu [] = { - MenuLayoutEntry ("grp_i", tl::to_string (QObject::tr ("By Layout Index")), SLOT (cm_lv_regroup_by_index ())), - MenuLayoutEntry ("grp_d", tl::to_string (QObject::tr ("By Datatype")), SLOT (cm_lv_regroup_by_datatype ())), - MenuLayoutEntry ("grp_l", tl::to_string (QObject::tr ("By Layer")), SLOT (cm_lv_regroup_by_layer ())), - MenuLayoutEntry ("flatten", tl::to_string (QObject::tr ("Flatten")), SLOT (cm_lv_regroup_flatten ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry tab_menu [] = { - MenuLayoutEntry ("new_tab", tl::to_string (QObject::tr ("New Tab")), SLOT (cm_lv_new_tab ())), - MenuLayoutEntry ("remove_tab", tl::to_string (QObject::tr ("Remove Tab")), SLOT (cm_lv_remove_tab ())), - MenuLayoutEntry ("rename_tab", tl::to_string (QObject::tr ("Rename Tab")), SLOT (cm_lv_rename_tab ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry context_menu [] = { - MenuLayoutEntry ("select_all", tl::to_string (QObject::tr ("Select All")), SLOT (cm_lv_select_all ())), - // It is not sure, whether "expandAll" destabilizes the tree widget: - // MenuLayoutEntry ("expand_all", tl::to_string (QObject::tr ("Expand All")), SLOT (cm_lv_expand_all ())), - MenuLayoutEntry::separator ("tab_group"), - MenuLayoutEntry ("tab_menu", tl::to_string (QObject::tr ("Tabs")), tab_menu), - MenuLayoutEntry::separator ("visibility_group"), - MenuLayoutEntry ("hide", tl::to_string (QObject::tr ("Hide")), SLOT (cm_lv_hide ())), - MenuLayoutEntry ("hide_all", tl::to_string (QObject::tr ("Hide All")), SLOT (cm_lv_hide_all ())), - MenuLayoutEntry ("show", tl::to_string (QObject::tr ("Show")), SLOT (cm_lv_show ())), - MenuLayoutEntry ("show_all", tl::to_string (QObject::tr ("Show All")), SLOT (cm_lv_show_all ())), - MenuLayoutEntry ("show_only", tl::to_string (QObject::tr ("Show Only Selected")), SLOT (cm_lv_show_only ())), - MenuLayoutEntry ("valid", tl::to_string (QObject::tr ("Make Valid")), SLOT (cm_lv_make_valid ())), - MenuLayoutEntry ("invvalid", tl::to_string (QObject::tr ("Make Invalid")), SLOT (cm_lv_make_invalid ())), - MenuLayoutEntry ("rename", tl::to_string (QObject::tr ("Rename")), SLOT (cm_lv_rename ())), - MenuLayoutEntry::separator ("options_group"), - MenuLayoutEntry ("hide_empty_layers", tl::to_string (QObject::tr ("Hide Empty Layers")), std::make_pair (cfg_hide_empty_layers, "?")), - MenuLayoutEntry ("test_shapes_in_view", tl::to_string (QObject::tr ("Test For Shapes In View")), std::make_pair (cfg_test_shapes_in_view, "?")), - MenuLayoutEntry::separator ("source_group"), - MenuLayoutEntry ("select_source", tl::to_string (QObject::tr ("Select Source")), SLOT (cm_lv_source ())), - MenuLayoutEntry::separator ("sort_group"), - MenuLayoutEntry ("sort_menu", tl::to_string (QObject::tr ("Sort By")), sort_by_menu), - MenuLayoutEntry::separator ("view_group"), - MenuLayoutEntry ("del", tl::to_string (QObject::tr ("Delete Layer Entry")), SLOT (cm_lv_delete ())), - MenuLayoutEntry ("insert", tl::to_string (QObject::tr ("Insert Layer Entry")), SLOT (cm_lv_insert ())), - MenuLayoutEntry ("add_others", tl::to_string (QObject::tr ("Add Other Layer Entries")), SLOT (cm_lv_add_missing ())), - MenuLayoutEntry ("clean_up", tl::to_string (QObject::tr ("Clean Up Layer Entries")), SLOT (cm_lv_remove_unused ())), - MenuLayoutEntry::separator ("grouping_group"), - MenuLayoutEntry ("group", tl::to_string (QObject::tr ("Group")), SLOT (cm_lv_group ())), - MenuLayoutEntry ("ungroup", tl::to_string (QObject::tr ("Ungroup")), SLOT (cm_lv_ungroup ())), - MenuLayoutEntry ("regroup_menu", tl::to_string (QObject::tr ("Regroup Layer Entries")), regroup_menu), - MenuLayoutEntry::separator ("copy_paste_group"), - MenuLayoutEntry ("copy", tl::to_string (QObject::tr ("Copy")), SLOT (cm_lv_copy ())), - MenuLayoutEntry ("cut", tl::to_string (QObject::tr ("Cut")), SLOT (cm_lv_cut ())), - MenuLayoutEntry ("paste", tl::to_string (QObject::tr ("Paste")), SLOT (cm_lv_paste ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry lcp_context_menu [] = { - MenuLayoutEntry ("@lcp_context_menu", "", context_menu), - MenuLayoutEntry::last () - }; - - menu.init (lcp_context_menu); - - MenuLayoutEntry lcp_tab_context_menu [] = { - MenuLayoutEntry ("@lcp_tabs_context_menu", "", tab_menu), - MenuLayoutEntry::last () - }; - - menu.init (lcp_tab_context_menu); -} - LayerControlPanel::LayerControlPanel (lay::LayoutView *view, db::Manager *manager, QWidget *parent, const char *name) : QFrame (parent), db::Object (manager), @@ -2399,4 +2319,96 @@ LayerControlPanel::do_move (int mode) mp_view->set_selected_layers (new_sel); } +// ------------------------------------------------------------ +// Declaration of the "plugin" for the menu entries + +class LayerControlPanelPluginDeclaration + : public lay::PluginDeclaration +{ +public: + virtual void get_menu_entries (std::vector &menu_entries) const + { + std::string at; + + at = ".end"; + menu_entries.push_back (lay::submenu ("@lcp_context_menu", at, std::string ())); + + at = "@lcp_context_menu.end"; + + menu_entries.push_back (lay::menu_item ("cm_lv_select_all", "select_all", at, tl::to_string (QObject::tr ("Select All"))); + // It is not sure, whether "expandAll" destabilizes the tree widget: + // menu_entries.push_back (lay::menu_item ("cm_lv_expand_all", "expand_all", at, tl::to_string (QObject::tr ("Expand All"))); + menu_entries.push_back (lay::separator ("tab_group", at)); + menu_entries.push_back (lay::submenu ("tab_menu", at, tl::to_string (QObject::tr ("Tabs")))); + + { + std::string at = "@lcp_context_menu.tab_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_lv_new_tab", "new_tab", at, tl::to_string (QObject::tr ("New Tab"))); + menu_entries.push_back (lay::menu_item ("cm_lv_remove_tab", "remove_tab", at, tl::to_string (QObject::tr ("Remove Tab"))); + menu_entries.push_back (lay::menu_item ("cm_lv_rename_tab", "rename_tab", at, tl::to_string (QObject::tr ("Rename Tab"))); + } + + menu_entries.push_back (lay::separator ("visibility_group", at)); + menu_entries.push_back (lay::menu_item ("cm_lv_hide", "hide", at, tl::to_string (QObject::tr ("Hide"))); + menu_entries.push_back (lay::menu_item ("cm_lv_hide_all", "hide_all", at, tl::to_string (QObject::tr ("Hide All"))); + menu_entries.push_back (lay::menu_item ("cm_lv_show", "show", at, tl::to_string (QObject::tr ("Show"))); + menu_entries.push_back (lay::menu_item ("cm_lv_show_all", "show_all", at, tl::to_string (QObject::tr ("Show All"))); + menu_entries.push_back (lay::menu_item ("cm_lv_show_only", "show_only", at, tl::to_string (QObject::tr ("Show Only Selected"))); + menu_entries.push_back (lay::menu_item ("cm_lv_make_valid", "valid", at, tl::to_string (QObject::tr ("Make Valid"))); + menu_entries.push_back (lay::menu_item ("cm_lv_make_invalid", "invvalid", at, tl::to_string (QObject::tr ("Make Invalid"))); + menu_entries.push_back (lay::menu_item ("cm_lv_rename", "rename", at, tl::to_string (QObject::tr ("Rename"))); + menu_entries.push_back (lay::separator ("options_group", at)); + menu_entries.push_back (lay::config_menu_item ("hide_empty_layers", at, tl::to_string (QObject::tr ("Hide Empty Layers")), cfg_hide_empty_layers, "?")); + menu_entries.push_back (lay::config_menu_item ("test_shapes_in_view", at, tl::to_string (QObject::tr ("Test For Shapes In View")), cfg_test_shapes_in_view, "?")); + menu_entries.push_back (lay::separator ("source_group", at)); + menu_entries.push_back (lay::menu_item ("cm_lv_source", "select_source", at, tl::to_string (QObject::tr ("Select Source"))); + menu_entries.push_back (lay::separator ("sort_group", at)); + menu_entries.push_back (lay::submenu ("sort_menu", at, tl::to_string (QObject::tr ("Sort By")))); + + { + std::string at = "@lcp_context_menu.sort_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_lv_sort_by_ild", "sort_ild", at, tl::to_string (QObject::tr ("Layout Index, Layer And Datatype"))); + menu_entries.push_back (lay::menu_item ("cm_lv_sort_by_idl", "sort_idl", at, tl::to_string (QObject::tr ("Layout Index, Datatype And Layer"))); + menu_entries.push_back (lay::menu_item ("cm_lv_sort_by_ldi", "sort_ldi", at, tl::to_string (QObject::tr ("Layer, Datatype And Layout Index"))); + menu_entries.push_back (lay::menu_item ("cm_lv_sort_by_dli", "sort_dli", at, tl::to_string (QObject::tr ("Datatype, Layer And Layout Index"))); + menu_entries.push_back (lay::menu_item ("cm_lv_sort_by_name", "sort_name", at, tl::to_string (QObject::tr ("Name"))); + } + + menu_entries.push_back (lay::separator ("view_group", at)); + menu_entries.push_back (lay::menu_item ("cm_lv_delete", "del", at, tl::to_string (QObject::tr ("Delete Layer Entry"))); + menu_entries.push_back (lay::menu_item ("cm_lv_insert", "insert", at, tl::to_string (QObject::tr ("Insert Layer Entry"))); + menu_entries.push_back (lay::menu_item ("cm_lv_add_missing", "add_others", at, tl::to_string (QObject::tr ("Add Other Layer Entries"))); + menu_entries.push_back (lay::menu_item ("cm_lv_remove_unused", "clean_up", at, tl::to_string (QObject::tr ("Clean Up Layer Entries"))); + menu_entries.push_back (lay::separator ("grouping_group", at)); + menu_entries.push_back (lay::menu_item ("cm_lv_group", "group", at, tl::to_string (QObject::tr ("Group"))); + menu_entries.push_back (lay::menu_item ("cm_lv_ungroup", "ungroup", at, tl::to_string (QObject::tr ("Ungroup"))); + menu_entries.push_back (lay::submenu ("regroup_menu", at, tl::to_string (QObject::tr ("Regroup Layer Entries")))); + + { + std::string at = "@lcp_context_menu.regroup_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_lv_regroup_by_index", "grp_i", at, tl::to_string (QObject::tr ("By Layout Index"))); + menu_entries.push_back (lay::menu_item ("cm_lv_regroup_by_datatype", "grp_d", at, tl::to_string (QObject::tr ("By Datatype"))); + menu_entries.push_back (lay::menu_item ("cm_lv_regroup_by_layer", "grp_l", at, tl::to_string (QObject::tr ("By Layer"))); + menu_entries.push_back (lay::menu_item ("cm_lv_regroup_flatten", "flatten", at, tl::to_string (QObject::tr ("Flatten"))); + } + + menu_entries.push_back (lay::separator ("copy_paste_group", at)); + menu_entries.push_back (lay::menu_item ("cm_lv_copy", "copy", at, tl::to_string (QObject::tr ("Copy"))); + menu_entries.push_back (lay::menu_item ("cm_lv_cut", "cut", at, tl::to_string (QObject::tr ("Cut"))); + menu_entries.push_back (lay::menu_item ("cm_lv_paste", "paste", at, tl::to_string (QObject::tr ("Paste"))); + + at = ".end"; + menu_entries.push_back (lay::submenu ("@lcp_tabs_context_menu", at, std::string ())); + + { + std::string at = "@lcp_tabs_context_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_lv_new_tab", "new_tab", at, tl::to_string (QObject::tr ("New Tab"))); + menu_entries.push_back (lay::menu_item ("cm_lv_remove_tab", "remove_tab", at, tl::to_string (QObject::tr ("Remove Tab"))); + menu_entries.push_back (lay::menu_item ("cm_lv_rename_tab", "rename_tab", at, tl::to_string (QObject::tr ("Rename Tab"))); + } + } +}; + +static tl::RegisteredClass config_decl (new LayerControlPanelPluginDeclaration (), -9, "LayerControlPanelPlugin"); + } // namespace lay diff --git a/src/laybasic/laybasic/layLayerControlPanel.h b/src/laybasic/laybasic/layLayerControlPanel.h index a6bbde994..d7caea7a5 100644 --- a/src/laybasic/laybasic/layLayerControlPanel.h +++ b/src/laybasic/laybasic/layLayerControlPanel.h @@ -138,11 +138,6 @@ public: */ bool has_focus () const; - /** - * @brief Perform the layer control panel's initialisations on the main menu - */ - static void init_menu (lay::AbstractMenu &menu); - /** * @brief Tell, if there is something to copy */ diff --git a/src/lay/lay/layLayoutStatistics.qrc b/src/laybasic/laybasic/layLayoutStatistics.qrc similarity index 100% rename from src/lay/lay/layLayoutStatistics.qrc rename to src/laybasic/laybasic/layLayoutStatistics.qrc diff --git a/src/lay/lay/layLayoutStatisticsForm.cc b/src/laybasic/laybasic/layLayoutStatisticsForm.cc similarity index 100% rename from src/lay/lay/layLayoutStatisticsForm.cc rename to src/laybasic/laybasic/layLayoutStatisticsForm.cc diff --git a/src/lay/lay/layLayoutStatisticsForm.h b/src/laybasic/laybasic/layLayoutStatisticsForm.h similarity index 100% rename from src/lay/lay/layLayoutStatisticsForm.h rename to src/laybasic/laybasic/layLayoutStatisticsForm.h diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index 13a29ea6f..45525bef6 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -44,7 +44,6 @@ #include "tlAssert.h" #include "tlExceptions.h" #include "layLayoutView.h" -#include "layAbstractMenuProvider.h" #include "layViewOp.h" #include "layViewObject.h" #include "layLayoutViewConfigPages.h" @@ -70,6 +69,11 @@ #include "layBookmarkManagementForm.h" #include "layNetlistBrowserDialog.h" #include "layBookmarksView.h" +#include "laySelectCellViewForm.h" +#include "layCellSelectionForm.h" +#include "layLayoutPropertiesForm.h" +#include "layLayoutStatisticsForm.h" +#include "dbClipboard.h" #include "dbLayout.h" #include "dbLayoutUtils.h" #include "dbRecursiveShapeIterator.h" @@ -255,35 +259,33 @@ static LayoutView *ms_current = 0; LayoutView::LayoutView (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options) : QFrame (parent), - lay::Plugin (plugin_parent), - lay::AbstractMenuProvider (false /* don't register as global instance */), - m_menu (this), + lay::Dispatcher (plugin_parent, false /*not standalone*/), m_editable (editable), m_options (options), m_annotation_shapes (manager), dm_prop_changed (this, &LayoutView::do_prop_changed) { - if (! plugin_root_maybe_null ()) { - mp_plugin_root.reset (new lay::PluginRoot (true, false)); - } + // either it's us or the parent has a dispatcher + tl_assert (dispatcher () != 0); // ensures the deferred method scheduler is present tl::DeferredMethodScheduler::instance (); setObjectName (QString::fromUtf8 (name)); - init (manager, plugin_root_maybe_null () ? plugin_root_maybe_null () : mp_plugin_root.get (), parent); + init (manager, dispatcher (), parent); } -LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool editable, lay::PluginRoot *root, QWidget *parent, const char *name, unsigned int options) +LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options) : QFrame (parent), - lay::Plugin (root), - lay::AbstractMenuProvider (false /* don't register as global instance */), - m_menu (this), + lay::Dispatcher (plugin_parent, false /*not standalone*/), m_editable (editable), m_options (options), m_annotation_shapes (manager), dm_prop_changed (this, &LayoutView::do_prop_changed) { + // either it's us or the parent has a dispatcher + tl_assert (dispatcher () != 0); + // ensures the deferred method scheduler is present tl::DeferredMethodScheduler::instance (); @@ -291,7 +293,7 @@ LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool edit m_annotation_shapes = source->m_annotation_shapes; - init (manager, root, parent); + init (manager, dispatcher (), parent); // set the handle reference and clear all cell related stuff m_cellviews = source->cellview_list (); @@ -353,14 +355,13 @@ LayoutView::eventFilter(QObject *obj, QEvent *event) } void -LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/) +LayoutView::init (db::Manager *mgr, lay::Dispatcher *dispatcher, QWidget * /*parent*/) { manager (mgr); - if (! lay::AbstractMenuProvider::instance () || ! lay::AbstractMenuProvider::instance ()->menu ()) { - init_menu (m_menu); + if (! dispatcher) { // build the context menus, nothing else so far. - m_menu.build (0, 0); + menu ()->build (0, 0); } m_annotation_shapes.manager (mgr); @@ -597,9 +598,7 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/) connect (mp_timer, SIGNAL (timeout ()), this, SLOT (timer ())); mp_timer->start (timer_interval); - if (root) { - create_plugins (root); - } + create_plugins (); m_new_layer_props.layer = 1; m_new_layer_props.datatype = 0; @@ -704,62 +703,6 @@ QWidget *LayoutView::menu_parent_widget () return this; } -lay::Action & -LayoutView::action_for_slot (const char *slot) -{ - std::map::iterator a = m_actions_for_slot.find (std::string (slot)); - if (a != m_actions_for_slot.end ()) { - return a->second; - } else { - Action a = Action::create_free_action (this); - gtf::action_connect (a.qaction (), SIGNAL (triggered ()), this, slot); - return m_actions_for_slot.insert (std::make_pair (std::string (slot), a)).first->second; - } -} - -lay::Action * -LayoutView::create_config_action (const std::string &title, const std::string &cname, const std::string &cvalue) -{ - lay::ConfigureAction *ca = new lay::ConfigureAction (plugin_root (), title, cname, cvalue); - m_ca_collection.push_back (ca); - return ca; -} - -lay::Action * -LayoutView::create_config_action (const std::string &cname, const std::string &cvalue) -{ - lay::ConfigureAction *ca = new lay::ConfigureAction (plugin_root (), std::string (), cname, cvalue); - m_ca_collection.push_back (ca); - return ca; -} - -void -LayoutView::register_config_action (const std::string &name, lay::ConfigureAction *action) -{ - std::map >::iterator ca = m_configuration_actions.insert (std::make_pair (name, std::vector ())).first; - for (std::vector::iterator a = ca->second.begin (); a != ca->second.end (); ++a) { - if (*a == action) { - return; // already registered - } - } - - ca->second.push_back (action); -} - -void -LayoutView::unregister_config_action (const std::string &name, lay::ConfigureAction *action) -{ - std::map >::iterator ca = m_configuration_actions.find (name); - if (ca != m_configuration_actions.end ()) { - for (std::vector::iterator a = ca->second.begin (); a != ca->second.end (); ++a) { - if (*a == action) { - ca->second.erase (a); - return; - } - } - } -} - void LayoutView::side_panel_destroyed () { if (sender () == mp_control_frame) { @@ -859,9 +802,9 @@ void LayoutView::drop_url (const std::string &path_or_url) } } -lay::Plugin *LayoutView::create_plugin (lay::PluginRoot *root, const lay::PluginDeclaration *cls) +lay::Plugin *LayoutView::create_plugin (const lay::PluginDeclaration *cls) { - lay::Plugin *p = cls->create_plugin (manager (), root, this); + lay::Plugin *p = cls->create_plugin (manager (), dispatcher (), this); if (p) { // unhook the plugin from the script side if created there (prevent GC from destroying it) @@ -881,7 +824,7 @@ lay::Plugin *LayoutView::create_plugin (lay::PluginRoot *root, const lay::Plugin return p; } -void LayoutView::create_plugins (lay::PluginRoot *root, const lay::PluginDeclaration *except_this) +void LayoutView::create_plugins (const lay::PluginDeclaration *except_this) { for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { delete *p; @@ -896,13 +839,13 @@ void LayoutView::create_plugins (lay::PluginRoot *root, const lay::PluginDeclara // TODO: clean solution. The following is a HACK: if (cls.current_name () == "ant::Plugin" || cls.current_name () == "img::Plugin") { // ant and img are created always - create_plugin (root, &*cls); + create_plugin (&*cls); } else if ((m_options & LV_NoPlugins) == 0) { // others: only create unless LV_NoPlugins is set - create_plugin (root, &*cls); + create_plugin (&*cls); } else if ((m_options & LV_NoGrid) == 0 && cls.current_name () == "GridNetPlugin") { // except grid net plugin which is created on request - create_plugin (root, &*cls); + create_plugin (&*cls); } } @@ -932,15 +875,6 @@ Plugin *LayoutView::get_plugin_by_name (const std::string &name) const return 0; } -void -LayoutView::init_menu (lay::AbstractMenu &menu) -{ - lay::LayerControlPanel::init_menu (menu); - lay::HierarchyControlPanel::init_menu (menu); - lay::LibrariesView::init_menu (menu); - lay::BookmarksView::init_menu (menu); -} - void LayoutView::update_menu (lay::LayoutView *view, lay::AbstractMenu &menu) { @@ -1045,6 +979,8 @@ LayoutView::reset_title () bool LayoutView::configure (const std::string &name, const std::string &value) { + lay::Dispatcher::configure (name, value); + if (mp_move_service && mp_move_service->configure (name, value)) { return true; } @@ -4773,7 +4709,7 @@ LayoutView::active_library_changed (int /*index*/) // commit the new active library to the other views and persist this state // TODO: could be passed through the LibraryController (like through some LibraryController::active_library) - plugin_root ()->config_set (cfg_current_lib_view, lib_name); + dispatcher ()->config_set (cfg_current_lib_view, lib_name); } void @@ -6540,25 +6476,461 @@ LayoutView::intrinsic_mouse_modes (std::vector *descriptions) AbstractMenu * LayoutView::menu () { - if (lay::AbstractMenuProvider::instance () && lay::AbstractMenuProvider::instance ()->menu ()) { - return lay::AbstractMenuProvider::instance ()->menu (); - } else { - return &m_menu; - } + // NOTE: dispatcher is either this or the real end of the chain + return dispatcher ()->menu (); } -int +int LayoutView::default_mode () { return 0; // TODO: any generic scheme? is select, should be ruler.. } -void +void +LayoutView::do_cm_duplicate (bool interactive) +{ + // Do duplicate simply by concatenating copy & paste currently. + // Save the clipboard state before in order to preserve the current content + db::Clipboard saved_clipboard; + db::Clipboard::instance ().swap (saved_clipboard); + + try { + copy (); + clear_selection (); + cancel (); + if (interactive) { + paste_interactive (); + } else { + paste (); + } + db::Clipboard::instance ().swap (saved_clipboard); + } catch (...) { + db::Clipboard::instance ().swap (saved_clipboard); + throw; + } +} + +void +LayoutView::do_cm_paste (bool interactive) +{ + if (! db::Clipboard::instance ().empty ()) { + cancel (); + clear_selection (); + if (interactive) { + paste_interactive (); + } else { + paste (); + } + } +} + +void +LayoutView::cm_new_cell () +{ + static double s_new_cell_window_size = 2.0; + static std::string s_new_cell_cell_name; + + NewCellPropertiesDialog cell_prop_dia (this); + if (cell_prop_dia.exec_dialog (& cellview (active_cellview_index ())->layout (), s_new_cell_cell_name, s_new_cell_window_size)) { + + db::cell_index_type new_ci = new_cell (active_cellview_index (), s_new_cell_cell_name.c_str ()); + select_cell (new_ci, active_cellview_index ()); + + db::DBox zb = db::DBox (-0.5 * s_new_cell_window_size, -0.5 * s_new_cell_window_size, 0.5 * s_new_cell_window_size, 0.5 * s_new_cell_window_size); + if (get_max_hier_levels () < 1 || get_min_hier_levels () > 0) { + zoom_box_and_set_hier_levels (zb, std::make_pair (0, 1)); + } else { + zoom_box (zb); + } + + } +} + +// TODO: this constant is defined in MainWindow.cc too ... +const int max_dirty_files = 15; + +void +LayoutView::cm_reload () +{ + std::vector selected; + + if (cellviews () > 1) { + + SelectCellViewForm form (0, this, tl::to_string (QObject::tr ("Select Layouts To Reload"))); + form.select_all (); + + if (form.exec () == QDialog::Accepted) { + selected = form.selected_cellviews (); + } + + } else if (cellviews () > 0) { + selected.push_back (0); + } + + if (selected.size () > 0) { + + int dirty_layouts = 0; + std::string dirty_files; + + for (std::vector ::const_iterator i = selected.begin (); i != selected.end (); ++i) { + + const lay::CellView &cv = cellview (*i); + + if (cv->layout ().is_editable () && cv->is_dirty ()) { + ++dirty_layouts; + if (dirty_layouts == max_dirty_files) { + dirty_files += "\n..."; + } else if (dirty_layouts < max_dirty_files) { + if (! dirty_files.empty ()) { + dirty_files += "\n"; + } + dirty_files += cv->name (); + } + } + + } + + bool can_reload = true; + if (dirty_layouts != 0) { + + QMessageBox mbox (this); + mbox.setText (tl::to_qstring (tl::to_string (QObject::tr ("The following layouts need saving:\n\n")) + dirty_files + "\n\nPress 'Reload Without Saving' to reload anyhow and discard changes.")); + mbox.setWindowTitle (QObject::tr ("Save Needed")); + mbox.setIcon (QMessageBox::Warning); + QAbstractButton *yes_button = mbox.addButton (QObject::tr ("Reload Without Saving"), QMessageBox::YesRole); + mbox.addButton (QMessageBox::Cancel); + + mbox.exec (); + + can_reload = (mbox.clickedButton() == yes_button); + + } + + if (can_reload) { + + // Actually reload + for (std::vector ::const_iterator i = selected.begin (); i != selected.end (); ++i) { + reload_layout (*i); + } + + } + + } +} + +std::vector +LayoutView::menu_symbols () +{ + // TODO: currently these are all symbols from all plugins + return lay::PluginDeclaration::menu_symbols (); +} + +void LayoutView::menu_activated (const std::string &symbol) { - // distribute the menu on the plugins - one should take it. - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - (*p)->menu_activated (symbol); + if (symbol == "cm_show_properties") { + show_properties (this); + } else if (symbol == "cm_delete") { + + del (); + // because a "delete" might involve objects currently edited, we cancel the edit after we have deleted the object + cancel (); + clear_selection (); + + } else if (symbol == "cm_unselect_all") { + select (db::DBox (), lay::Editable::Reset); + } else if (symbol == "cm_select_all") { + select (full_box (), lay::Editable::Replace); + } else if (symbol == "cm_lv_paste") { + cm_layer_paste (); + } else if (symbol == "cm_lv_cut") { + cm_layer_cut (); + } else if (symbol == "cm_lv_copy") { + cm_layer_copy (); + } else if (symbol == "cm_cell_paste") { + cm_cell_paste (); + } else if (symbol == "cm_cell_cut") { + cm_cell_cut (); + } else if (symbol == "cm_cell_copy") { + cm_cell_copy (); + } else if (symbol == "cm_duplicate") { + do_cm_duplicate (false); + } else if (symbol == "cm_duplicate_interactive") { + do_cm_duplicate (true); + } else if (symbol == "cm_copy") { + + copy (); + clear_selection (); + + } else if (symbol == "cm_paste") { + do_cm_paste (true); + } else if (symbol == "cm_paste_interactive") { + do_cm_paste (true); + } else if (symbol == "cm_cut") { + + cut (); + cancel (); // see del() for reason why cancel is after cut + clear_selection (); + + } else if (symbol == "cm_zoom_fit_sel") { + zoom_fit_sel (); + } else if (symbol == "cm_zoom_fit") { + zoom_fit (); + } else if (symbol == "cm_pan_left") { + pan_left (); + } else if (symbol == "cm_pan_right") { + pan_right (); + } else if (symbol == "cm_pan_up") { + pan_up (); + } else if (symbol == "cm_pan_down") { + pan_down (); + } else if (symbol == "cm_zoom_in") { + zoom_in (); + } else if (symbol == "cm_zoom_out") { + zoom_out (); + } else if (symbol == "cm_select_current_cell") { + + if (active_cellview_index () >= 0) { + lay::LayoutView::cell_path_type path; + int cvi = active_cellview_index (); + current_cell_path (path); + select_cell_fit (path, cvi); + } + + } else if (symbol == "cm_open_current_cell") { + + if (active_cellview_index () >= 0) { + cm_open_current_cell (); + } + + } else if (symbol == "cm_select_cell") { + + if (active_cellview_index () >= 0) { + + CellSelectionForm form (0, this, "cell_selection_form"); + + if (form.exec () == QDialog::Accepted && + form.selected_cellview_index () >= 0) { + select_cell (form.selected_cellview ().combined_unspecific_path (), form.selected_cellview_index ()); + set_current_cell_path (form.selected_cellview_index (), form.selected_cellview ().combined_unspecific_path ()); + zoom_fit (); + } + + } + + } else if (symbol == "cm_new_cell") { + cm_new_cell (); + } else if (symbol == "cm_adjust_origin") { + if (active_cellview_index () >= 0) { + cm_align_cell_origin (); + } + } else if (symbol == "cm_cell_convert_to_static") { + if (active_cellview_index () >= 0) { + cm_cell_convert_to_static (); + } + } else if (symbol == "cm_lay_convert_to_static") { + if (active_cellview_index () >= 0) { + cm_lay_convert_to_static (); + } + } else if (symbol == "cm_lay_move") { + if (active_cellview_index () >= 0) { + cm_lay_move (); + } + } else if (symbol == "cm_lay_scale") { + if (active_cellview_index () >= 0) { + cm_lay_scale (); + } + } else if (symbol == "cm_lay_free_rot") { + if (active_cellview_index () >= 0) { + cm_lay_free_rot (); + } + } else if (symbol == "cm_lay_rot_ccw") { + if (active_cellview_index () >= 0) { + cm_lay_rot_ccw (); + } + } else if (symbol == "cm_lay_rot_cw") { + if (active_cellview_index () >= 0) { + cm_lay_rot_cw (); + } + } else if (symbol == "cm_lay_flip_y") { + if (active_cellview_index () >= 0) { + cm_lay_flip_y (); + } + } else if (symbol == "cm_lay_flip_x") { + if (active_cellview_index () >= 0) { + cm_lay_flip_x (); + } + } else if (symbol == "cm_sel_move") { + if (active_cellview_index () >= 0) { + cm_sel_move (); + } + } else if (symbol == "cm_sel_move_to") { + if (active_cellview_index () >= 0) { + cm_sel_move_to (); + } + } else if (symbol == "cm_sel_move_interactive") { + if (active_cellview_index () >= 0) { + cm_sel_move_interactive (); + } + } else if (symbol == "cm_sel_scale") { + if (active_cellview_index () >= 0) { + cm_sel_scale (); + } + } else if (symbol == "cm_sel_free_rot") { + if (active_cellview_index () >= 0) { + cm_sel_free_rot (); + } + } else if (symbol == "cm_sel_rot_ccw") { + if (active_cellview_index () >= 0) { + cm_sel_rot_ccw (); + } + } else if (symbol == "cm_sel_rot_cw") { + if (active_cellview_index () >= 0) { + cm_sel_rot_cw (); + } + } else if (symbol == "cm_sel_flip_y") { + if (active_cellview_index () >= 0) { + cm_sel_flip_y (); + } + } else if (symbol == "cm_sel_flip_x") { + if (active_cellview_index () >= 0) { + cm_sel_flip_x (); + } + } else if (symbol == "cm_edit_layer") { + if (active_cellview_index () >= 0) { + cm_edit_layer (); + } + } else if (symbol == "cm_delete_layer") { + if (active_cellview_index () >= 0) { + cm_edit_layer (); + } + } else if (symbol == "cm_clear_layer") { + if (active_cellview_index () >= 0) { + cm_clear_layer (); + } + } else if (symbol == "cm_copy_layer") { + if (active_cellview_index () >= 0) { + cm_copy_layer (); + } + } else if (symbol == "cm_new_layer") { + if (active_cellview_index () >= 0) { + cm_new_layer (); + } + } else if (symbol == "cm_layout_props") { + LayoutPropertiesForm lp_form (this, this, "layout_props_form"); + lp_form.exec (); + } else if (symbol == "cm_layout_stats") { + LayoutStatisticsForm lp_form (this, this, "layout_props_form"); + lp_form.exec (); + } else if (symbol == "cm_reload") { + cm_reload (); + } else if (symbol == "cm_inc_max_hier") { + int new_to = get_max_hier_levels () + 1; + set_hier_levels (std::make_pair (get_min_hier_levels (), new_to)); + } else if (symbol == "cm_dec_max_hier") { + int new_to = get_max_hier_levels () > 0 ? get_max_hier_levels () - 1 : 0; + set_hier_levels (std::make_pair (std::min (get_min_hier_levels (), new_to), new_to)); + } else if (symbol == "cm_max_hier") { + max_hier (); + } else if (symbol == "cm_max_hier_0") { + set_hier_levels (std::make_pair (std::min (get_min_hier_levels (), 0), 0)); + } else if (symbol == "cm_max_hier_1") { + set_hier_levels (std::make_pair (std::min (get_min_hier_levels (), 0), 1)); + } else if (symbol == "cm_prev_display_state") { + if (has_prev_display_state ()) { + prev_display_state (); + } + } else if (symbol == "cm_next_display_state") { + if (has_next_display_state ()) { + next_display_state (); + } + } else if (symbol == "cm_redraw") { + redraw (); + } else if (symbol == "cm_cell_delete") { + cm_cell_delete (); + } else if (symbol == "cm_cell_replace") { + cm_cell_replace (); + } else if (symbol == "cm_cell_rename") { + cm_cell_rename (); + } else if (symbol == "cm_cell_flatten") { + cm_cell_flatten (); + } else if (symbol == "cm_cell_select") { + cm_cell_select (); + } else if (symbol == "cm_cell_hide") { + cm_cell_hide (); + } else if (symbol == "cm_cell_show") { + cm_cell_show (); + } else if (symbol == "cm_cell_show_all") { + cm_cell_show_all (); + } else if (symbol == "cm_cell_user_properties") { + if (active_cellview_index () >= 0) { + cm_cell_user_properties (); + } + } else if (symbol == "cm_lv_select_all") { + cm_select_all (); + } else if (symbol == "cm_lv_new_tab") { + cm_new_tab (); + } else if (symbol == "cm_lv_rename_tab") { + cm_rename_tab (); + } else if (symbol == "cm_lv_make_invalid") { + cm_make_invalid (); + } else if (symbol == "cm_lv_remove_tab") { + cm_remove_tab (); + } else if (symbol == "cm_lv_make_valid") { + cm_make_valid (); + } else if (symbol == "cm_lv_hide_all") { + cm_hide_all (); + } else if (symbol == "cm_lv_hide") { + cm_hide (); + } else if (symbol == "cm_lv_show_only") { + cm_show_only (); + } else if (symbol == "cm_lv_show_all") { + cm_show_all (); + } else if (symbol == "cm_lv_show") { + cm_show (); + } else if (symbol == "cm_lv_rename") { + cm_rename (); + } else if (symbol == "cm_lv_delete") { + cm_delete (); + } else if (symbol == "cm_lv_insert") { + cm_insert (); + } else if (symbol == "cm_lv_group") { + cm_group (); + } else if (symbol == "cm_lv_ungroup") { + cm_ungroup (); + } else if (symbol == "cm_lv_source") { + cm_source (); + } else if (symbol == "cm_lv_sort_by_name") { + cm_sort_by_name (); + } else if (symbol == "cm_lv_sort_by_ild") { + cm_sort_by_ild (); + } else if (symbol == "cm_lv_sort_by_idl") { + cm_sort_by_idl (); + } else if (symbol == "cm_lv_sort_by_ldi") { + cm_sort_by_ldi (); + } else if (symbol == "cm_lv_sort_by_dli") { + cm_sort_by_dli (); + } else if (symbol == "cm_lv_regroup_by_index") { + cm_regroup_by_index (); + } else if (symbol == "cm_lv_regroup_by_datatype") { + cm_regroup_by_datatype (); + } else if (symbol == "cm_lv_regroup_by_layer") { + cm_regroup_by_layer (); + } else if (symbol == "cm_lv_regroup_flatten") { + cm_regroup_flatten (); + } else if (symbol == "cm_lv_expand_all") { + cm_expand_all (); + } else if (symbol == "cm_lv_add_missing") { + cm_add_missing (); + } else if (symbol == "cm_lv_remove_unused") { + cm_remove_unused (); + } else { + + // distribute the menu on the plugins - one should take it. + for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + (*p)->menu_activated (symbol); + } + } } @@ -7596,5 +7968,186 @@ LayoutView::sizeHint () const } } -} // namespace lay +// ------------------------------------------------------------ +// Declaration of the "plugin" for the menu entries +class LayoutViewPluginDeclaration + : public lay::PluginDeclaration +{ +public: + virtual void get_menu_entries (std::vector &menu_entries) const + { + std::string at; + + // secret menu entries + at = "@secrets.end"; + menu_entries.push_back (lay::menu_item ("cm_paste_interactive", "paste_interactive:edit", at, tl::to_string (QObject::tr ("Paste Interactive")))); + menu_entries.push_back (lay::menu_item ("cm_duplicate_interactive", "duplicate_interactive:edit", at, tl::to_string (QObject::tr ("Duplicate Interactive")))); + menu_entries.push_back (lay::menu_item ("cm_sel_move_interactive", "sel_move_interactive:edit", at, tl::to_string (QObject::tr ("Move Interactive")))); + + at = "edit_menu.end"; + menu_entries.push_back (lay::separator ("edit_select_individual_group", at)); + + menu_entries.push_back (lay::separator ("basic_group", at)); + menu_entries.push_back (lay::submenu ("layout_menu:edit:edit_mode", at, tl::to_string (QObject::tr ("Layout")))); + { + std::string at = "edit_menu.layout_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_lay_flip_x", "lay_flip_x:edit_mode", at, tl::to_string (QObject::tr ("Flip Horizontally")))); + menu_entries.push_back (lay::menu_item ("cm_lay_flip_y", "lay_flip_y:edit_mode", at, tl::to_string (QObject::tr ("Flip Vertically")))); + menu_entries.push_back (lay::menu_item ("cm_lay_rot_cw", "lay_rot_cw:edit_mode", at, tl::to_string (QObject::tr ("Rotate Clockwise")))); + menu_entries.push_back (lay::menu_item ("cm_lay_rot_ccw", "lay_rot_ccw:edit_mode", at, tl::to_string (QObject::tr ("Rotate Counterclockwise")))); + menu_entries.push_back (lay::menu_item ("cm_lay_free_rot", "lay_free_rot:edit_mode", at, tl::to_string (QObject::tr ("Rotation By Angle")))); + menu_entries.push_back (lay::menu_item ("cm_lay_scale", "lay_scale:edit_mode", at, tl::to_string (QObject::tr ("Scale")))); + menu_entries.push_back (lay::menu_item ("cm_lay_move", "lay_move:edit_mode", at, tl::to_string (QObject::tr ("Move By")))); + menu_entries.push_back (lay::separator ("cellop_group", at)); + menu_entries.push_back (lay::menu_item ("cm_lay_convert_to_static", "lay_convert_to_static:edit_mode", at, tl::to_string (QObject::tr ("Convert All Cells To Static")))); + } + + menu_entries.push_back (lay::submenu ("cell_menu:edit:edit_mode", at, tl::to_string (QObject::tr ("Cell")))); + { + std::string at = "edit_menu.cell_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_new_cell", "new_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("New Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_delete", "delete_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Delete Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_rename", "rename_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Rename Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_replace", "replace_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Replace Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_flatten", "flatten_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Flatten Cell")))); + menu_entries.push_back (lay::separator ("ops_group", at)); + menu_entries.push_back (lay::menu_item ("cm_adjust_origin", "adjust_cell_origin:edit:edit_mode", at, tl::to_string (QObject::tr ("Adjust Origin")))); + menu_entries.push_back (lay::menu_item ("cm_cell_convert_to_static", "convert_cell_to_static:edit_mode", at, tl::to_string (QObject::tr ("Convert Cell To Static")))); + menu_entries.push_back (lay::separator ("props_group", at)); + menu_entries.push_back (lay::menu_item ("cm_cell_user_properties", "user_properties", at, tl::to_string (QObject::tr ("User Properties")))); + } + + menu_entries.push_back (lay::submenu ("layer_menu:edit:edit_mode", at, tl::to_string (QObject::tr ("Layer")))); + { + std::string at = "edit_menu.layer_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_new_layer", "new_layer:edit:edit_mode", at, tl::to_string (QObject::tr ("New Layer")))); + menu_entries.push_back (lay::menu_item ("cm_clear_layer", "clear_layer:edit:edit_mode", at, tl::to_string (QObject::tr ("Clear Layer")))); + menu_entries.push_back (lay::menu_item ("cm_delete_layer", "delete_layer:edit:edit_mode", at, tl::to_string (QObject::tr ("Delete Layer")))); + menu_entries.push_back (lay::menu_item ("cm_copy_layer", "copy_layer:edit:edit_mode", at, tl::to_string (QObject::tr ("Copy Layer")))); + menu_entries.push_back (lay::menu_item ("cm_edit_layer", "edit_layer:edit:edit_mode", at, tl::to_string (QObject::tr ("Edit Layer Specification")))); + } + + menu_entries.push_back (lay::submenu ("selection_menu:edit", at, tl::to_string (QObject::tr ("Selection")))); + { + std::string at = "edit_menu.selection_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_sel_flip_x", "sel_flip_x", at, tl::to_string (QObject::tr ("Flip Horizontally")))); + menu_entries.push_back (lay::menu_item ("cm_sel_flip_y", "sel_flip_y", at, tl::to_string (QObject::tr ("Flip Vertically")))); + menu_entries.push_back (lay::menu_item ("cm_sel_rot_cw", "sel_rot_cw", at, tl::to_string (QObject::tr ("Rotate Clockwise")))); + menu_entries.push_back (lay::menu_item ("cm_sel_rot_ccw", "sel_rot_ccw", at, tl::to_string (QObject::tr ("Rotate Counterclockwise")))); + menu_entries.push_back (lay::menu_item ("cm_sel_free_rot", "sel_free_rot", at, tl::to_string (QObject::tr ("Rotation By Angle")))); + menu_entries.push_back (lay::menu_item ("cm_sel_scale", "sel_scale", at, tl::to_string (QObject::tr ("Scale")))); + menu_entries.push_back (lay::menu_item ("cm_sel_move", "sel_move", at, tl::to_string (QObject::tr ("Move By")))); + menu_entries.push_back (lay::menu_item ("cm_sel_move_to", "sel_move_to", at, tl::to_string (QObject::tr ("Move To")))); + } + + menu_entries.push_back (lay::separator ("edit_select_individual_group", at)); + + menu_entries.push_back (lay::separator ("utils_group", at)); + menu_entries.push_back (lay::submenu ("utils_menu:edit:edit_mode", at, tl::to_string (QObject::tr ("Utilities")))); + + menu_entries.push_back (lay::separator ("edit_select_individual_group", at)); + + menu_entries.push_back (lay::separator ("misc_group", at)); + menu_entries.push_back (lay::menu_item ("cm_delete", "delete:edit", at, tl::to_string (QObject::tr ("Delete(Del)")))); + menu_entries.push_back (lay::menu_item ("cm_show_properties", "show_properties:edit", at, tl::to_string (QObject::tr ("Properties(Q)")))); + menu_entries.push_back (lay::separator ("edit_select_individual_group", at)); + + menu_entries.push_back (lay::separator ("cpc_group", at)); + menu_entries.push_back (lay::menu_item ("cm_copy", "copy:edit", at, tl::to_string (QObject::tr ("Copy(Ctrl+C)")))); + menu_entries.push_back (lay::menu_item ("cm_cut", "cut:edit", at, tl::to_string (QObject::tr ("Cut(Ctrl+X)")))); + menu_entries.push_back (lay::menu_item ("cm_paste", "paste:edit", at, tl::to_string (QObject::tr ("Paste(Ctrl+V)")))); + menu_entries.push_back (lay::menu_item ("cm_duplicate", "duplicate:edit", at, tl::to_string (QObject::tr ("Duplicate(Ctrl+B)")))); + + menu_entries.push_back (lay::separator ("modes_group", at)); + menu_entries.push_back (lay::submenu ("mode_menu", at, tl::to_string (QObject::tr ("Mode")))); + + menu_entries.push_back (lay::submenu ("select_menu", at, tl::to_string (QObject::tr ("Select")))); + { + std::string at = "edit_menu.select_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_select_all", "select_all", at, tl::to_string (QObject::tr ("Select All")))); + menu_entries.push_back (lay::menu_item ("cm_unselect_all", "unselect_all", at, tl::to_string (QObject::tr ("Unselect All")))); + menu_entries.push_back (lay::separator ("edit_select_basic_group", at)); + menu_entries.push_back (lay::menu_item ("enable_all", "enable_all", at, tl::to_string (QObject::tr ("Enable All")))); + menu_entries.push_back (lay::menu_item ("disable_all", "disable_all", at, tl::to_string (QObject::tr ("Disable All")))); + menu_entries.push_back (lay::separator ("edit_select_individual_group", at)); + }; + + menu_entries.push_back (lay::separator ("cancel_group", at)); + menu_entries.push_back (lay::menu_item ("cm_cancel", "cancel", at, tl::to_string (QObject::tr ("Cancel(Esc)")))); + + at = "bookmark_menu.end"; + menu_entries.push_back (lay::submenu ("goto_bookmark_menu", at, tl::to_string (QObject::tr ("Goto Bookmark")))); + menu_entries.push_back (lay::menu_item ("cm_bookmark_view", "bookmark_view", at, tl::to_string (QObject::tr ("Bookmark This View")))); + + menu_entries.push_back (lay::separator ("bookmark_mgm_group", at)); + menu_entries.push_back (lay::menu_item ("cm_manage_bookmarks", "manage_bookmarks", at, tl::to_string (QObject::tr ("Manage Bookmarks")))); + menu_entries.push_back (lay::menu_item ("cm_load_bookmarks", "load_bookmarks", at, tl::to_string (QObject::tr ("Load Bookmarks")))); + menu_entries.push_back (lay::menu_item ("cm_save_bookmarks", "save_bookmarks", at, tl::to_string (QObject::tr ("Save Bookmarks")))); + + at = "zoom_menu.end"; + menu_entries.push_back (lay::submenu ("global_trans", at, tl::to_string (QObject::tr ("Global Transformation")))); + { + std::string at = "zoom_menu.global_trans.end"; + menu_entries.push_back (lay::config_menu_item ("r0", at, tl::to_string (QObject::tr ("\\(r0\\)<:/r0.png>")), cfg_global_trans, "?r0 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("r90", at, tl::to_string (QObject::tr ("\\(r90\\)<:/r90.png>")), cfg_global_trans, "?r90 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("r180", at, tl::to_string (QObject::tr ("\\(r180\\)<:/r180.png>")), cfg_global_trans, "?r180 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("r270", at, tl::to_string (QObject::tr ("\\(r270\\)<:/r270.png>")), cfg_global_trans, "?r270 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("m0", at, tl::to_string (QObject::tr ("\\(m0\\)<:/m0.png>")), cfg_global_trans, "?m0 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("m45", at, tl::to_string (QObject::tr ("\\(m45\\)<:/m45.png>")), cfg_global_trans, "?m45 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("m90", at, tl::to_string (QObject::tr ("\\(m90\\)<:/m90.png>")), cfg_global_trans, "?m90 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("m135", at, tl::to_string (QObject::tr ("\\(m135\\)<:/m135.png>")), cfg_global_trans, "?m135 *1 0,0")); + } + + menu_entries.push_back (lay::separator ("hier_group", at)); + menu_entries.push_back (lay::menu_item ("cm_max_hier", "max_hier", at, tl::to_string (QObject::tr ("Full Hierarchy(*)")))); + menu_entries.push_back (lay::menu_item ("cm_max_hier_0", "max_hier_0", at, tl::to_string (QObject::tr ("Box Only(0)")))); + menu_entries.push_back (lay::menu_item ("cm_max_hier_1", "max_hier_1", at, tl::to_string (QObject::tr ("Top Level Only(1)")))); + menu_entries.push_back (lay::menu_item ("cm_inc_max_hier", "inc_max_hier", at, tl::to_string (QObject::tr ("Increment Hierarchy(+)")))); + menu_entries.push_back (lay::menu_item ("cm_dec_max_hier", "dec_max_hier", at, tl::to_string (QObject::tr ("Decrement Hierarchy(-)")))); + + menu_entries.push_back (lay::separator ("zoom_group", at)); + menu_entries.push_back (lay::menu_item ("cm_zoom_fit", "zoom_fit", at, tl::to_string (QObject::tr ("Zoom Fit(F2)")))); + menu_entries.push_back (lay::menu_item ("cm_zoom_fit_sel", "zoom_fit_sel", at, tl::to_string (QObject::tr ("Zoom Fit Selection(Shift+F2)")))); + menu_entries.push_back (lay::menu_item ("cm_zoom_in", "zoom_in", at, tl::to_string (QObject::tr ("Zoom In(Return)")))); + menu_entries.push_back (lay::menu_item ("cm_zoom_out", "zoom_out", at, tl::to_string (QObject::tr ("Zoom Out(Shift+Return)")))); + /* disabled because that interferes with the use of the arrow keys for moving the selection + MenuLayoutEntry::separator ("pan_group"); + menu_entries.push_back (lay::menu_item ("cm_pan_up", "pan_up", at, tl::to_string (QObject::tr ("Pan Up(Up)")))); + menu_entries.push_back (lay::menu_item ("cm_pan_down", "pan_down", at, tl::to_string (QObject::tr ("Pan Down(Down)")))); + menu_entries.push_back (lay::menu_item ("cm_pan_left", "pan_left", at, tl::to_string (QObject::tr ("Pan Left(Left)")))); + menu_entries.push_back (lay::menu_item ("cm_pan_right", "pan_right", at, tl::to_string (QObject::tr ("Pan Right(Right)")))); + */ + + menu_entries.push_back (lay::separator ("redraw_group", at)); + menu_entries.push_back (lay::menu_item ("cm_redraw", "redraw", at, tl::to_string (QObject::tr ("Redraw")))); + menu_entries.push_back (lay::separator ("state_group", at)); + menu_entries.push_back (lay::menu_item ("cm_prev_display_state", "prev_display_state", at, tl::to_string (QObject::tr ("Back(Shift+Tab)<:/back.png>")))); + menu_entries.push_back (lay::menu_item ("cm_next_display_state", "next_display_state", at, tl::to_string (QObject::tr ("Forward(Tab)<:/forward.png>")))); + + menu_entries.push_back (lay::separator ("select_group", at)); + menu_entries.push_back (lay::menu_item ("cm_select_cell", "select_cell:edit", at, tl::to_string (QObject::tr ("Select Cell")))); + menu_entries.push_back (lay::menu_item ("cm_select_current_cell", "select_current_cell", at, tl::to_string (QObject::tr ("Show As New Top(Ctrl+S)")))); + menu_entries.push_back (lay::menu_item ("cm_goto_position", "goto_position", at, tl::to_string (QObject::tr ("Goto Position(Ctrl+G)")))); + + // Add a hook for inserting new items after the modes + menu_entries.push_back (lay::separator ("end_modes", "@toolbar.end")); + + } + + void implements_primary_mouse_modes (std::vector > > &modes) + { + std::vector mode_titles; + lay::LayoutView::intrinsic_mouse_modes (&mode_titles); + + int mode_id = 0; + for (std::vector ::const_iterator t = mode_titles.begin (); t != mode_titles.end (); ++t, --mode_id) { + // modes: pair(title, pair(insert_pos, id)) + modes.push_back (std::make_pair (*t, std::make_pair ("edit_menu.mode_menu.end;@toolbar.end_modes", mode_id))); + } + } +}; + +static tl::RegisteredClass config_decl (new LayoutViewPluginDeclaration (), -10, "LayoutViewPlugin"); + +} // namespace lay diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index f3fa53245..c8e03cc56 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -38,8 +38,8 @@ #include "layLayerProperties.h" #include "layAbstractMenu.h" -#include "layAbstractMenuProvider.h" #include "layAnnotationShapes.h" +#include "layDispatcher.h" #include "layLayoutCanvas.h" #include "layColorPalette.h" #include "layStipplePalette.h" @@ -81,7 +81,6 @@ class SelectionService; class MoveService; class Browser; class ColorButton; -class PluginRoot; class ConfigureAction; /** @@ -159,8 +158,7 @@ struct LAYBASIC_PUBLIC LayerDisplayProperties class LAYBASIC_PUBLIC LayoutView : public QFrame, public lay::Editables, - public lay::Plugin, - public lay::AbstractMenuProvider + public lay::Dispatcher { Q_OBJECT @@ -198,7 +196,7 @@ public: /** * @brief Constructor (clone from another view) */ - LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::PluginRoot *root, QWidget *parent = 0, const char *name = "view", unsigned int options = (unsigned int) LV_Normal); + LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, QWidget *parent = 0, const char *name = "view", unsigned int options = (unsigned int) LV_Normal); /** * @brief Destructor @@ -1667,11 +1665,6 @@ public: */ static unsigned int intrinsic_mouse_modes (std::vector *descriptions); - /** - * @brief Perform the layout view's initialisations on the main menu - */ - static void init_menu (lay::AbstractMenu &menu); - /** * @brief Updates the menu for the given view * If the view is 0, the menu shall be updated to reflect "no view active" @@ -2018,7 +2011,7 @@ public: * PD is the type of the declaration. */ template - void create_plugin (lay::PluginRoot *root) + void create_plugin () { for (std::vector::const_iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { if (dynamic_cast ((*p)->plugin_declaration ()) != 0) { @@ -2027,7 +2020,7 @@ public: } for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { if (dynamic_cast (&*cls) != 0) { - create_plugin (root, &*cls); + create_plugin (&*cls); break; } } @@ -2516,7 +2509,7 @@ public: * * If plugins already exist, they are deleted and created again */ - void create_plugins (lay::PluginRoot *root, const lay::PluginDeclaration *except_this = 0); + void create_plugins (const lay::PluginDeclaration *except_this = 0); public slots: /** @@ -2678,6 +2671,7 @@ public slots: void layer_order_changed (); void timer (); void menu_activated (const std::string &symbol); + static std::vector menu_symbols (); void deactivate_all_browsers (); void min_hier_changed (int i); void max_hier_changed (int i); @@ -2762,12 +2756,6 @@ protected: void activate (); private: - lay::AbstractMenu m_menu; - std::auto_ptr mp_plugin_root; - std::map m_actions_for_slot; - std::map > m_configuration_actions; - tl::shared_collection m_ca_collection; - bool m_editable; int m_disabled_edits; unsigned int m_options; @@ -2904,7 +2892,7 @@ private: bool m_active_cellview_changed_event_enabled; tl::DeferredMethod dm_prop_changed; - void init (db::Manager *mgr, lay::PluginRoot *root, QWidget *parent); + void init (db::Manager *mgr, lay::Dispatcher *dispatcher, QWidget *parent); void do_prop_changed (); void do_redraw (int layer); @@ -2937,6 +2925,11 @@ private: void init_layer_properties (LayerProperties &props, const LayerPropertiesList &lp_list) const; void merge_dither_pattern (lay::LayerPropertiesList &props); + void do_cm_duplicate (bool interactive); + void do_cm_paste (bool interactive); + void cm_new_cell (); + void cm_reload (); + // overrides Editables method to display a message void signal_selection_changed (); @@ -2944,18 +2937,13 @@ private: void showEvent (QShowEvent *); void hideEvent (QHideEvent *); - lay::Plugin *create_plugin (lay::PluginRoot *root, const lay::PluginDeclaration *cls); + lay::Plugin *create_plugin (const lay::PluginDeclaration *cls); std::list::iterator cellview_iter (int cv_index); std::list::const_iterator cellview_iter (int cv_index) const; - // implementation of AbstractMenuProvider + // implementation of Dispatcher virtual QWidget *menu_parent_widget (); - virtual lay::Action &action_for_slot (const char *slot); - virtual lay::Action *create_config_action (const std::string &title, const std::string &cname, const std::string &cvalue); - virtual lay::Action *create_config_action (const std::string &cname, const std::string &cvalue); - virtual void register_config_action (const std::string &name, lay::ConfigureAction *action); - virtual void unregister_config_action (const std::string &name, lay::ConfigureAction *action); }; } diff --git a/src/laybasic/laybasic/layLayoutViewConfigPages.h b/src/laybasic/laybasic/layLayoutViewConfigPages.h index 71b2e254f..10ffb7a23 100644 --- a/src/laybasic/laybasic/layLayoutViewConfigPages.h +++ b/src/laybasic/laybasic/layLayoutViewConfigPages.h @@ -67,8 +67,8 @@ public: LayoutViewConfigPage (QWidget *parent); ~LayoutViewConfigPage (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::LayoutViewConfigPage *mp_ui; @@ -83,8 +83,8 @@ public: LayoutViewConfigPage1 (QWidget *parent); ~LayoutViewConfigPage1 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::LayoutViewConfigPage1 *mp_ui; @@ -99,8 +99,8 @@ public: LayoutViewConfigPage2a (QWidget *parent); ~LayoutViewConfigPage2a (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::LayoutViewConfigPage2a *mp_ui; @@ -115,8 +115,8 @@ public: LayoutViewConfigPage2b (QWidget *parent); ~LayoutViewConfigPage2b (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::LayoutViewConfigPage2b *mp_ui; @@ -131,8 +131,8 @@ public: LayoutViewConfigPage2c (QWidget *parent); ~LayoutViewConfigPage2c (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::LayoutViewConfigPage2c *mp_ui; @@ -147,8 +147,8 @@ public: LayoutViewConfigPage3a (QWidget *parent); ~LayoutViewConfigPage3a (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::LayoutViewConfigPage3a *mp_ui; @@ -163,8 +163,8 @@ public: LayoutViewConfigPage3b (QWidget *parent); ~LayoutViewConfigPage3b (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::LayoutViewConfigPage3b *mp_ui; @@ -179,8 +179,8 @@ public: LayoutViewConfigPage3c (QWidget *parent); ~LayoutViewConfigPage3c (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::LayoutViewConfigPage3c *mp_ui; @@ -195,8 +195,8 @@ public: LayoutViewConfigPage3f (QWidget *parent); ~LayoutViewConfigPage3f (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::LayoutViewConfigPage3f *mp_ui; @@ -212,8 +212,8 @@ public: LayoutViewConfigPage4 (QWidget *parent); ~LayoutViewConfigPage4 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); virtual void undo (db::Op *op); virtual void redo (db::Op *op); @@ -244,8 +244,8 @@ public: LayoutViewConfigPage5 (QWidget *parent); ~LayoutViewConfigPage5 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); public slots: void browse_clicked (); @@ -264,8 +264,8 @@ public: LayoutViewConfigPage6 (QWidget *parent); ~LayoutViewConfigPage6 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); virtual void undo (db::Op *op); virtual void redo (db::Op *op); @@ -298,8 +298,8 @@ public: LayoutViewConfigPage6a (QWidget *parent); ~LayoutViewConfigPage6a (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); virtual void undo (db::Op *op); virtual void redo (db::Op *op); @@ -329,8 +329,8 @@ public: LayoutViewConfigPage7 (QWidget *parent); ~LayoutViewConfigPage7 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::LayoutViewConfigPage7 *mp_ui; diff --git a/src/laybasic/laybasic/layLibrariesView.cc b/src/laybasic/laybasic/layLibrariesView.cc index ad8d84346..4ae658748 100644 --- a/src/laybasic/laybasic/layLibrariesView.cc +++ b/src/laybasic/laybasic/layLibrariesView.cc @@ -196,25 +196,6 @@ LibraryTreeWidget::mouseReleaseEvent (QMouseEvent *event) const int max_cellviews_in_split_mode = 5; -void -LibrariesView::init_menu (lay::AbstractMenu &menu) -{ - MenuLayoutEntry context_menu [] = { -#if 0 - // doesn't make sense for many libs - MenuLayoutEntry ("split_mode", tl::to_string (QObject::tr ("Split Mode")), std::make_pair (cfg_split_lib_views, "?")), -#endif - MenuLayoutEntry::last () - }; - - MenuLayoutEntry main_menu [] = { - MenuLayoutEntry ("@lib_context_menu", "", context_menu), - MenuLayoutEntry::last () - }; - - menu.init (main_menu); -} - LibrariesView::LibrariesView (lay::LayoutView *view, QWidget *parent, const char *name) : QFrame (parent), m_enable_cb (true), @@ -821,4 +802,28 @@ LibrariesView::has_focus () const return m_active_index >= 0 && m_active_index < int (mp_cell_lists.size ()) && mp_cell_lists [m_active_index]->hasFocus (); } +// ------------------------------------------------------------ +// Declaration of the "plugin" for the menu entries + +class LibraryViewPluginDeclaration + : public lay::PluginDeclaration +{ +public: + virtual void get_menu_entries (std::vector &menu_entries) const + { + std::string at; + + at = ".end"; + menu_entries.push_back (lay::submenu ("@lib_context_menu", at, std::string ())); + + at = "@lib_context_menu.end"; +#if 0 + // doesn't make sense for many libs + menu_entries.push_back (lay::config_menu_item ("split_mode", at, tl::to_string (QObject::tr ("Split Mode")), cfg_split_lib_views, "?")), +#endif + } +}; + +static tl::RegisteredClass config_decl (new LibraryViewPluginDeclaration (), -7, "LibraryViewPlugin"); + } // namespace lay diff --git a/src/laybasic/laybasic/layLibrariesView.h b/src/laybasic/laybasic/layLibrariesView.h index e1674e83f..841e90a75 100644 --- a/src/laybasic/laybasic/layLibrariesView.h +++ b/src/laybasic/laybasic/layLibrariesView.h @@ -114,11 +114,6 @@ public: */ ~LibrariesView (); - /** - * @brief Perform the cell control panel's initialisations on the main menu - */ - static void init_menu (lay::AbstractMenu &menu); - /** * @brief The sizeHint implementation for Qt layout management */ diff --git a/src/laybasic/laybasic/layLoadLayoutOptionsDialog.h b/src/laybasic/laybasic/layLoadLayoutOptionsDialog.h index e36ac27db..e0183ffbb 100644 --- a/src/laybasic/laybasic/layLoadLayoutOptionsDialog.h +++ b/src/laybasic/laybasic/layLoadLayoutOptionsDialog.h @@ -52,7 +52,7 @@ namespace lay { class LayoutView; -class PluginRoot; +class Dispatcher; class FileDialog; class LAYBASIC_PUBLIC LoadLayoutOptionsDialog @@ -64,7 +64,7 @@ public: LoadLayoutOptionsDialog (QWidget *parent, const std::string &title); ~LoadLayoutOptionsDialog (); - bool edit_global_options (lay::PluginRoot *config_root, db::Technologies *technologies); + bool edit_global_options (lay::Dispatcher *dispatcher, db::Technologies *technologies); bool get_options (db::LoadLayoutOptions &options); void show_always (bool sa) diff --git a/src/laybasic/laybasic/layNetlistBrowser.h b/src/laybasic/laybasic/layNetlistBrowser.h index 46324ed75..78a8adc2a 100644 --- a/src/laybasic/laybasic/layNetlistBrowser.h +++ b/src/laybasic/laybasic/layNetlistBrowser.h @@ -50,8 +50,8 @@ class NetlistBrowserConfigPage public: NetlistBrowserConfigPage (QWidget *parent); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); public slots: void window_changed (int); @@ -66,8 +66,8 @@ class NetlistBrowserConfigPage2 public: NetlistBrowserConfigPage2 (QWidget *parent); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); public slots: void color_button_clicked (); diff --git a/src/laybasic/laybasic/layPlugin.cc b/src/laybasic/laybasic/layPlugin.cc index 0743f2504..7cea2ab8b 100644 --- a/src/laybasic/laybasic/layPlugin.cc +++ b/src/laybasic/laybasic/layPlugin.cc @@ -21,7 +21,6 @@ */ -#include "layAbstractMenuProvider.h" #include "laybasicCommon.h" #include "tlException.h" @@ -30,6 +29,7 @@ #include "tlLog.h" #include "layPlugin.h" +#include "layDispatcher.h" #include "tlExceptions.h" #include "tlClassRegistry.h" @@ -56,8 +56,10 @@ PluginDeclaration::PluginDeclaration () PluginDeclaration::~PluginDeclaration () { - if (PluginRoot::instance ()) { - PluginRoot::instance ()->plugin_removed (this); + clear_menu_items (); + + if (Dispatcher::instance ()) { + Dispatcher::instance ()->plugin_removed (this); } } @@ -69,6 +71,30 @@ PluginDeclaration::toggle_editable_enabled () END_PROTECTED } +std::vector +PluginDeclaration::menu_symbols () +{ + std::vector symbols; + + for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { + + std::vector menu_entries; + cls->get_menu_entries (menu_entries); + + for (std::vector::const_iterator m = menu_entries.begin (); m != menu_entries.end (); ++m) { + if (! m->symbol.empty ()) { + symbols.push_back (m->symbol); + } + } + + } + + std::sort (symbols.begin (), symbols.end ()); + symbols.erase (std::unique (symbols.begin (), symbols.end ()), symbols.end ()); + + return symbols; +} + void PluginDeclaration::generic_menu () { @@ -85,7 +111,7 @@ PluginDeclaration::generic_menu () } // Forward the request to the plugin root which will propagate it down to the plugins - lay::PluginRoot::instance ()->menu_activated (symbol); + lay::Dispatcher::instance ()->menu_activated (symbol); END_PROTECTED } @@ -100,8 +126,8 @@ PluginDeclaration::mode_triggered () int mode = action->data ().toInt (); - if (lay::PluginRoot::instance ()) { - lay::PluginRoot::instance ()->select_mode (mode); + if (lay::Dispatcher::instance ()) { + lay::Dispatcher::instance ()->select_mode (mode); } action->setChecked (true); @@ -111,19 +137,24 @@ PluginDeclaration::mode_triggered () END_PROTECTED } -void -PluginDeclaration::init_menu () +void +PluginDeclaration::clear_menu_items () { - if (! lay::AbstractMenuProvider::instance () || ! lay::AbstractMenuProvider::instance ()->menu ()) { - return; + while (! m_menu_actions.empty ()) { + delete m_menu_actions.back (); + m_menu_actions.pop_back (); } +} - lay::AbstractMenu &menu = *lay::AbstractMenuProvider::instance ()->menu (); +void +PluginDeclaration::init_menu (lay::Dispatcher *dispatcher) +{ + lay::AbstractMenu &menu = *dispatcher->menu (); // pre-initialize to allow multiple init_menu calls m_editable_mode_action = lay::Action (); m_mouse_mode_action = lay::Action (); - m_menu_actions.clear (); + clear_menu_items (); std::string title; @@ -158,19 +189,41 @@ PluginDeclaration::init_menu () for (std::vector::const_iterator m = menu_entries.begin (); m != menu_entries.end (); ++m) { if (m->title.empty ()) { + menu.insert_separator (m->insert_pos, m->menu_name); + } else { if (m->sub_menu) { + menu.insert_menu (m->insert_pos, m->menu_name, m->title); + } else { - Action action (m->title); - action.qaction ()->setData (QVariant (tl::to_qstring (m->symbol))); - gtf::action_connect (action.qaction (), SIGNAL (triggered ()), this, SLOT (generic_menu ())); - menu.insert_item (m->insert_pos, m->menu_name, action); + Action *action = 0; + + if (! m->cname.empty ()) { + + action = dispatcher->create_config_action (m->title, m->cname, m->cvalue); + + } else { + + action = new Action (m->title); + action->qaction ()->setData (QVariant (tl::to_qstring (m->symbol))); + gtf::action_connect (action->qaction (), SIGNAL (triggered ()), this, SLOT (generic_menu ())); + + } m_menu_actions.push_back (action); + menu.insert_item (m->insert_pos, m->menu_name, *action); + + if (! m->exclusive_group.empty ()) { + action->add_to_exclusive_group (&menu, m->exclusive_group); + } + + if (m->checkable) { + action->set_checkable (true); + } } @@ -178,13 +231,29 @@ PluginDeclaration::init_menu () } - // Fill the mode menu file items from the mouse modes + // Fill the mode menu file items from the mouse modes + + std::vector > > modes; title = std::string (); if (implements_mouse_mode (title)) { + modes.push_back (std::make_pair (title, std::make_pair ("edit_menu.mode_menu.end;@toolbar.end", id ()))); + } + + // the primary mouse modes (special for LayoutView) + implements_primary_mouse_modes (modes); + + for (std::vector >::const_iterator m = modes.begin (); m != modes.end (); ++m) { // extract first part, which is the name, separated by a tab from the title. - std::string name = tl::sprintf ("mode_%d", id ()); + std::string name; + if (m->second.second <= 0) { + name = tl::sprintf ("mode_i%d", 1 - m->second.second); + } else { + name = tl::sprintf ("mode_%d", m->second.second); + } + std::string title = m->first; + const char *tab = strchr (title.c_str (), '\t'); if (tab) { name = std::string (title, 0, tab - title.c_str ()); @@ -193,12 +262,10 @@ PluginDeclaration::init_menu () m_mouse_mode_action = Action (title); m_mouse_mode_action.add_to_exclusive_group (&menu, "mouse_mode_exclusive_group"); - m_mouse_mode_action.set_checkable (true); - m_mouse_mode_action.qaction ()->setData (QVariant (id ())); + m_mouse_mode_action.qaction ()->setData (QVariant (m->second.second)); - menu.insert_item ("edit_menu.mode_menu.end", name, m_mouse_mode_action); - menu.insert_item ("@toolbar.end_modes", name, m_mouse_mode_action); + menu.insert_item (m->second.first, name + ":mode_group", m_mouse_mode_action); gtf::action_connect (m_mouse_mode_action.qaction (), SIGNAL (triggered ()), this, SLOT (mode_triggered ())); @@ -208,15 +275,15 @@ PluginDeclaration::init_menu () void PluginDeclaration::remove_menu_items () { - if (! lay::AbstractMenuProvider::instance () || ! lay::AbstractMenuProvider::instance ()->menu ()) { + if (! lay::Dispatcher::instance () || ! lay::Dispatcher::instance ()->menu ()) { return; } - lay::AbstractMenu *menu = lay::AbstractMenuProvider::instance ()->menu (); + lay::AbstractMenu *menu = lay::Dispatcher::instance ()->menu (); menu->delete_items (m_editable_mode_action); menu->delete_items (m_mouse_mode_action); - for (std::vector ::const_iterator a = m_menu_actions.begin (); a != m_menu_actions.end (); ++a) { - menu->delete_items (*a); + for (std::vector ::const_iterator a = m_menu_actions.begin (); a != m_menu_actions.end (); ++a) { + menu->delete_items (**a); } } @@ -233,9 +300,9 @@ PluginDeclaration::set_editable_enabled (bool f) void PluginDeclaration::register_plugin () { - if (PluginRoot::instance ()) { - PluginRoot::instance ()->plugin_registered (this); - initialize (PluginRoot::instance ()); + if (Dispatcher::instance ()) { + Dispatcher::instance ()->plugin_registered (this); + initialize (Dispatcher::instance ()); } } @@ -365,26 +432,26 @@ Plugin::get_config_names (std::vector &names) const } } -PluginRoot * -Plugin::plugin_root () +Dispatcher * +Plugin::dispatcher () { Plugin *p = this; while (p->mp_parent) { p = p->mp_parent; } - return dynamic_cast (p); + return dynamic_cast (p); } -PluginRoot * -Plugin::plugin_root_maybe_null () +Dispatcher * +Plugin::dispatcher_maybe_null () { Plugin *p = this; while (p->mp_parent) { p = p->mp_parent; } - return dynamic_cast (p); + return dynamic_cast (p); } void @@ -434,190 +501,4 @@ Plugin::do_config_set (const std::string &name, const std::string &value, bool f return false; } -// ---------------------------------------------------------------- -// PluginRoot implementation - -static PluginRoot *ms_root_instance = 0; - -PluginRoot::PluginRoot (bool standalone, bool reg_inst) - : Plugin (0, standalone) -{ - if (reg_inst) { - ms_root_instance = this; - } -} - -PluginRoot::~PluginRoot () -{ - if (ms_root_instance == this) { - ms_root_instance = 0; - } -} - -// Writing and Reading of configuration - -struct ConfigGetAdaptor -{ - ConfigGetAdaptor (const std::string &name) - : mp_owner (0), m_done (false), m_name (name) - { - // .. nothing yet .. - } - - std::string operator () () const - { - std::string s; - mp_owner->config_get (m_name, s); - return s; - } - - bool at_end () const - { - return m_done; - } - - void start (const lay::PluginRoot &owner) - { - mp_owner = &owner; - m_done = false; - } - - void next () - { - m_done = true; - } - -private: - const lay::PluginRoot *mp_owner; - bool m_done; - std::string m_name; -}; - -struct ConfigGetNullAdaptor -{ - ConfigGetNullAdaptor () - { - // .. nothing yet .. - } - - std::string operator () () const - { - return std::string (); - } - - bool at_end () const - { - return true; - } - - void start (const lay::PluginRoot & /*owner*/) { } - void next () { } -}; - -struct ConfigNamedSetAdaptor -{ - ConfigNamedSetAdaptor () - { - // .. nothing yet .. - } - - void operator () (lay::PluginRoot &w, tl::XMLReaderState &reader, const std::string &name) const - { - tl::XMLObjTag tag; - w.config_set (name, *reader.back (tag)); - } -}; - -struct ConfigSetAdaptor -{ - ConfigSetAdaptor (const std::string &name) - : m_name (name) - { - // .. nothing yet .. - } - - void operator () (lay::PluginRoot &w, tl::XMLReaderState &reader) const - { - tl::XMLObjTag tag; - w.config_set (m_name, *reader.back (tag)); - } - -private: - std::string m_name; -}; - -// the configuration file's XML structure is built dynamically -static tl::XMLStruct -config_structure (const lay::PluginRoot *plugin) -{ - tl::XMLElementList body; - std::string n_with_underscores; - - std::vector names; - plugin->get_config_names (names); - - for (std::vector ::const_iterator n = names.begin (); n != names.end (); ++n) { - - body.append (tl::XMLMember > ( - ConfigGetAdaptor (*n), ConfigSetAdaptor (*n), *n)); - - // for compatibility, provide an alternative with underscores (i.e. 0.20->0.21 because of default_grids) - n_with_underscores.clear (); - for (const char *c = n->c_str (); *c; ++c) { - n_with_underscores += (*c == '-' ? '_' : *c); - } - - body.append (tl::XMLMember > ( - ConfigGetNullAdaptor (), ConfigSetAdaptor (*n), n_with_underscores)); - - } - - // add a wildcard member to read all others unspecifically into the repository - body.append (tl::XMLWildcardMember > (ConfigNamedSetAdaptor ())); - - return tl::XMLStruct ("config", body); -} - - -bool -PluginRoot::write_config (const std::string &config_file) -{ - try { - tl::OutputStream os (config_file, tl::OutputStream::OM_Plain); - config_structure (this).write (os, *this); - return true; - } catch (...) { - return false; - } -} - -bool -PluginRoot::read_config (const std::string &config_file) -{ - std::auto_ptr file; - - try { - file.reset (new tl::XMLFileSource (config_file)); - } catch (...) { - return false; - } - - try { - config_structure (this).parse (*file, *this); - } catch (tl::Exception &ex) { - std::string msg = tl::to_string (QObject::tr ("Problem reading config file ")) + config_file + ": " + ex.msg (); - throw tl::Exception (msg); - } - - config_end (); - - return true; -} - -PluginRoot * -PluginRoot::instance () -{ - return ms_root_instance; -} - } diff --git a/src/laybasic/laybasic/layPlugin.h b/src/laybasic/laybasic/layPlugin.h index 4922da7b7..0395433b6 100644 --- a/src/laybasic/laybasic/layPlugin.h +++ b/src/laybasic/laybasic/layPlugin.h @@ -47,7 +47,7 @@ namespace lay { class Plugin; -class PluginRoot; +class Dispatcher; class LayoutView; class Browser; class ViewService; @@ -77,7 +77,7 @@ public: * The implementation is supposed to fetch the configuration from the * Plugin object provided and load the widgets accordingly. */ - virtual void setup (PluginRoot * /*root*/) + virtual void setup (Dispatcher * /*root*/) { // the default implementation does nothing. } @@ -89,7 +89,7 @@ public: * throw exceptions if the configuration something is invalid) * and commit the changes through */ - virtual void commit (PluginRoot * /*root*/) + virtual void commit (Dispatcher * /*root*/) { // the default implementation does nothing. } @@ -98,42 +98,111 @@ public: /** * @brief A menu entry declaration + * See separator, menu_item, submenu and config_menu_item below. */ struct LAYBASIC_PUBLIC MenuEntry { - /** - * @brief A declaration for a separator - * - * @param menu_name The name of the menu item (see layAbstractMenu.h) - * @param insert_pos The position where to insert (see layAbstractMenu.h) - */ - MenuEntry (const std::string &menu_name_, const std::string &insert_pos_) - : menu_name (menu_name_), insert_pos (insert_pos_), sub_menu (false) - { - // .. - } - - /** - * @brief A declaration for a menu entry - * - * @param symbol The symbol to send when this menu item is selected - * @param menu_name The name of the menu item (see layAbstractMenu.h) - * @param insert_pos The position where to insert (see layAbstractMenu.h) - * @param title The title to display plus optional icon resource and keyboard shortcut. The format of the string is: ["("shortcut")"]["<"icon-resource">"][{"tool-tip"}]. - */ - MenuEntry (const std::string &symbol_, const std::string &menu_name_, const std::string &insert_pos_, const std::string &title_, bool sub_menu_ = false) - : menu_name (menu_name_), symbol (symbol_), insert_pos (insert_pos_), title (title_), sub_menu (sub_menu_) - { - // .. - } + MenuEntry () : sub_menu (false), checkable (false) { } std::string menu_name; std::string symbol; std::string insert_pos; std::string title; + std::string cname; + std::string cvalue; + std::string exclusive_group; bool sub_menu; + bool checkable; }; +/** + * @brief Creates a separator menu entry + * + * @param menu_name The name of the menu item (see layAbstractMenu.h) + * @param insert_pos The position where to insert (see layAbstractMenu.h) + */ +MenuEntry separator (const std::string &menu_name, const std::string &insert_pos) +{ + MenuEntry e; + e.menu_name = menu_name; + e.insert_pos = insert_pos; + return e; +} + +/** + * @brief Creates a normal menu entry + * + * @param symbol The symbol to send when this menu item is selected + * @param menu_name The name of the menu item (see layAbstractMenu.h) + * @param insert_pos The position where to insert (see layAbstractMenu.h) + * @param title The title to display plus optional icon resource and keyboard shortcut. The format of the string is: ["("shortcut")"]["<"icon-resource">"][{"tool-tip"}]. + */ +MenuEntry menu_item (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &title) +{ + MenuEntry e; + e.symbol = symbol; + e.menu_name = menu_name; + e.insert_pos = insert_pos; + e.title = title; + return e; +} + +/** + * @brief Creates a submenu entry + * + * @param menu_name The name of the menu item (see layAbstractMenu.h) + * @param insert_pos The position where to insert (see layAbstractMenu.h) + * @param title The title to display plus optional icon resource and keyboard shortcut. The format of the string is: ["("shortcut")"]["<"icon-resource">"][{"tool-tip"}]. + */ +MenuEntry submenu (const std::string &menu_name, const std::string &insert_pos, const std::string &title) +{ + MenuEntry e; + e.menu_name = menu_name; + e.insert_pos = insert_pos; + e.title = title; + e.sub_menu = true; + return e; +} + +/** + * @brief Creates a submenu entry + * + * @param symbol The symbol to send when this menu item is selected + * @param menu_name The name of the menu item (see layAbstractMenu.h) + * @param insert_pos The position where to insert (see layAbstractMenu.h) + * @param title The title to display plus optional icon resource and keyboard shortcut. The format of the string is: ["("shortcut")"]["<"icon-resource">"][{"tool-tip"}]. + */ +MenuEntry submenu (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &title) +{ + MenuEntry e; + e.symbol = symbol; + e.menu_name = menu_name; + e.insert_pos = insert_pos; + e.title = title; + e.sub_menu = true; + return e; +} + +/** + * @brief Creates a configuration entry + * + * @param menu_name The name of the menu item (see layAbstractMenu.h) + * @param insert_pos The position where to insert (see layAbstractMenu.h) + * @param title The title to display plus optional icon resource and keyboard shortcut. The format of the string is: ["("shortcut")"]["<"icon-resource">"][{"tool-tip"}]. + * @param cname The name of the configuration item + * @param cvalue The value to set for the configuration item (optional for boolean configuration items) + */ +MenuEntry config_menu_item (const std::string &menu_name, const std::string &insert_pos, const std::string &title, const std::string &cname, const std::string &cvalue = std::string ()) +{ + MenuEntry e; + e.menu_name = menu_name; + e.insert_pos = insert_pos; + e.title = title; + e.cname = cname; + e.cvalue = cvalue; + return e; +} + /** * @brief The configuration declaration * @@ -238,7 +307,7 @@ public: * Reimplementation of this method offers a chance to initialize static resources such as * dialogs etc. */ - virtual void initialize (lay::PluginRoot * /*root*/) + virtual void initialize (lay::Dispatcher * /*dispatcher*/) { // .. the default implementation does nothing .. } @@ -251,7 +320,7 @@ public: * While initialize is called before any configuration is loaded, "initialized" will be * called after the pugin system has been initially configured. */ - virtual void initialized (lay::PluginRoot * /*root*/) + virtual void initialized (lay::Dispatcher * /*dispatcher*/) { // .. the default implementation does nothing .. } @@ -259,7 +328,7 @@ public: /** * @brief Uninitialize the plugin */ - virtual void uninitialize (lay::PluginRoot * /*root*/) + virtual void uninitialize (lay::Dispatcher * /*dispatcher*/) { // .. the default implementation does nothing .. } @@ -270,7 +339,7 @@ public: * If the plugin wants to prevent the application from closing, it may return false * in this method. */ - virtual bool can_exit (lay::PluginRoot * /*root*/) const + virtual bool can_exit (lay::Dispatcher * /*dispatcher*/) const { return true; } @@ -292,7 +361,7 @@ public: * This method may return 0 for "dummy" plugins that just register menu entries * or configuration options. */ - virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::PluginRoot * /*plugin_root*/, lay::LayoutView * /*view*/) const + virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher * /*dispatcher*/, lay::LayoutView * /*view*/) const { return 0; } @@ -322,6 +391,17 @@ public: { return false; } + + /** + * @brief Specifies the primary mouse modes + * + * These are built-in modes from the LayoutView. This method is intended for + * the LayoutView's standard modes only. + */ + virtual void implements_primary_mouse_modes (std::vector > > & /*modes*/) + { + // .. nothing yet .. + } /** * @brief Returns the technology component provider @@ -354,9 +434,17 @@ public: * @brief Creates the menu resources for this plugin * * This method will create the menu resources for the plugin and perform the - * required connect operations. + * required connect operations. The dispatcher provides the menu and the + * event endpoints. */ - void init_menu (); + void init_menu (lay::Dispatcher *dispatcher); + + /** + * @brief Gets the available menu symbols from all plugins + * + * This does not mean all symbols will be available. + */ + static std::vector menu_symbols (); /** * @brief Removes the menu resources associated with this plugin @@ -397,7 +485,7 @@ public: } /** - * @brief Notifies that plugin root that a new plugin was registered + * @brief Notifies that dispatcher that a new plugin was registered * * This method must be called when a plugin is dynamically created. It is important * that when this method is called, the menu items and other properties are set already. @@ -416,10 +504,12 @@ private slots: private: int m_id; - std::vector m_menu_actions; + std::vector m_menu_actions; lay::Action m_editable_mode_action; lay::Action m_mouse_mode_action; bool m_editable_enabled; + + void clear_menu_items (); }; /** @@ -634,17 +724,17 @@ public: void get_config_names (std::vector &names) const; /** - * @brief Gets the plugin root (the parent plugin not having another parent) + * @brief Gets the dispatcher (the top level end of the plugin chain) * The returned pointer is guaranteed to be non-zero. */ - PluginRoot *plugin_root (); + Dispatcher *dispatcher (); /** - * @brief Gets the plugin root (the parent plugin not having another parent) + * @brief Gets the dispatcher (the top level end of the plugin chain) * This version may return null, if the plugin is instantiated without a * root. */ - PluginRoot *plugin_root_maybe_null (); + Dispatcher *dispatcher_maybe_null (); /** * @brief Menu command handler @@ -790,78 +880,6 @@ private: bool m_standalone; }; -/** - * @brief The plugin root element - * - * The first (root) object must be derived from this class. - * This class offers the full "plugin" functionality like - * configuration interface etc. but cannot have a parent. - */ - -class LAYBASIC_PUBLIC PluginRoot - : public Plugin -{ -public: - /** - * @brief The constructor - */ - PluginRoot (bool standalone = false, bool reg_inst = true); - - /** - * @brief Destructor - */ - ~PluginRoot (); - - /** - * @brief Write configuration to a file - * - * If the configuration file cannot be written, false - * is returned but no exception is thrown. - * - * @return false, if an error occurred. - */ - bool write_config (const std::string &config_file); - - /** - * @brief Read the configuration from a file - * - * This method siletly does nothing, if the config file does not - * exist. If it does and an error occurred, the error message is printed - * on stderr. In both cases, false is returned. - * - * @return false, if an error occurred. - */ - bool read_config (const std::string &config_file); - - /** - * @brief The singleton instance of the plugin root - */ - static PluginRoot *instance (); - - /** - * @brief Notifies the plugin root that a new plugin class has been registered - * - * This method is called when a plugin is loaded dynamically during runtime. - */ - virtual void plugin_registered (lay::PluginDeclaration * /*cls*/) { } - - /** - * @brief Notifies the plugin root that a plugin class is about to be removed - */ - virtual void plugin_removed (lay::PluginDeclaration * /*cls*/) { } - - /** - * @brief Selects the given mode - * - * The implementation is supposed to select the given mode on all related plugins. - */ - virtual void select_mode (int /*mode*/) { } - -private: - PluginRoot (const PluginRoot &); - PluginRoot &operator= (const PluginRoot &); -}; - /** * @brief A handy function for implementing the configure method * @@ -885,11 +903,6 @@ inline bool test_and_set (T &target, const T &source) namespace tl { - // disable copy ctor for PluginRoot - template <> struct type_traits : public type_traits { - typedef tl::false_tag has_copy_constructor; - }; - // disable copy ctor for Plugin template <> struct type_traits : public type_traits { typedef tl::false_tag has_copy_constructor; diff --git a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.h b/src/laybasic/laybasic/laySaveLayoutOptionsDialog.h index 584ba94e9..c14b587b7 100644 --- a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.h +++ b/src/laybasic/laybasic/laySaveLayoutOptionsDialog.h @@ -80,7 +80,7 @@ public: SaveLayoutOptionsDialog (QWidget *parent, const std::string &title); ~SaveLayoutOptionsDialog (); - bool edit_global_options (lay::PluginRoot *config_root, db::Technologies *technologies); + bool edit_global_options (lay::Dispatcher *dispatcher, db::Technologies *technologies); bool get_options (db::SaveLayoutOptions &options); public slots: diff --git a/src/lay/lay/laySelectCellViewForm.cc b/src/laybasic/laybasic/laySelectCellViewForm.cc similarity index 100% rename from src/lay/lay/laySelectCellViewForm.cc rename to src/laybasic/laybasic/laySelectCellViewForm.cc diff --git a/src/lay/lay/laySelectCellViewForm.h b/src/laybasic/laybasic/laySelectCellViewForm.h similarity index 100% rename from src/lay/lay/laySelectCellViewForm.h rename to src/laybasic/laybasic/laySelectCellViewForm.h diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index 92422593e..320831041 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -71,7 +71,9 @@ FORMS = \ NetlistBrowserConfigPage2.ui \ NetlistBrowserDialog.ui \ NetInfoDialog.ui \ - NetExportDialog.ui + NetExportDialog.ui \ + SelectCellViewForm.ui \ + LayoutStatistics.ui RESOURCES = \ laybasicResources.qrc @@ -86,7 +88,6 @@ SOURCES = \ gsiDeclLayPlugin.cc \ gsiDeclLayStream.cc \ layAbstractMenu.cc \ - layAbstractMenuProvider.cc \ layAnnotationShapes.cc \ layBitmap.cc \ layBitmapRenderer.cc \ @@ -178,12 +179,14 @@ SOURCES = \ layNetlistBrowserTreeModel.cc \ layLibrariesView.cc \ layBookmarksView.cc \ - layGenericSyntaxHighlighter.cc + layGenericSyntaxHighlighter.cc \ + layDispatcher.cc \ + laySelectCellViewForm.cc \ + layLayoutStatisticsForm.cc HEADERS = \ gtf.h \ layAbstractMenu.h \ - layAbstractMenuProvider.h \ layAnnotationShapes.h \ layBitmap.h \ layBitmapRenderer.h \ @@ -277,7 +280,10 @@ HEADERS = \ layNetlistBrowserTreeModel.h \ layLibrariesView.h \ layBookmarksView.h \ - layGenericSyntaxHighlighter.h + layGenericSyntaxHighlighter.h \ + layDispatcher.h \ + laySelectCellViewForm.h \ + layLayoutStatisticsForm.h INCLUDEPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC DEPENDPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC diff --git a/src/laybasic/laybasic/rdbMarkerBrowser.h b/src/laybasic/laybasic/rdbMarkerBrowser.h index 908859b4d..f4ced337c 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowser.h +++ b/src/laybasic/laybasic/rdbMarkerBrowser.h @@ -47,8 +47,8 @@ class MarkerBrowserConfigPage public: MarkerBrowserConfigPage (QWidget *parent); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); public slots: void window_changed (int); @@ -63,8 +63,8 @@ class MarkerBrowserConfigPage2 public: MarkerBrowserConfigPage2 (QWidget *parent); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); }; class MarkerBrowserContextModeConverter