WIP: preparing synthetic events for LayoutView in non-Qt case

This commit is contained in:
Matthias Koefferlein 2022-05-08 18:33:40 +02:00
parent c8be882785
commit aea861f9b4
13 changed files with 724 additions and 671 deletions

View File

@ -2113,7 +2113,7 @@ MainService::cm_tap ()
int icon_size = menu->style ()->pixelMetric (QStyle::PM_ButtonIconSize);
db::Point mp_local = view ()->view_object_widget ()->mouse_position ();
db::DPoint mp_local = view ()->view_object_widget ()->mouse_position ();
QPoint mp = view ()->view_object_widget ()->mapToGlobal (QPoint (mp_local.x (), mp_local.y ()));
for (std::vector<lay::LayerPropertiesConstIterator>::const_iterator l = tapped_layers.begin (); l != tapped_layers.end (); ++l) {

View File

@ -37,6 +37,7 @@
#include "layLayerProperties.h"
#include "layLayoutView.h"
#include "layTipDialog.h"
#include "layDragDropData.h"
#include <QInputDialog>
#include <QApplication>

View File

@ -357,6 +357,54 @@ get_config_names (lay::LayoutView *view)
return names;
}
static void
send_key_press_event (lay::LayoutView *view, unsigned int key, unsigned int buttons)
{
view->view_object_widget ()->send_key_press_event (key, buttons);
}
static void
send_mouse_move_event (lay::LayoutView *view, const db::DPoint &pt, unsigned int buttons)
{
view->view_object_widget ()->send_mouse_move_event (pt, buttons);
}
static void
send_leave_event (lay::LayoutView *view)
{
view->view_object_widget ()->send_leave_event ();
}
static void
send_enter_event (lay::LayoutView *view)
{
view->view_object_widget ()->send_enter_event ();
}
static void
send_mouse_press_event (lay::LayoutView *view, const db::DPoint &pt, unsigned int buttons)
{
view->view_object_widget ()->send_mouse_press_event (pt, buttons);
}
static void
send_mouse_double_clicked_event (lay::LayoutView *view, const db::DPoint &pt, unsigned int buttons)
{
view->view_object_widget ()->send_mouse_double_clicked_event (pt, buttons);
}
static void
send_mouse_release_event (lay::LayoutView *view, const db::DPoint &pt, unsigned int buttons)
{
view->view_object_widget ()->send_mouse_release_event (pt, buttons);
}
static void
send_wheel_event (lay::LayoutView *view, int delta, bool horizontal, const db::DPoint &pt, unsigned int buttons)
{
view->view_object_widget ()->send_wheel_event (delta, horizontal, pt, buttons);
}
namespace {
/**
@ -2007,6 +2055,68 @@ Class<lay::LayoutView> decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou
"invalid results."
"\n"
"This method was introduced in version 0.16."
) +
gsi::method_ext ("send_key_press_event", &send_key_press_event, gsi::arg ("key"), gsi::arg ("buttons"),
"@brief Sends a key press event\n"
"\n"
"This method is intended to emulate the key press events sent by Qt normally in environments where Qt is not present. "
"The arguments follow the conventions used within \\Plugin#key_event for example.\n"
"\n"
"This method was introduced in version 0.28."
) +
gsi::method_ext ("send_mouse_move_event", &send_mouse_move_event, gsi::arg ("pt"), gsi::arg ("buttons"),
"@brief Sends a mouse move event\n"
"\n"
"This method is intended to emulate the mouse move events sent by Qt normally in environments where Qt is not present. "
"The arguments follow the conventions used within \\Plugin#mouse_move_event for example.\n"
"\n"
"This method was introduced in version 0.28."
) +
gsi::method_ext ("send_mouse_press_event", &send_mouse_press_event, gsi::arg ("pt"), gsi::arg ("buttons"),
"@brief Sends a mouse button press event\n"
"\n"
"This method is intended to emulate the mouse button press events sent by Qt normally in environments where Qt is not present. "
"The arguments follow the conventions used within \\Plugin#mouse_move_event for example.\n"
"\n"
"This method was introduced in version 0.28."
) +
gsi::method_ext ("send_mouse_double_clicked_event", &send_mouse_double_clicked_event, gsi::arg ("pt"), gsi::arg ("buttons"),
"@brief Sends a mouse button double-click event\n"
"\n"
"This method is intended to emulate the mouse button double-click events sent by Qt normally in environments where Qt is not present. "
"The arguments follow the conventions used within \\Plugin#mouse_move_event for example.\n"
"\n"
"This method was introduced in version 0.28."
) +
gsi::method_ext ("send_mouse_release_event", &send_mouse_release_event, gsi::arg ("pt"), gsi::arg ("buttons"),
"@brief Sends a mouse button release event\n"
"\n"
"This method is intended to emulate the mouse button release events sent by Qt normally in environments where Qt is not present. "
"The arguments follow the conventions used within \\Plugin#mouse_move_event for example.\n"
"\n"
"This method was introduced in version 0.28."
) +
gsi::method_ext ("send_leave_event", &send_leave_event,
"@brief Sends a mouse window leave event\n"
"\n"
"This method is intended to emulate the mouse mouse window leave events sent by Qt normally in environments where Qt is not present. "
"\n"
"This method was introduced in version 0.28."
) +
gsi::method_ext ("send_enter_event", &send_enter_event,
"@brief Sends a mouse window leave event\n"
"\n"
"This method is intended to emulate the mouse mouse window leave events sent by Qt normally in environments where Qt is not present. "
"\n"
"This method was introduced in version 0.28."
) +
gsi::method_ext ("send_wheel_event", &send_wheel_event, gsi::arg ("delta"), gsi::arg ("horizontal"), gsi::arg ("pt"), gsi::arg ("buttons"),
"@brief Sends a mouse wheel event\n"
"\n"
"This method is intended to emulate the mouse wheel events sent by Qt normally in environments where Qt is not present. "
"The arguments follow the conventions used within \\Plugin#wheel_event for example.\n"
"\n"
"This method was introduced in version 0.28."
),
"@brief The view object presenting one or more layout objects\n"
"\n"

View File

@ -23,6 +23,7 @@
#include "layCellTreeModel.h"
#include "layLayoutView.h"
#include "layDragDropData.h"
#include "tlGlobPattern.h"
#include "dbPCellHeader.h"
#include "dbPCellVariant.h"

View File

@ -433,7 +433,7 @@ LayoutViewFunctions::cm_cell_user_properties ()
lay::UserPropertiesForm props_form (view ());
if (props_form.show (view (), cv_index, prop_id)) {
view ()->transaction (tl::to_string (QObject::tr ("Edit cell's user properties")));
view ()->transaction (tl::to_string (tr ("Edit cell's user properties")));
cell.prop_id (prop_id);
view ()->commit ();
@ -456,7 +456,7 @@ LayoutViewFunctions::cm_cell_replace ()
if (cv_index >= 0 && paths.size () > 0) {
if (paths.size () > 1) {
throw tl::Exception (tl::to_string (QObject::tr ("Replace cell cannot be used when multiple cells are selected")));
throw tl::Exception (tl::to_string (tr ("Replace cell cannot be used when multiple cells are selected")));
}
db::Layout &layout = view ()->cellview (cv_index)->layout ();
@ -487,7 +487,7 @@ LayoutViewFunctions::cm_cell_replace ()
view ()->clear_selection ();
view ()->transaction (tl::to_string (QObject::tr ("Replace cells")));
view ()->transaction (tl::to_string (tr ("Replace cells")));
// replace instances of the target cell with the new cell
@ -555,7 +555,7 @@ LayoutViewFunctions::cm_lay_convert_to_static ()
db::Layout &layout = view ()->cellview (cv_index)->layout ();
view ()->transaction (tl::to_string (QObject::tr ("Convert all cells to static")));
view ()->transaction (tl::to_string (tr ("Convert all cells to static")));
std::vector<db::cell_index_type> cells;
for (db::Layout::const_iterator c = layout.begin (); c != layout.end (); ++c) {
@ -611,7 +611,7 @@ LayoutViewFunctions::cm_cell_convert_to_static ()
view ()->clear_selection ();
view ()->transaction (tl::to_string (QObject::tr ("Convert cells to static")));
view ()->transaction (tl::to_string (tr ("Convert cells to static")));
std::map<db::cell_index_type, db::cell_index_type> cell_map;
@ -697,7 +697,7 @@ LayoutViewFunctions::cm_cell_delete ()
}
}
view ()->transaction (tl::to_string (QObject::tr ("Delete cells")));
view ()->transaction (tl::to_string (tr ("Delete cells")));
if (mode == 0 || mode == 2) {
layout.delete_cells (cells_to_delete);
@ -730,7 +730,7 @@ void
LayoutViewFunctions::cm_layer_cut ()
{
if (view ()->control_panel ()) {
db::Transaction trans (manager (), tl::to_string (QObject::tr ("Cut Layers")));
db::Transaction trans (manager (), tl::to_string (tr ("Cut Layers")));
view ()->control_panel ()->cut ();
}
}
@ -739,7 +739,7 @@ void
LayoutViewFunctions::cm_layer_paste ()
{
if (view ()->control_panel ()) {
db::Transaction trans (manager (), tl::to_string (QObject::tr ("Paste Layers")));
db::Transaction trans (manager (), tl::to_string (tr ("Paste Layers")));
view ()->control_panel ()->paste ();
}
}
@ -758,7 +758,7 @@ void
LayoutViewFunctions::cm_cell_paste ()
{
if (view ()->hierarchy_panel ()) {
db::Transaction trans (manager (), tl::to_string (QObject::tr ("Paste Cells")));
db::Transaction trans (manager (), tl::to_string (tr ("Paste Cells")));
view ()->hierarchy_panel ()->paste ();
}
}
@ -789,12 +789,12 @@ LayoutViewFunctions::cm_cell_flatten ()
std::vector<HierarchyControlPanel::cell_path_type> paths;
view ()->hierarchy_panel ()->selected_cells (cv_index, paths);
if (paths.empty ()) {
throw tl::Exception (tl::to_string (QObject::tr ("No cells selected for flattening")));
throw tl::Exception (tl::to_string (tr ("No cells selected for flattening")));
}
for (std::vector<HierarchyControlPanel::cell_path_type>::const_iterator p = paths.begin (); p != paths.end (); ++p) {
if (p->size () > 0 && cv->layout ().cell (p->back ()).is_proxy ()) {
throw tl::Exception (tl::to_string (QObject::tr ("Cannot use this function on a PCell or library cell")));
throw tl::Exception (tl::to_string (tr ("Cannot use this function on a PCell or library cell")));
}
}
@ -809,7 +809,7 @@ LayoutViewFunctions::cm_cell_flatten ()
if (manager () && manager ()->is_enabled ()) {
lay::TipDialog td (QApplication::activeWindow (),
tl::to_string (QObject::tr ("Undo buffering for the following operation can be memory and time consuming.\nChoose \"Yes\" to use undo buffering or \"No\" for no undo buffering. Warning: in the latter case, the undo history will be lost.\n\nChoose undo buffering?")),
tl::to_string (tr ("Undo buffering for the following operation can be memory and time consuming.\nChoose \"Yes\" to use undo buffering or \"No\" for no undo buffering. Warning: in the latter case, the undo history will be lost.\n\nChoose undo buffering?")),
"flatten-undo-buffering",
lay::TipDialog::yesnocancel_buttons);
@ -832,7 +832,7 @@ LayoutViewFunctions::cm_cell_flatten ()
if (! supports_undo) {
manager ()->clear ();
} else {
manager ()->transaction (tl::to_string (QObject::tr ("Flatten cell")));
manager ()->transaction (tl::to_string (tr ("Flatten cell")));
}
}
@ -890,7 +890,7 @@ LayoutViewFunctions::cm_cell_rename ()
std::string name (layout.cell_name (path.back ()));
if (name_dialog.exec_dialog (layout, name)) {
view ()->transaction (tl::to_string (QObject::tr ("Rename cell")));
view ()->transaction (tl::to_string (tr ("Rename cell")));
layout.rename_cell (path.back (), name.c_str ());
view ()->commit ();
@ -921,7 +921,7 @@ LayoutViewFunctions::cm_cell_hide ()
std::vector<HierarchyControlPanel::cell_path_type> paths;
view ()->hierarchy_panel ()->selected_cells (view ()->active_cellview_index (), paths);
view ()->transaction (tl::to_string (QObject::tr ("Hide cell")));
view ()->transaction (tl::to_string (tr ("Hide cell")));
for (std::vector<HierarchyControlPanel::cell_path_type>::const_iterator p = paths.begin (); p != paths.end (); ++p) {
if (! p->empty ()) {
@ -942,7 +942,7 @@ LayoutViewFunctions::cm_cell_show ()
std::vector<HierarchyControlPanel::cell_path_type> paths;
view ()->hierarchy_panel ()->selected_cells (view ()->active_cellview_index (), paths);
view ()->transaction (tl::to_string (QObject::tr ("Show cell")));
view ()->transaction (tl::to_string (tr ("Show cell")));
for (std::vector<HierarchyControlPanel::cell_path_type>::const_iterator p = paths.begin (); p != paths.end (); ++p) {
if (! p->empty ()) {
@ -959,7 +959,7 @@ void
LayoutViewFunctions::cm_cell_show_all ()
{
if (view ()->hierarchy_panel ()) {
view ()->transaction (tl::to_string (QObject::tr ("Show all cells")));
view ()->transaction (tl::to_string (tr ("Show all cells")));
view ()->show_all_cells ();
view ()->commit ();
}
@ -1270,7 +1270,7 @@ LayoutViewFunctions::cm_reload ()
if (view ()->cellviews () > 1) {
lay::SelectCellViewForm form (0, view (), tl::to_string (QObject::tr ("Select Layouts To Reload")));
lay::SelectCellViewForm form (0, view (), tl::to_string (tr ("Select Layouts To Reload")));
form.select_all ();
if (form.exec () == QDialog::Accepted) {
@ -1308,10 +1308,10 @@ LayoutViewFunctions::cm_reload ()
if (dirty_layouts != 0) {
QMessageBox mbox (view ());
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.setText (tl::to_qstring (tl::to_string (tr ("The following layouts need saving:\n\n")) + dirty_files + "\n\nPress 'Reload Without Saving' to reload anyhow and discard changes."));
mbox.setWindowTitle (tr ("Save Needed"));
mbox.setIcon (QMessageBox::Warning);
QAbstractButton *yes_button = mbox.addButton (QObject::tr ("Reload Without Saving"), QMessageBox::YesRole);
QAbstractButton *yes_button = mbox.addButton (tr ("Reload Without Saving"), QMessageBox::YesRole);
mbox.addButton (QMessageBox::Cancel);
mbox.exec ();
@ -1352,7 +1352,7 @@ LayoutViewFunctions::transform_layout (const db::DCplxTrans &tr_mic)
db::Layout &layout = view ()->cellview (cv_index)->layout ();
db::ICplxTrans tr (db::DCplxTrans (1.0 / layout.dbu ()) * tr_mic * db::DCplxTrans (layout.dbu ()));
db::ICplxTrans trans (db::DCplxTrans (1.0 / layout.dbu ()) * tr_mic * db::DCplxTrans (layout.dbu ()));
bool has_proxy = false;
for (db::Layout::const_iterator c = layout.begin (); ! has_proxy && c != layout.end (); ++c) {
@ -1361,19 +1361,19 @@ LayoutViewFunctions::transform_layout (const db::DCplxTrans &tr_mic)
if (has_proxy &&
QMessageBox::question (view (),
QObject::tr ("Transforming PCells Or Library Cells"),
QObject::tr ("The layout contains PCells or library cells or both.\n"
"Any changes to such cells may be lost when their layout is refreshed later.\n"
"Consider using 'Convert all cells to static' before transforming the layout.\n"
"\n"
"Would you like to continue?\n"
"Choose 'Yes' to continue anyway. Choose 'No' to cancel."),
tr ("Transforming PCells Or Library Cells"),
tr ("The layout contains PCells or library cells or both.\n"
"Any changes to such cells may be lost when their layout is refreshed later.\n"
"Consider using 'Convert all cells to static' before transforming the layout.\n"
"\n"
"Would you like to continue?\n"
"Choose 'Yes' to continue anyway. Choose 'No' to cancel."),
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) {
return;
}
view ()->transaction (tl::to_string (QObject::tr ("Transform layout")));
layout.transform (tr);
view ()->transaction (tl::to_string (tr ("Transform layout")));
layout.transform (trans);
view ()->commit ();
}
@ -1409,8 +1409,8 @@ LayoutViewFunctions::cm_lay_free_rot ()
{
bool ok = false;
QString s = QInputDialog::getText (QApplication::activeWindow (),
QObject::tr ("Free rotation"),
QObject::tr ("Rotation angle in degree (counterclockwise)"),
tr ("Free rotation"),
tr ("Rotation angle in degree (counterclockwise)"),
QLineEdit::Normal, QString::fromUtf8 ("0.0"),
&ok);
@ -1429,8 +1429,8 @@ LayoutViewFunctions::cm_lay_scale ()
{
bool ok = false;
QString s = QInputDialog::getText (QApplication::activeWindow (),
QObject::tr ("Scaling"),
QObject::tr ("Scaling factor"),
tr ("Scaling"),
tr ("Scaling factor"),
QLineEdit::Normal, QString::fromUtf8 ("1.0"),
&ok);
@ -1502,8 +1502,8 @@ LayoutViewFunctions::cm_sel_free_rot ()
{
bool ok = false;
QString s = QInputDialog::getText (QApplication::activeWindow (),
QObject::tr ("Free rotation"),
QObject::tr ("Rotation angle in degree (counterclockwise)"),
tr ("Free rotation"),
tr ("Rotation angle in degree (counterclockwise)"),
QLineEdit::Normal, QString::fromUtf8 ("0.0"),
&ok);
@ -1527,8 +1527,8 @@ LayoutViewFunctions::cm_sel_scale ()
{
bool ok = false;
QString s = QInputDialog::getText (QApplication::activeWindow (),
QObject::tr ("Scaling"),
QObject::tr ("Scaling factor"),
tr ("Scaling"),
tr ("Scaling factor"),
QLineEdit::Normal, QString::fromUtf8 ("1.0"),
&ok);
@ -1560,7 +1560,7 @@ LayoutViewFunctions::cm_sel_move_to ()
{
db::DBox sel_bbox (view ()->lay::Editables::selection_bbox ());
if (sel_bbox.empty ()) {
throw tl::Exception (tl::to_string (QObject::tr ("Nothing selected to move")));
throw tl::Exception (tl::to_string (tr ("Nothing selected to move")));
}
double x = sel_bbox.left () + (sel_bbox.width () * (1 + m_move_to_origin_mode_x) * 0.5);
@ -1623,7 +1623,7 @@ LayoutViewFunctions::cm_copy_layer ()
if (manager () && manager ()->is_enabled ()) {
lay::TipDialog td (QApplication::activeWindow (),
tl::to_string (QObject::tr ("Undo buffering for the following operation can be memory and time consuming.\nChoose \"Yes\" to use undo buffering or \"No\" for no undo buffering. Warning: in the latter case, the undo history will be lost.\n\nChoose undo buffering?")),
tl::to_string (tr ("Undo buffering for the following operation can be memory and time consuming.\nChoose \"Yes\" to use undo buffering or \"No\" for no undo buffering. Warning: in the latter case, the undo history will be lost.\n\nChoose undo buffering?")),
"copy-layer-undo-buffering",
lay::TipDialog::yesnocancel_buttons);
@ -1645,7 +1645,7 @@ LayoutViewFunctions::cm_copy_layer ()
if (! supports_undo) {
manager ()->clear ();
} else {
manager ()->transaction (tl::to_string (QObject::tr ("Duplicate layer")));
manager ()->transaction (tl::to_string (tr ("Duplicate layer")));
}
}
@ -1653,7 +1653,7 @@ LayoutViewFunctions::cm_copy_layer ()
bool same_layout = (&view ()->cellview (m_copy_cvr)->layout () == &view ()->cellview (m_copy_cva)->layout ());
if (same_layout && m_copy_layera == m_copy_layerr) {
throw tl::Exception (tl::to_string (QObject::tr ("Source and target layer must not be identical for duplicate operation")));
throw tl::Exception (tl::to_string (tr ("Source and target layer must not be identical for duplicate operation")));
}
if (m_duplicate_hier_mode == 0) {
@ -1780,11 +1780,11 @@ LayoutViewFunctions::cm_new_layer ()
for (unsigned int l = 0; l < cv->layout ().layers (); ++l) {
if (cv->layout ().is_valid_layer (l) && cv->layout ().get_properties (l).log_equal (m_new_layer_props)) {
throw tl::Exception (tl::to_string (QObject::tr ("A layer with that signature already exists: ")) + m_new_layer_props.to_string ());
throw tl::Exception (tl::to_string (tr ("A layer with that signature already exists: ")) + m_new_layer_props.to_string ());
}
}
view ()->transaction (tl::to_string (QObject::tr ("New layer")));
view ()->transaction (tl::to_string (tr ("New layer")));
unsigned int l = cv->layout ().insert_layer (m_new_layer_props);
std::vector <unsigned int> nl;
@ -1810,7 +1810,7 @@ LayoutViewFunctions::cm_align_cell_origin ()
return;
}
if (cell->is_proxy ()) {
throw tl::Exception (tl::to_string (QObject::tr ("Cannot use this function on a PCell or library cell")));
throw tl::Exception (tl::to_string (tr ("Cannot use this function on a PCell or library cell")));
}
lay::AlignCellOptionsDialog dialog (view ());
@ -1818,7 +1818,7 @@ LayoutViewFunctions::cm_align_cell_origin ()
view ()->clear_selection ();
view ()->transaction (tl::to_string (QObject::tr ("Align cell origin")));
view ()->transaction (tl::to_string (tr ("Align cell origin")));
db::Box bbox;
@ -1900,12 +1900,12 @@ LayoutViewFunctions::cm_edit_layer ()
{
lay::LayerPropertiesConstIterator sel = view ()->current_layer ();
if (sel.is_null ()) {
throw tl::Exception (tl::to_string (QObject::tr ("No layer selected for editing it's properties")));
throw tl::Exception (tl::to_string (tr ("No layer selected for editing it's properties")));
}
int index = sel->cellview_index ();
if (sel->has_children () || index < 0 || int (view ()->cellviews ()) <= index || sel->layer_index () < 0) {
throw tl::Exception (tl::to_string (QObject::tr ("No valid layer selected for editing it's properties")));
throw tl::Exception (tl::to_string (tr ("No valid layer selected for editing it's properties")));
}
const lay::CellView &cv = view ()->cellview (index);
@ -1917,11 +1917,11 @@ LayoutViewFunctions::cm_edit_layer ()
for (unsigned int l = 0; l < cv->layout ().layers (); ++l) {
if (cv->layout ().is_valid_layer (l) && int (l) != sel->layer_index () && cv->layout ().get_properties (l).log_equal (layer_props)) {
throw tl::Exception (tl::to_string (QObject::tr ("A layer with that signature already exists: ")) + layer_props.to_string ());
throw tl::Exception (tl::to_string (tr ("A layer with that signature already exists: ")) + layer_props.to_string ());
}
}
view ()->transaction (tl::to_string (QObject::tr ("Edit layer")));
view ()->transaction (tl::to_string (tr ("Edit layer")));
cv->layout ().set_properties (sel->layer_index (), layer_props);
@ -1963,13 +1963,13 @@ LayoutViewFunctions::cm_delete_layer ()
}
if (valid_sel.empty ()) {
throw tl::Exception (tl::to_string (QObject::tr ("No or no valid layer selected for deleting them")));
throw tl::Exception (tl::to_string (tr ("No or no valid layer selected for deleting them")));
}
view ()->cancel_edits ();
view ()->clear_selection ();
view ()->transaction (tl::to_string (QObject::tr ("Delete layers")));
view ()->transaction (tl::to_string (tr ("Delete layers")));
// Hint: delete_layer must come before the layers are actually deleted in because
// for undo this must be the last thing to do (otherwise the layout is not propertly set up)
@ -2002,7 +2002,7 @@ LayoutViewFunctions::cm_clear_layer ()
{
std::vector<lay::LayerPropertiesConstIterator> sel = view ()->selected_layers ();
if (sel.empty ()) {
throw tl::Exception (tl::to_string (QObject::tr ("No layer selected for clearing")));
throw tl::Exception (tl::to_string (tr ("No layer selected for clearing")));
}
lay::ClearLayerModeDialog mode_dialog (view ());
@ -2011,7 +2011,7 @@ LayoutViewFunctions::cm_clear_layer ()
view ()->cancel_edits ();
view ()->clear_selection ();
view ()->transaction (tl::to_string (QObject::tr ("Clear layer")));
view ()->transaction (tl::to_string (tr ("Clear layer")));
for (std::vector<lay::LayerPropertiesConstIterator>::const_iterator si = sel.begin (); si != sel.end (); ++si) {
@ -2058,153 +2058,153 @@ public:
// 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"))));
menu_entries.push_back (lay::menu_item ("cm_select_next_item", "select_next_item:edit", at, tl::to_string (QObject::tr ("Select Next Item(Space)"))));
menu_entries.push_back (lay::menu_item ("cm_select_next_item_add", "select_next_item_add:edit", at, tl::to_string (QObject::tr ("Select Next Item too(Shift+Space)"))));
menu_entries.push_back (lay::menu_item ("cm_paste_interactive", "paste_interactive:edit", at, tl::to_string (tr ("Paste Interactive"))));
menu_entries.push_back (lay::menu_item ("cm_duplicate_interactive", "duplicate_interactive:edit", at, tl::to_string (tr ("Duplicate Interactive"))));
menu_entries.push_back (lay::menu_item ("cm_sel_move_interactive", "sel_move_interactive:edit", at, tl::to_string (tr ("Move Interactive"))));
menu_entries.push_back (lay::menu_item ("cm_select_next_item", "select_next_item:edit", at, tl::to_string (tr ("Select Next Item(Space)"))));
menu_entries.push_back (lay::menu_item ("cm_select_next_item_add", "select_next_item_add:edit", at, tl::to_string (tr ("Select Next Item too(Shift+Space)"))));
at = "edit_menu.edit_options_group";
menu_entries.push_back (lay::menu_item ("cm_undo", "undo:edit", at, tl::to_string (QObject::tr ("Undo(Ctrl+Z)"))));
menu_entries.push_back (lay::menu_item ("cm_redo", "redo:edit", at, tl::to_string (QObject::tr ("Redo(Ctrl+Y)"))));
menu_entries.push_back (lay::menu_item ("cm_undo", "undo:edit", at, tl::to_string (tr ("Undo(Ctrl+Z)"))));
menu_entries.push_back (lay::menu_item ("cm_redo", "redo:edit", at, tl::to_string (tr ("Redo(Ctrl+Y)"))));
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"))));
menu_entries.push_back (lay::submenu ("layout_menu:edit:edit_mode", at, tl::to_string (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::menu_item ("cm_lay_flip_x", "lay_flip_x:edit_mode", at, tl::to_string (tr ("Flip Horizontally"))));
menu_entries.push_back (lay::menu_item ("cm_lay_flip_y", "lay_flip_y:edit_mode", at, tl::to_string (tr ("Flip Vertically"))));
menu_entries.push_back (lay::menu_item ("cm_lay_rot_cw", "lay_rot_cw:edit_mode", at, tl::to_string (tr ("Rotate Clockwise"))));
menu_entries.push_back (lay::menu_item ("cm_lay_rot_ccw", "lay_rot_ccw:edit_mode", at, tl::to_string (tr ("Rotate Counterclockwise"))));
menu_entries.push_back (lay::menu_item ("cm_lay_free_rot", "lay_free_rot:edit_mode", at, tl::to_string (tr ("Rotation By Angle"))));
menu_entries.push_back (lay::menu_item ("cm_lay_scale", "lay_scale:edit_mode", at, tl::to_string (tr ("Scale"))));
menu_entries.push_back (lay::menu_item ("cm_lay_move", "lay_move:edit_mode", at, tl::to_string (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::menu_item ("cm_lay_convert_to_static", "lay_convert_to_static:edit_mode", at, tl::to_string (tr ("Convert All Cells To Static"))));
}
menu_entries.push_back (lay::submenu ("cell_menu:edit:edit_mode", at, tl::to_string (QObject::tr ("Cell"))));
menu_entries.push_back (lay::submenu ("cell_menu:edit:edit_mode", at, tl::to_string (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::menu_item ("cm_new_cell", "new_cell:edit:edit_mode", at, tl::to_string (tr ("New Cell"))));
menu_entries.push_back (lay::menu_item ("cm_cell_delete", "delete_cell:edit:edit_mode", at, tl::to_string (tr ("Delete Cell"))));
menu_entries.push_back (lay::menu_item ("cm_cell_rename", "rename_cell:edit:edit_mode", at, tl::to_string (tr ("Rename Cell"))));
menu_entries.push_back (lay::menu_item ("cm_cell_replace", "replace_cell:edit:edit_mode", at, tl::to_string (tr ("Replace Cell"))));
menu_entries.push_back (lay::menu_item ("cm_cell_flatten", "flatten_cell:edit:edit_mode", at, tl::to_string (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::menu_item ("cm_adjust_origin", "adjust_cell_origin:edit:edit_mode", at, tl::to_string (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 (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::menu_item ("cm_cell_user_properties", "user_properties", at, tl::to_string (tr ("User Properties"))));
}
menu_entries.push_back (lay::submenu ("layer_menu:edit:edit_mode", at, tl::to_string (QObject::tr ("Layer"))));
menu_entries.push_back (lay::submenu ("layer_menu:edit:edit_mode", at, tl::to_string (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::menu_item ("cm_new_layer", "new_layer:edit:edit_mode", at, tl::to_string (tr ("New Layer"))));
menu_entries.push_back (lay::menu_item ("cm_clear_layer", "clear_layer:edit:edit_mode", at, tl::to_string (tr ("Clear Layer"))));
menu_entries.push_back (lay::menu_item ("cm_delete_layer", "delete_layer:edit:edit_mode", at, tl::to_string (tr ("Delete Layer"))));
menu_entries.push_back (lay::menu_item ("cm_copy_layer", "copy_layer:edit:edit_mode", at, tl::to_string (tr ("Copy Layer"))));
menu_entries.push_back (lay::menu_item ("cm_edit_layer", "edit_layer:edit:edit_mode", at, tl::to_string (tr ("Edit Layer Specification"))));
}
menu_entries.push_back (lay::submenu ("selection_menu:edit", at, tl::to_string (QObject::tr ("Selection"))));
menu_entries.push_back (lay::submenu ("selection_menu:edit", at, tl::to_string (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::menu_item ("cm_sel_flip_x", "sel_flip_x", at, tl::to_string (tr ("Flip Horizontally"))));
menu_entries.push_back (lay::menu_item ("cm_sel_flip_y", "sel_flip_y", at, tl::to_string (tr ("Flip Vertically"))));
menu_entries.push_back (lay::menu_item ("cm_sel_rot_cw", "sel_rot_cw", at, tl::to_string (tr ("Rotate Clockwise"))));
menu_entries.push_back (lay::menu_item ("cm_sel_rot_ccw", "sel_rot_ccw", at, tl::to_string (tr ("Rotate Counterclockwise"))));
menu_entries.push_back (lay::menu_item ("cm_sel_free_rot", "sel_free_rot", at, tl::to_string (tr ("Rotation By Angle"))));
menu_entries.push_back (lay::menu_item ("cm_sel_scale", "sel_scale", at, tl::to_string (tr ("Scale"))));
menu_entries.push_back (lay::menu_item ("cm_sel_move", "sel_move", at, tl::to_string (tr ("Move By"))));
menu_entries.push_back (lay::menu_item ("cm_sel_move_to", "sel_move_to", at, tl::to_string (tr ("Move To"))));
}
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::submenu ("utils_menu:edit:edit_mode", at, tl::to_string (tr ("Utilities"))));
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::menu_item ("cm_delete", "delete:edit", at, tl::to_string (tr ("Delete(Del)"))));
menu_entries.push_back (lay::menu_item ("cm_show_properties", "show_properties:edit", at, tl::to_string (tr ("Properties(Q)"))));
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::menu_item ("cm_copy", "copy:edit", at, tl::to_string (tr ("Copy(Ctrl+C)"))));
menu_entries.push_back (lay::menu_item ("cm_cut", "cut:edit", at, tl::to_string (tr ("Cut(Ctrl+X)"))));
menu_entries.push_back (lay::menu_item ("cm_paste", "paste:edit", at, tl::to_string (tr ("Paste(Ctrl+V)"))));
menu_entries.push_back (lay::menu_item ("cm_duplicate", "duplicate:edit", at, tl::to_string (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 ("mode_menu", at, tl::to_string (tr ("Mode"))));
menu_entries.push_back (lay::submenu ("select_menu", at, tl::to_string (QObject::tr ("Select"))));
menu_entries.push_back (lay::submenu ("select_menu", at, tl::to_string (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::menu_item ("cm_select_all", "select_all", at, tl::to_string (tr ("Select All"))));
menu_entries.push_back (lay::menu_item ("cm_unselect_all", "unselect_all", at, tl::to_string (tr ("Unselect All"))));
menu_entries.push_back (lay::separator ("edit_select_basic_group", at));
menu_entries.push_back (lay::menu_item ("lv:enable_all", "enable_all", at, tl::to_string (QObject::tr ("Enable All"))));
menu_entries.push_back (lay::menu_item ("lv:disable_all", "disable_all", at, tl::to_string (QObject::tr ("Disable All"))));
menu_entries.push_back (lay::menu_item ("lv:enable_all", "enable_all", at, tl::to_string (tr ("Enable All"))));
menu_entries.push_back (lay::menu_item ("lv:disable_all", "disable_all", at, tl::to_string (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)"))));
menu_entries.push_back (lay::menu_item ("cm_cancel", "cancel", at, tl::to_string (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::submenu ("goto_bookmark_menu", at, tl::to_string (tr ("Goto Bookmark"))));
menu_entries.push_back (lay::menu_item ("cm_bookmark_view", "bookmark_view", at, tl::to_string (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"))));
menu_entries.push_back (lay::submenu ("open_recent_menu_bookmarks", at, tl::to_string (QObject::tr ("Recent Bookmark Files"))));
menu_entries.push_back (lay::menu_item ("cm_manage_bookmarks", "manage_bookmarks", at, tl::to_string (tr ("Manage Bookmarks"))));
menu_entries.push_back (lay::menu_item ("cm_load_bookmarks", "load_bookmarks", at, tl::to_string (tr ("Load Bookmarks"))));
menu_entries.push_back (lay::menu_item ("cm_save_bookmarks", "save_bookmarks", at, tl::to_string (tr ("Save Bookmarks"))));
menu_entries.push_back (lay::submenu ("open_recent_menu_bookmarks", at, tl::to_string (tr ("Recent Bookmark Files"))));
at = "zoom_menu.end";
menu_entries.push_back (lay::submenu ("global_trans", at, tl::to_string (QObject::tr ("Global Transformation"))));
menu_entries.push_back (lay::submenu ("global_trans", at, tl::to_string (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::config_menu_item ("r0", at, tl::to_string (tr ("\\(r0\\)<:/r0.png>")), cfg_global_trans, "?r0 *1 0,0"));
menu_entries.push_back (lay::config_menu_item ("r90", at, tl::to_string (tr ("\\(r90\\)<:/r90.png>")), cfg_global_trans, "?r90 *1 0,0"));
menu_entries.push_back (lay::config_menu_item ("r180", at, tl::to_string (tr ("\\(r180\\)<:/r180.png>")), cfg_global_trans, "?r180 *1 0,0"));
menu_entries.push_back (lay::config_menu_item ("r270", at, tl::to_string (tr ("\\(r270\\)<:/r270.png>")), cfg_global_trans, "?r270 *1 0,0"));
menu_entries.push_back (lay::config_menu_item ("m0", at, tl::to_string (tr ("\\(m0\\)<:/m0.png>")), cfg_global_trans, "?m0 *1 0,0"));
menu_entries.push_back (lay::config_menu_item ("m45", at, tl::to_string (tr ("\\(m45\\)<:/m45.png>")), cfg_global_trans, "?m45 *1 0,0"));
menu_entries.push_back (lay::config_menu_item ("m90", at, tl::to_string (tr ("\\(m90\\)<:/m90.png>")), cfg_global_trans, "?m90 *1 0,0"));
menu_entries.push_back (lay::config_menu_item ("m135", at, tl::to_string (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::menu_item ("cm_max_hier", "max_hier", at, tl::to_string (tr ("Full Hierarchy(*)"))));
menu_entries.push_back (lay::menu_item ("cm_max_hier_0", "max_hier_0", at, tl::to_string (tr ("Box Only(0)"))));
menu_entries.push_back (lay::menu_item ("cm_max_hier_1", "max_hier_1", at, tl::to_string (tr ("Top Level Only(1)"))));
menu_entries.push_back (lay::menu_item ("cm_inc_max_hier", "inc_max_hier", at, tl::to_string (tr ("Increment Hierarchy(+)"))));
menu_entries.push_back (lay::menu_item ("cm_dec_max_hier", "dec_max_hier", at, tl::to_string (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(Ctrl++)"))));
menu_entries.push_back (lay::menu_item ("cm_zoom_out", "zoom_out", at, tl::to_string (QObject::tr ("Zoom Out(Ctrl+-)"))));
menu_entries.push_back (lay::menu_item ("cm_zoom_fit", "zoom_fit", at, tl::to_string (tr ("Zoom Fit(F2)"))));
menu_entries.push_back (lay::menu_item ("cm_zoom_fit_sel", "zoom_fit_sel", at, tl::to_string (tr ("Zoom Fit Selection(Shift+F2)"))));
menu_entries.push_back (lay::menu_item ("cm_zoom_in", "zoom_in", at, tl::to_string (tr ("Zoom In(Ctrl++)"))));
menu_entries.push_back (lay::menu_item ("cm_zoom_out", "zoom_out", at, tl::to_string (tr ("Zoom Out(Ctrl+-)"))));
/* 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::menu_item ("cm_pan_up", "pan_up", at, tl::to_string (tr ("Pan Up(Up)"))));
menu_entries.push_back (lay::menu_item ("cm_pan_down", "pan_down", at, tl::to_string (tr ("Pan Down(Down)"))));
menu_entries.push_back (lay::menu_item ("cm_pan_left", "pan_left", at, tl::to_string (tr ("Pan Left(Left)"))));
menu_entries.push_back (lay::menu_item ("cm_pan_right", "pan_right", at, tl::to_string (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::menu_item ("cm_redraw", "redraw", at, tl::to_string (tr ("Redraw"))));
menu_entries.push_back (lay::separator ("state_group", at));
menu_entries.push_back (lay::menu_item_copy ("cm_prev_display_state", "prev_display_state", at, "@toolbar.prev_display_state"));
menu_entries.push_back (lay::menu_item_copy ("cm_next_display_state", "next_display_state", at, "@toolbar.next_display_state"));
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)"))));
menu_entries.push_back (lay::menu_item ("cm_select_cell", "select_cell:edit", at, tl::to_string (tr ("Select Cell"))));
menu_entries.push_back (lay::menu_item ("cm_select_current_cell", "select_current_cell", at, tl::to_string (tr ("Show As New Top(Ctrl+S)"))));
menu_entries.push_back (lay::menu_item ("cm_goto_position", "goto_position", at, tl::to_string (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"));

View File

@ -62,6 +62,7 @@ PluginDeclaration::~PluginDeclaration ()
}
}
#if defined(HAVE_QT)
void
PluginDeclaration::toggle_editable_enabled ()
{
@ -69,6 +70,7 @@ PluginDeclaration::toggle_editable_enabled ()
set_editable_enabled (! editable_enabled ());
END_PROTECTED
}
#endif
std::vector<std::string>
PluginDeclaration::menu_symbols ()
@ -95,6 +97,7 @@ PluginDeclaration::menu_symbols ()
}
#if defined(HAVE_QT)
namespace {
class GenericMenuAction
@ -144,12 +147,10 @@ private:
};
}
#endif
void
PluginDeclaration::init_menu (lay::Dispatcher *dispatcher)
{
#if defined(HAVE_QT) // @@@
lay::AbstractMenu &menu = *dispatcher->menu ();
mp_editable_mode_action.reset ((Action *) 0);
@ -259,13 +260,11 @@ PluginDeclaration::init_menu (lay::Dispatcher *dispatcher)
menu.insert_item (m->second.first, name + ":mode_group", mp_mouse_mode_action.get ());
}
#endif
}
void
PluginDeclaration::remove_menu_items (Dispatcher *dispatcher)
{
#if defined(HAVE_QT) // @@@
lay::AbstractMenu *menu = dispatcher->menu ();
menu->delete_items (mp_editable_mode_action.get ());
menu->delete_items (mp_mouse_mode_action.get ());
@ -280,15 +279,16 @@ PluginDeclaration::remove_menu_items (Dispatcher *dispatcher)
menu->delete_items (*a);
}
m_menu_actions.clear ();
#endif
}
#endif
void
PluginDeclaration::set_editable_enabled (bool f)
{
if (f != m_editable_enabled) {
m_editable_enabled = f;
#if defined(HAVE_QT) // @@@
#if defined(HAVE_QT)
if (mp_editable_mode_action.get ()) {
mp_editable_mode_action->set_checked (f);
}

View File

@ -386,6 +386,14 @@ public:
return m_id;
}
/**
* @brief Gets the available menu symbols from all plugins
*
* This does not mean all symbols will be available.
*/
static std::vector<std::string> menu_symbols ();
#if defined(HAVE_QT)
/**
* @brief Creates the menu resources for this plugin
*
@ -395,17 +403,11 @@ public:
*/
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<std::string> menu_symbols ();
/**
* @brief Removes the menu resources associated with this plugin
*/
void remove_menu_items (lay::Dispatcher *dispatcher);
#endif
/**
* @brief Enables this editable part of the plugin
@ -455,10 +457,8 @@ public:
#if defined(HAVE_QT)
private slots:
#else
private:
#endif
void toggle_editable_enabled ();
#endif
private:
int m_id;

View File

@ -31,6 +31,9 @@
#include "layViewObject.h"
#include "layCanvasPlane.h"
#include "layBitmap.h"
#if defined(HAVE_QT)
# include "layDragDropData.h"
#endif
#include "tlException.h"
#include "tlAlgorithm.h"
#include "tlExceptions.h"
@ -44,87 +47,6 @@ namespace lay
// event rather than a single click event:
const int click_tolerance = 5;
// ---------------------------------------------------------------
// Implementation of DragDropDataBase
const char *drag_drop_mime_type ()
{
return "application/klayout-ddd";
}
#if defined(HAVE_QT) // @@@
QMimeData *
DragDropDataBase::to_mime_data () const
{
QMimeData *mimeData = new QMimeData();
mimeData->setData (QString::fromUtf8 (drag_drop_mime_type ()), serialized ());
return mimeData;
}
#endif
// ---------------------------------------------------------------
// Implementation of CellDragDropData
#if defined(HAVE_QT) // @@@
QByteArray
CellDragDropData::serialized () const
{
QByteArray data;
QDataStream stream (&data, QIODevice::WriteOnly);
stream << QString::fromUtf8 ("CellDragDropData");
stream << (quintptr) mp_layout;
stream << (quintptr) mp_library;
stream << m_cell_index;
stream << m_is_pcell;
stream << int (m_pcell_params.size ());
for (std::vector<tl::Variant>::const_iterator i = m_pcell_params.begin (); i != m_pcell_params.end (); ++i) {
stream << tl::to_qstring (i->to_parsable_string ());
}
return data;
}
bool
CellDragDropData::deserialize (const QByteArray &ba)
{
QDataStream stream (const_cast<QByteArray *> (&ba), QIODevice::ReadOnly);
QString tag;
stream >> tag;
if (tag == QString::fromUtf8 ("CellDragDropData")) {
quintptr p = 0;
stream >> p;
mp_layout = reinterpret_cast <const db::Layout *> (p);
stream >> p;
mp_library = reinterpret_cast <const db::Library *> (p);
stream >> m_cell_index;
stream >> m_is_pcell;
m_pcell_params.clear ();
int n = 0;
stream >> n;
while (n-- > 0) {
QString s;
stream >> s;
std::string stl_s = tl::to_string (s);
tl::Extractor ex (stl_s.c_str ());
m_pcell_params.push_back (tl::Variant ());
ex.read (m_pcell_params.back ());
}
return true;
} else {
return false;
}
}
#endif
// ---------------------------------------------------------------
// A helper function to convert a Qt modifier/buttons to klayout buttons
@ -399,9 +321,9 @@ ViewObjectWidget::set_cursor (lay::Cursor::cursor_shape cursor)
void
ViewObjectWidget::set_default_cursor (lay::Cursor::cursor_shape cursor)
{
#if defined(HAVE_QT)
if (cursor != m_default_cursor) {
m_default_cursor = cursor;
#if defined(HAVE_QT)
if (m_cursor == lay::Cursor::none) {
if (m_default_cursor == lay::Cursor::none) {
unsetCursor ();
@ -409,18 +331,16 @@ ViewObjectWidget::set_default_cursor (lay::Cursor::cursor_shape cursor)
setCursor (lay::Cursor::qcursor (m_default_cursor));
}
}
}
#endif
}
}
void
ViewObjectWidget::ensure_entered ()
{
#if defined(HAVE_QT) // @@@
if (! m_mouse_inside) {
enterEvent (0);
send_enter_event ();
}
#endif
}
void
@ -432,7 +352,7 @@ ViewObjectWidget::begin_mouse_event (lay::Cursor::cursor_shape cursor)
void
ViewObjectWidget::end_mouse_event ()
{
#if defined(HAVE_QT) // @@@
#if defined(HAVE_QT)
if (m_cursor == lay::Cursor::none) {
if (m_default_cursor == lay::Cursor::none) {
unsetCursor ();
@ -445,7 +365,347 @@ ViewObjectWidget::end_mouse_event ()
#endif
}
#if defined(HAVE_QT) // @@@
void
ViewObjectWidget::send_key_press_event (unsigned int key, unsigned int buttons)
{
bool done = false;
if (mp_active_service) {
done = (mp_active_service->enabled () && mp_active_service->key_event (key, buttons));
}
if (! done) {
key_event (key, buttons);
}
}
void
ViewObjectWidget::do_mouse_move ()
{
m_in_mouse_move = true;
if (m_mouse_pressed_state &&
(abs (m_mouse_pos.x () - m_mouse_pressed.x ()) > click_tolerance || abs (m_mouse_pos.y () - m_mouse_pressed.y ()) > click_tolerance)) {
begin_mouse_event (lay::Cursor::none);
m_mouse_pressed_state = false;
bool done = false;
db::DPoint p = pixel_to_um (m_mouse_pressed);
for (std::list<ViewService *>::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) {
std::list<ViewService *>::iterator gg = g;
++gg;
done = ((*g)->enabled () && (*g)->mouse_press_event (p, m_mouse_buttons, true));
g = gg;
}
if (! done && mp_active_service) {
done = (mp_active_service->enabled () && mp_active_service->mouse_press_event (p, m_mouse_buttons, true));
}
service_iterator svc = begin_services ();
while (svc != end_services () && !done) {
service_iterator next = svc;
++next;
done = ((*svc)->enabled () && (*svc)->mouse_press_event (p, m_mouse_buttons, false));
svc = next;
}
if (! done) {
mouse_press_event (p, m_mouse_buttons);
}
end_mouse_event ();
}
if (! m_mouse_pressed_state) {
begin_mouse_event (lay::Cursor::none);
bool done = false;
db::DPoint p = pixel_to_um (m_mouse_pos);
for (std::list<ViewService *>::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) {
std::list<ViewService *>::iterator gg = g;
++gg;
done = ((*g)->enabled () && (*g)->mouse_move_event (p, m_mouse_buttons, true));
g = gg;
}
if (! done && mp_active_service) {
done = (mp_active_service->enabled () && mp_active_service->mouse_move_event (p, m_mouse_buttons, true));
}
service_iterator svc = begin_services ();
while (svc != end_services () && !done) {
service_iterator next = svc;
++next;
done = ((*svc)->enabled () && (*svc)->mouse_move_event (p, m_mouse_buttons, false));
svc = next;
}
if (! done) {
mouse_move_event (p, m_mouse_buttons);
}
end_mouse_event ();
}
m_in_mouse_move = false;
}
void
ViewObjectWidget::send_mouse_move_event (const db::DPoint &pt, unsigned int buttons)
{
ensure_entered ();
m_mouse_pos = pt;
m_mouse_buttons = buttons;
do_mouse_move ();
}
void
ViewObjectWidget::send_leave_event ()
{
try {
bool done = false;
for (std::list<ViewService *>::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) {
std::list<ViewService *>::iterator gg = g;
++gg;
done = ((*g)->enabled () && (*g)->leave_event (true));
g = gg;
}
if (! done && mp_active_service) {
done = (mp_active_service->enabled () && mp_active_service->leave_event (true));
}
service_iterator svc = begin_services ();
while (svc != end_services () && !done) {
service_iterator next = svc;
++next;
done = ((*svc)->enabled () && (*svc)->leave_event (false));
svc = next;
}
if (! done) {
leave_event ();
}
end_mouse_event ();
m_mouse_inside = false;
} catch (...) {
m_mouse_inside = false;
throw;
}
}
void
ViewObjectWidget::send_enter_event ()
{
m_mouse_inside = true;
begin_mouse_event ();
bool done = false;
for (std::list<ViewService *>::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) {
std::list<ViewService *>::iterator gg = g;
++gg;
done = ((*g)->enabled () && (*g)->enter_event (true));
g = gg;
}
if (! done && mp_active_service) {
done = (mp_active_service->enabled () && mp_active_service->enter_event (true));
}
service_iterator svc = begin_services ();
while (svc != end_services () && !done) {
service_iterator next = svc;
++next;
done = ((*svc)->enabled () && (*svc)->enter_event (false));
svc = next;
}
if (! done) {
enter_event ();
}
end_mouse_event ();
}
void
ViewObjectWidget::send_mouse_press_event (const db::DPoint &pt, unsigned int buttons)
{
ensure_entered ();
#if defined(HAVE_QT)
setFocus ();
#endif
m_mouse_pos = pt;
m_mouse_pressed = m_mouse_pos;
m_mouse_buttons = buttons;
m_mouse_pressed_state = true;
}
void
ViewObjectWidget::send_mouse_double_clicked_event (const db::DPoint &pt, unsigned int buttons)
{
ensure_entered ();
begin_mouse_event (lay::Cursor::none);
#if defined(HAVE_QT)
setFocus ();
#endif
bool done = false;
m_mouse_pos = pt;
m_mouse_pressed = m_mouse_pos;
m_mouse_pressed_state = false;
db::DPoint p = pixel_to_um (m_mouse_pos);
for (std::list<ViewService *>::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) {
std::list<ViewService *>::iterator gg = g;
++gg;
done = ((*g)->m_enabled && (*g)->mouse_double_click_event (p, buttons, true));
g = gg;
}
if (! done && mp_active_service) {
done = (mp_active_service->enabled () && mp_active_service->mouse_double_click_event (p, buttons, true));
}
service_iterator svc = begin_services ();
while (svc != end_services () && !done) {
service_iterator next = svc;
++next;
done = ((*svc)->enabled () && (*svc)->mouse_double_click_event (p, buttons, false));
svc = next;
}
if (! done) {
mouse_double_click_event (p, buttons);
}
end_mouse_event ();
}
void
ViewObjectWidget::send_mouse_release_event (const db::DPoint &pt, unsigned int /*buttons*/)
{
try {
ensure_entered ();
begin_mouse_event ();
bool done = false;
m_mouse_pos = pt;
db::DPoint p = pixel_to_um (m_mouse_pos);
for (std::list<ViewService *>::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) {
std::list<ViewService *>::iterator gg = g;
++gg;
if (m_mouse_pressed_state) {
done = (*g)->enabled () && (*g)->mouse_click_event (p, m_mouse_buttons, true);
} else {
done = (*g)->enabled () && (*g)->mouse_release_event (p, m_mouse_buttons, true);
}
g = gg;
}
if (! done && mp_active_service && mp_active_service->enabled ()) {
if (m_mouse_pressed_state) {
done = mp_active_service->mouse_click_event (p, m_mouse_buttons, true);
} else {
done = mp_active_service->mouse_release_event (p, m_mouse_buttons, true);
}
}
service_iterator svc = begin_services ();
while (svc != end_services () && !done) {
service_iterator next = svc;
++next;
if ((*svc)->enabled ()) {
if (m_mouse_pressed_state) {
done = (*svc)->mouse_click_event (p, m_mouse_buttons, false);
} else {
done = (*svc)->mouse_release_event (p, m_mouse_buttons, false);
}
}
svc = next;
}
if (! done) {
if (m_mouse_pressed_state) {
mouse_click_event (p, m_mouse_buttons);
} else {
mouse_release_event (p, m_mouse_buttons);
}
}
end_mouse_event ();
m_mouse_pressed_state = false;
} catch (...) {
m_mouse_pressed_state = false;
throw;
}
}
void
ViewObjectWidget::send_wheel_event (int delta, bool horizontal, const db::DPoint &pt, unsigned int buttons)
{
ensure_entered ();
begin_mouse_event ();
db::DPoint p = pixel_to_um (pt);
bool done = false;
for (std::list<ViewService *>::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) {
std::list<ViewService *>::iterator gg = g;
++gg;
done = ((*g)->enabled () && (*g)->wheel_event (delta, horizontal, p, buttons, true));
g = gg;
}
if (! done && mp_active_service) {
done = (mp_active_service->enabled () && mp_active_service->wheel_event (delta, horizontal, p, buttons, true));
}
service_iterator svc = begin_services ();
while (svc != end_services () && !done) {
service_iterator next = svc;
++next;
done = ((*svc)->enabled () && (*svc)->wheel_event (delta, horizontal, p, buttons, false));
svc = next;
}
if (! done) {
wheel_event (delta, horizontal, p, buttons);
}
end_mouse_event ();
}
#if defined(HAVE_QT)
bool
ViewObjectWidget::focusNextPrevChild (bool /*next*/)
{
@ -456,18 +716,8 @@ void
ViewObjectWidget::keyPressEvent (QKeyEvent *e)
{
BEGIN_PROTECTED
unsigned int buttons = qt_to_buttons (Qt::MouseButtons (), e->modifiers ());
bool done = false;
if (mp_active_service) {
done = (mp_active_service->enabled () && mp_active_service->key_event ((unsigned int) e->key(), buttons));
}
if (! done) {
key_event ((unsigned int) e->key (), buttons);
}
send_key_press_event ((unsigned int) e->key (), buttons);
END_PROTECTED
}
@ -586,139 +836,33 @@ void
ViewObjectWidget::mouseMoveEvent (QMouseEvent *e)
{
BEGIN_PROTECTED
ensure_entered ();
m_mouse_pos = db::Point (e->pos ().x (), e->pos ().y ());
m_mouse_buttons = qt_to_buttons (e->buttons (), e->modifiers ());
do_mouse_move ();
END_PROTECTED
}
db::DPoint p;
#if QT_VERSION < 0x60000
p = db::DPoint (e->pos ().x (), e->pos ().y ());
#else
p = db::DPoint (e->position ().x (), e->position ().y ());
#endif
void
ViewObjectWidget::do_mouse_move ()
{
m_in_mouse_move = true;
send_mouse_move_event (p, qt_to_buttons (e->buttons (), e->modifiers ()));
if (m_mouse_pressed_state &&
(abs (m_mouse_pos.x () - m_mouse_pressed.x ()) > click_tolerance || abs (m_mouse_pos.y () - m_mouse_pressed.y ()) > click_tolerance)) {
begin_mouse_event (lay::Cursor::none);
m_mouse_pressed_state = false;
bool done = false;
db::DPoint p = pixel_to_um (m_mouse_pressed);
for (std::list<ViewService *>::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) {
std::list<ViewService *>::iterator gg = g;
++gg;
done = ((*g)->enabled () && (*g)->mouse_press_event (p, m_mouse_buttons, true));
g = gg;
}
if (! done && mp_active_service) {
done = (mp_active_service->enabled () && mp_active_service->mouse_press_event (p, m_mouse_buttons, true));
}
service_iterator svc = begin_services ();
while (svc != end_services () && !done) {
service_iterator next = svc;
++next;
done = ((*svc)->enabled () && (*svc)->mouse_press_event (p, m_mouse_buttons, false));
svc = next;
}
if (! done) {
mouse_press_event (p, m_mouse_buttons);
}
end_mouse_event ();
}
if (! m_mouse_pressed_state) {
begin_mouse_event (lay::Cursor::none);
bool done = false;
db::DPoint p = pixel_to_um (m_mouse_pos);
for (std::list<ViewService *>::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) {
std::list<ViewService *>::iterator gg = g;
++gg;
done = ((*g)->enabled () && (*g)->mouse_move_event (p, m_mouse_buttons, true));
g = gg;
}
if (! done && mp_active_service) {
done = (mp_active_service->enabled () && mp_active_service->mouse_move_event (p, m_mouse_buttons, true));
}
service_iterator svc = begin_services ();
while (svc != end_services () && !done) {
service_iterator next = svc;
++next;
done = ((*svc)->enabled () && (*svc)->mouse_move_event (p, m_mouse_buttons, false));
svc = next;
}
if (! done) {
mouse_move_event (p, m_mouse_buttons);
}
end_mouse_event ();
}
m_in_mouse_move = false;
END_PROTECTED
}
#if defined(HAVE_QT) // @@@
void
ViewObjectWidget::mouseDoubleClickEvent (QMouseEvent *e)
{
BEGIN_PROTECTED
ensure_entered ();
begin_mouse_event (lay::Cursor::none);
setFocus ();
db::DPoint p;
#if QT_VERSION < 0x60000
p = db::DPoint (e->pos ().x (), e->pos ().y ());
#else
p = db::DPoint (e->position ().x (), e->position ().y ());
#endif
bool done = false;
send_mouse_double_clicked_event (p, qt_to_buttons (e->buttons (), e->modifiers ()));
m_mouse_pos = db::Point (e->pos ().x (), e->pos ().y ());
m_mouse_pressed = m_mouse_pos;
m_mouse_pressed_state = false;
unsigned int buttons = qt_to_buttons (e->buttons (), e->modifiers ());
db::DPoint p = pixel_to_um (m_mouse_pos);
for (std::list<ViewService *>::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) {
std::list<ViewService *>::iterator gg = g;
++gg;
done = ((*g)->m_enabled && (*g)->mouse_double_click_event (p, buttons, true));
g = gg;
}
if (! done && mp_active_service) {
done = (mp_active_service->enabled () && mp_active_service->mouse_double_click_event (p, buttons, true));
}
service_iterator svc = begin_services ();
while (svc != end_services () && !done) {
service_iterator next = svc;
++next;
done = ((*svc)->enabled () && (*svc)->mouse_double_click_event (p, buttons, false));
svc = next;
}
if (! done) {
mouse_double_click_event (p, buttons);
}
end_mouse_event ();
END_PROTECTED
}
@ -730,198 +874,75 @@ ViewObjectWidget::enterEvent (QEvent * /*event*/)
#endif
{
BEGIN_PROTECTED
m_mouse_inside = true;
begin_mouse_event ();
bool done = false;
for (std::list<ViewService *>::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) {
std::list<ViewService *>::iterator gg = g;
++gg;
done = ((*g)->enabled () && (*g)->enter_event (true));
g = gg;
}
if (! done && mp_active_service) {
done = (mp_active_service->enabled () && mp_active_service->enter_event (true));
}
service_iterator svc = begin_services ();
while (svc != end_services () && !done) {
service_iterator next = svc;
++next;
done = ((*svc)->enabled () && (*svc)->enter_event (false));
svc = next;
}
if (! done) {
enter_event ();
}
end_mouse_event ();
send_enter_event ();
END_PROTECTED
}
void
void
ViewObjectWidget::leaveEvent (QEvent * /*event*/)
{
BEGIN_PROTECTED
BEGIN_PROTECTED
begin_mouse_event ();
bool done = false;
for (std::list<ViewService *>::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) {
std::list<ViewService *>::iterator gg = g;
++gg;
done = ((*g)->enabled () && (*g)->leave_event (true));
g = gg;
}
if (! done && mp_active_service) {
done = (mp_active_service->enabled () && mp_active_service->leave_event (true));
}
service_iterator svc = begin_services ();
while (svc != end_services () && !done) {
service_iterator next = svc;
++next;
done = ((*svc)->enabled () && (*svc)->leave_event (false));
svc = next;
}
if (! done) {
leave_event ();
}
end_mouse_event ();
END_PROTECTED
m_mouse_inside = false;
}
void
ViewObjectWidget::wheelEvent (QWheelEvent *e)
{
BEGIN_PROTECTED
ensure_entered ();
begin_mouse_event ();
BEGIN_PROTECTED
db::DPoint p;
#if QT_VERSION < 0x60000
int delta = e->delta ();
db::DPoint p = pixel_to_um (db::Point (e->pos ().x (), e->pos ().y ()));
p = db::DPoint (e->pos ().x (), e->pos ().y ());
bool horizontal = (e->orientation () == Qt::Horizontal);
#else
int delta = e->angleDelta ().y ();
db::DPoint p = pixel_to_um (e->position ());
p = db::DPoint (e->position ().x (), e->position ().y ());
bool horizontal = false;
#endif
e->ignore ();
bool done = false;
send_wheel_event (delta, horizontal, p, qt_to_buttons (e->buttons (), e->modifiers ()));
unsigned int buttons = qt_to_buttons (e->buttons (), e->modifiers ());
for (std::list<ViewService *>::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) {
std::list<ViewService *>::iterator gg = g;
++gg;
done = ((*g)->enabled () && (*g)->wheel_event (delta, horizontal, p, buttons, true));
g = gg;
}
if (! done && mp_active_service) {
done = (mp_active_service->enabled () && mp_active_service->wheel_event (delta, horizontal, p, buttons, true));
}
service_iterator svc = begin_services ();
while (svc != end_services () && !done) {
service_iterator next = svc;
++next;
done = ((*svc)->enabled () && (*svc)->wheel_event (delta, horizontal, p, buttons, false));
svc = next;
}
if (! done) {
wheel_event (delta, horizontal, p, buttons);
}
end_mouse_event ();
END_PROTECTED
}
void
ViewObjectWidget::mousePressEvent (QMouseEvent *e)
{
ensure_entered ();
setFocus ();
BEGIN_PROTECTED
m_mouse_pos = db::Point (e->pos ().x (), e->pos ().y ());
m_mouse_pressed = m_mouse_pos;
db::DPoint p;
#if QT_VERSION < 0x60000
p = db::DPoint (e->pos ().x (), e->pos ().y ());
#else
p = db::DPoint (e->position ().x (), e->position ().y ());
#endif
m_mouse_buttons = qt_to_buttons (e->buttons (), e->modifiers ());
m_mouse_pressed_state = true;
send_mouse_press_event (p, qt_to_buttons (e->buttons (), e->modifiers ()));
END_PROTECTED
}
void
ViewObjectWidget::mouseReleaseEvent (QMouseEvent *e)
{
BEGIN_PROTECTED
ensure_entered ();
begin_mouse_event ();
bool done = false;
db::DPoint p;
#if QT_VERSION < 0x60000
p = db::DPoint (e->pos ().x (), e->pos ().y ());
#else
p = db::DPoint (e->position ().x (), e->position ().y ());
#endif
m_mouse_pos = db::Point (e->pos ().x (), e->pos ().y ());
db::DPoint p = pixel_to_um (m_mouse_pos);
send_mouse_press_event (p, qt_to_buttons (e->buttons (), e->modifiers ()));
for (std::list<ViewService *>::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) {
std::list<ViewService *>::iterator gg = g;
++gg;
if (m_mouse_pressed_state) {
done = (*g)->enabled () && (*g)->mouse_click_event (p, m_mouse_buttons, true);
} else {
done = (*g)->enabled () && (*g)->mouse_release_event (p, m_mouse_buttons, true);
}
g = gg;
}
if (! done && mp_active_service && mp_active_service->enabled ()) {
if (m_mouse_pressed_state) {
done = mp_active_service->mouse_click_event (p, m_mouse_buttons, true);
} else {
done = mp_active_service->mouse_release_event (p, m_mouse_buttons, true);
}
}
service_iterator svc = begin_services ();
while (svc != end_services () && !done) {
service_iterator next = svc;
++next;
if ((*svc)->enabled ()) {
if (m_mouse_pressed_state) {
done = (*svc)->mouse_click_event (p, m_mouse_buttons, false);
} else {
done = (*svc)->mouse_release_event (p, m_mouse_buttons, false);
}
}
svc = next;
}
if (! done) {
if (m_mouse_pressed_state) {
mouse_click_event (p, m_mouse_buttons);
} else {
mouse_release_event (p, m_mouse_buttons);
}
}
end_mouse_event ();
END_PROTECTED
m_mouse_pressed_state = false;
}
#endif
void

View File

@ -73,138 +73,9 @@ class Bitmap;
class PixelBuffer;
class BitmapBuffer;
LAYBASIC_PUBLIC const char *drag_drop_mime_type ();
/**
* @brief A helper class required to store the drag/drop data
*
* Drag/drop data is basically a collection of key/value pairs.
* A category string is provided to identify the kind of data.
*/
class LAYBASIC_PUBLIC DragDropDataBase
{
public:
/**
* @brief Default constructor
*/
DragDropDataBase () { }
/**
* @brief Dtor
*/
virtual ~DragDropDataBase () { }
#if defined(HAVE_QT) // @@@
/**
* @brief Serializes itself to an QByteArray
*/
virtual QByteArray serialized () const = 0;
/**
* @brief Try deserialization from an QByteArray
*
* Returns false, if deserialization failed.
*/
virtual bool deserialize (const QByteArray &ba) = 0;
/**
* @brief Create a QMimeData object from the object
*/
QMimeData *to_mime_data () const;
#if defined(HAVE_QT)
class DragDropDataBase;
#endif
};
/**
* @brief Drag/drop data for a cell
*/
class LAYBASIC_PUBLIC CellDragDropData
: public DragDropDataBase
{
public:
/**
* @brief Default ctor
*/
CellDragDropData ()
: mp_layout (0), mp_library (0), m_cell_index (0), m_is_pcell (false)
{
// .. nothing yet ..
}
/**
* @brief Specifies drag & drop of a cell
*
* @param layout the layout where the cell lives in
* @param cell_index The index of the cell
*/
CellDragDropData (const db::Layout *layout, const db::Library *library, db::cell_index_type cell_or_pcell_index, bool is_pcell, const std::vector<tl::Variant> &pcell_params = std::vector<tl::Variant> ())
: mp_layout (layout), mp_library (library), m_cell_index (cell_or_pcell_index), m_is_pcell (is_pcell), m_pcell_params (pcell_params)
{
// .. nothing yet ..
}
/**
* @brief Gets the layout object where the cell lives in
*/
const db::Layout *layout () const
{
return mp_layout;
}
/**
* @brief Gets the layout object where the cell lives in
*/
const db::Library *library () const
{
return mp_library;
}
/**
* @brief PCell parameters
*/
const std::vector<tl::Variant> &pcell_params () const
{
return m_pcell_params;
}
/**
* @brief Gets the index of the cell
*/
db::cell_index_type cell_index () const
{
return m_cell_index;
}
/**
* @brief Gets a value indicating whether the cell is a pcell
*/
bool is_pcell () const
{
return m_is_pcell;
}
#if defined(HAVE_QT) // @@@
/**
* @brief Serializes itself to an QByteArray
*/
virtual QByteArray serialized () const;
/**
* @brief Try deserialization from an QByteArray
*
* Returns false, if deserialization failed.
*/
bool deserialize (const QByteArray &ba);
#endif
private:
const db::Layout *mp_layout;
const db::Library *mp_library;
db::cell_index_type m_cell_index;
bool m_is_pcell;
std::vector<tl::Variant> m_pcell_params;
};
/**
* @brief A view service
@ -243,6 +114,7 @@ public:
*/
virtual bool key_event (unsigned int /*key*/, unsigned int /*buttons*/) { return false; }
#if defined(HAVE_QT)
/**
* @brief The drag enter event
*
@ -267,6 +139,7 @@ public:
* @brief The drop event
*/
virtual bool drop_event (const db::DPoint & /*p*/, const DragDropDataBase * /*data*/) { return false; }
#endif
/**
* @brief Mouse press event handler
@ -914,6 +787,7 @@ public:
*/
virtual void key_event (unsigned int /*key*/, unsigned int /*buttons*/) { }
#if defined(HAVE_QT)
/**
* @brief The drag enter event
*
@ -938,6 +812,7 @@ public:
* @brief The drop event
*/
virtual bool drop_event (const db::DPoint & /*p*/, const DragDropDataBase * /*data*/) { return false; }
#endif
/**
* @brief Remaining mouse double click event handler
@ -1041,7 +916,7 @@ public:
/**
* @brief Gets the current mouse position
*/
db::Point mouse_position () const
db::DPoint mouse_position () const
{
return m_mouse_pos;
}
@ -1081,8 +956,48 @@ public:
bool image_updated ();
#endif
/**
* @brief External entry point for key press event generation
*/
void send_key_press_event (unsigned int key, unsigned int buttons);
/**
* @brief External entry point for mouse move event generation
*/
void send_mouse_move_event (const db::DPoint &pt, unsigned int buttons);
/**
* @brief External entry point for leave event generation
*/
void send_leave_event ();
/**
* @brief External entry point for enter event generation
*/
void send_enter_event ();
/**
* @brief External entry point for mouse button press event generation
*/
void send_mouse_press_event (const db::DPoint &pt, unsigned int buttons);
/**
* @brief External entry point for mouse button double-click event generation
*/
void send_mouse_double_clicked_event (const db::DPoint &pt, unsigned int buttons);
/**
* @brief External entry point for mouse button release event generation
*/
void send_mouse_release_event (const db::DPoint &pt, unsigned int buttons);
/**
* @brief External entry point for mouse wheel event generation
*/
void send_wheel_event (int delta, bool horizontal, const db::DPoint &pt, unsigned int buttons);
protected:
#if defined(HAVE_QT) // @@@
#if defined(HAVE_QT)
/**
* @brief Qt focus event handler
*/
@ -1187,8 +1102,8 @@ private:
bool m_needs_update_bg;
lay::ViewService *mp_active_service;
db::DCplxTrans m_trans;
db::Point m_mouse_pos;
db::Point m_mouse_pressed;
db::DPoint m_mouse_pos;
db::DPoint m_mouse_pressed;
bool m_mouse_pressed_state;
unsigned int m_mouse_buttons;
bool m_in_mouse_move;

View File

@ -104,6 +104,7 @@ DEFINES += MAKE_LAYBASIC_LIBRARY
layConfigurationDialog.cc \
layCursor.cc \
layDialogs.cc \
layDragDropData.cc \
layEditLineStyleWidget.cc \
layEditLineStylesForm.cc \
layEditStippleWidget.cc \
@ -173,6 +174,7 @@ DEFINES += MAKE_LAYBASIC_LIBRARY
layColor.h \
layCursor.h \
layDialogs.h \
layDragDropData.h \
layEditLineStyleWidget.h \
layEditLineStylesForm.h \
layEditStippleWidget.h \

View File

@ -163,14 +163,14 @@ TEST(4)
tl::msleep (250);
lay::PixelBuffer img = lv.get_screenshot_pb ();
EXPECT_EQ (img.width (), 42);
EXPECT_EQ (img.height (), 117);
EXPECT_EQ ((int) img.width (), 42);
EXPECT_EQ ((int) img.height (), 117);
lv.resize (142, 217);
img = lv.get_screenshot_pb ();
EXPECT_EQ (img.width (), 142);
EXPECT_EQ (img.height (), 217);
EXPECT_EQ ((int) img.width (), 142);
EXPECT_EQ ((int) img.height (), 217);
}
#if defined(HAVE_PNG)

View File

@ -20,8 +20,6 @@
*/
#if defined(HAVE_QT) // @@@
#include "layNetlistBrowserTreeModel.h"
#include "tlUnitTest.h"
@ -106,4 +104,3 @@ TEST (2)
EXPECT_EQ (model->parent (model->index (1, 0, inv2PairIndex)).internalId () == inv2PairIndex.internalId (), true);
}
#endif

View File

@ -16,11 +16,17 @@ SOURCES = \
layPixelBufferTests.cc \
layLayoutViewTests.cc \
layRenderer.cc \
layNetlistBrowserModelTests.cc \
layNetlistBrowserTreeModelTests.cc \
layAbstractMenuTests.cc \
laySnapTests.cc
!equals(HAVE_QT, "0") {
SOURCES += \
layNetlistBrowserModelTests.cc \
layNetlistBrowserTreeModelTests.cc \
}
INCLUDEPATH += $$TL_INC $$LAYBASIC_INC $$DB_INC $$GSI_INC $$OUT_PWD/../laybasic
DEPENDPATH += $$TL_INC $$LAYBASIC_INC $$DB_INC $$GSI_INC $$OUT_PWD/../laybasic