gui_actions.cpp

changeset 170
2247a32e63a8
parent 168
96691a009dff
child 172
a65547b84ef8
--- a/gui_actions.cpp	Tue May 07 00:22:01 2013 +0300
+++ b/gui_actions.cpp	Tue May 07 01:15:31 2013 +0300
@@ -170,13 +170,13 @@
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 MAKE_ACTION (about, "About " APPNAME, "ldforge",
-	"Shows information about " APPNAME ".", CTRL (F1))
+	"Shows information about " APPNAME ".", (0))
 {
 	AboutDialog dlg;
 	dlg.exec ();
 }
 
-MAKE_ACTION (aboutQt, "About Qt", "qt", "Shows information about Qt.", CTRL_SHIFT (F1)) {
+MAKE_ACTION (aboutQt, "About Qt", "qt", "Shows information about Qt.", (0)) {
 	QMessageBox::aboutQt (g_win);
 }
 
@@ -405,6 +405,67 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
+void setGroup (const LDObject::Group group) {
+	for (LDObject* obj : g_win->sel ())
+		obj->setGroup (group);
+	
+	g_win->refresh ();
+}
+
+// =============================================================================
+void selGroup (const LDObject::Group group) {
+	for (LDObject* obj : g_curfile->m_objs) {
+		if (obj->group () != group)
+			continue; // wrong group
+		
+		bool selected = false;
+		for (LDObject* selobj : g_win->sel ()) {
+			if (selobj == obj) {
+				selected = true;
+				break;
+			}
+		}
+		
+		if (selected)
+			continue; // already selected
+		
+		g_win->sel ().push_back (obj);
+	}
+	
+	g_win->refresh ();
+}
+
+#define GROUP_ACTION(N, KEY) \
+	MAKE_ACTION (group##N, "Group " #N, "group", "Set group of selected objects to " #N, CTRL_SHIFT (KEY)) { \
+		setGroup (LDObject::N); \
+	} \
+	\
+	MAKE_ACTION (selGroup##N, "Select Group " #N, "group", "Select the contents of group " #N, SHIFT (F##KEY)) { \
+		selGroup (LDObject::N); \
+	}
+
+GROUP_ACTION (A, 1)
+GROUP_ACTION (B, 2)
+GROUP_ACTION (C, 3)
+GROUP_ACTION (D, 4)
+
+MAKE_ACTION (ungroup, "Ungroup", "ungroup", "Unset the group of selected objects", CTRL_SHIFT (0)) {
+	setGroup (LDObject::NoGroup);
+}
+
+// =============================================================================
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+// =============================================================================
+MAKE_ACTION (visibility, "Toggle Visibility", "visibility", "Toggles visibility/hiding on objects.", (0)) {
+	for (LDObject* obj : g_win->sel ())
+		obj->setHidden (!obj->hidden ());
+	
+	g_win->refresh ();
+}
+
+// =============================================================================
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+// =============================================================================
 // Debug things
 #ifndef RELEASE
 MAKE_ACTION (addTestQuad, "Add Test Quad", "add-quad", "Adds a test quad.", (0)) {

mercurial