46 extern_cfg (bool, gl_axes); |
46 extern_cfg (bool, gl_axes); |
47 |
47 |
48 const QColor g_GroupBackgrounds[] = { |
48 const QColor g_GroupBackgrounds[] = { |
49 QColor (0, 192, 255), // blue |
49 QColor (0, 192, 255), // blue |
50 QColor (144, 255, 0), // green |
50 QColor (144, 255, 0), // green |
|
51 QColor (255, 128, 0), // orange |
|
52 QColor (255, 255, 0), // yellow |
51 QColor (160, 64, 255), // purple |
53 QColor (160, 64, 255), // purple |
52 QColor (255, 128, 0), // orange |
54 QColor (0, 255, 160), // emerald |
53 }; |
55 }; |
54 |
56 |
55 const ushort g_numGroups = 2; |
57 const ushort g_numGroups = 2; |
56 |
58 |
57 // ============================================================================= |
59 // ============================================================================= |
201 addMenuAction ("copy"); // Copy |
203 addMenuAction ("copy"); // Copy |
202 addMenuAction ("paste"); // Paste |
204 addMenuAction ("paste"); // Paste |
203 addMenuAction ("del"); // Delete |
205 addMenuAction ("del"); // Delete |
204 menu->addSeparator (); // ----- |
206 menu->addSeparator (); // ----- |
205 |
207 |
206 for (uchar i = 0; i < LDObject::NumGroups; ++i) |
|
207 addMenuAction (fmt ("group%c", 'A' + i)); // Group * |
|
208 |
|
209 addMenuAction ("ungroup"); // Ungroup |
|
210 menu->addSeparator (); // ----- |
|
211 addMenuAction ("selectAll"); // Select All |
208 addMenuAction ("selectAll"); // Select All |
212 addMenuAction ("selectByColor"); // Select by Color |
209 addMenuAction ("selectByColor"); // Select by Color |
213 addMenuAction ("selectByType"); // Select by Type |
210 addMenuAction ("selectByType"); // Select by Type |
214 |
211 |
|
212 initMenu ("&Groups"); |
215 for (uchar i = 0; i < LDObject::NumGroups; ++i) |
213 for (uchar i = 0; i < LDObject::NumGroups; ++i) |
216 addMenuAction (fmt ("selGroup%c", 'A' + i)); // Select Group * |
214 addMenuAction (fmt ("group%c", 'A' + i)); // Group * |
|
215 |
|
216 menu->addSeparator (); // ----- |
|
217 addMenuAction ("ungroup"); // Ungroup |
|
218 menu->addSeparator (); // ----- |
|
219 for (uchar i = 0; i < LDObject::NumGroups; ++i) |
|
220 addMenuAction (fmt ("selGroup%c", 'A' + i)); // Select Group * |
217 |
221 |
218 initMenu ("&Tools"); |
222 initMenu ("&Tools"); |
219 addMenuAction ("setColor"); // Set Color |
223 addMenuAction ("setColor"); // Set Color |
220 addMenuAction ("invert"); // Invert |
224 addMenuAction ("invert"); // Invert |
221 addMenuAction ("inlineContents"); // Inline |
225 addMenuAction ("inlineContents"); // Inline |
917 // ============================================================================= |
921 // ============================================================================= |
918 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
922 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
919 // ============================================================================= |
923 // ============================================================================= |
920 void ForgeWindow::spawnContextMenu (const QPoint pos) { |
924 void ForgeWindow::spawnContextMenu (const QPoint pos) { |
921 const bool single = (g_win->sel ().size () == 1); |
925 const bool single = (g_win->sel ().size () == 1); |
|
926 LDObject* singleObj = (single) ? g_win->sel ()[0] : null; |
922 |
927 |
923 QMenu* contextMenu = new QMenu; |
928 QMenu* contextMenu = new QMenu; |
924 |
929 |
925 if (single) { |
930 if (single && singleObj->getType () != LDObject::Empty) { |
926 contextMenu->addAction (findAction ("editObject")); |
931 contextMenu->addAction (findAction ("editObject")); |
927 contextMenu->addSeparator (); |
932 contextMenu->addSeparator (); |
928 } |
933 } |
929 |
934 |
930 contextMenu->addAction (findAction ("cut")); |
935 contextMenu->addAction (findAction ("cut")); |
962 (QMessageBox::Yes | QMessageBox::No), QMessageBox::No) == QMessageBox::Yes; |
967 (QMessageBox::Yes | QMessageBox::No), QMessageBox::No) == QMessageBox::Yes; |
963 } |
968 } |
964 |
969 |
965 // ============================================================================= |
970 // ============================================================================= |
966 void critical (str msg) { |
971 void critical (str msg) { |
967 QMessageBox::critical (g_win, APPNAME ": Critical Error", msg, |
972 QMessageBox::critical (g_win, "Critical Error", msg, |
968 (QMessageBox::Close), QMessageBox::Close); |
973 (QMessageBox::Close), QMessageBox::Close); |
969 } |
974 } |
970 |
975 |
971 // ============================================================================= |
976 // ============================================================================= |
972 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
977 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
973 // ============================================================================= |
978 // ============================================================================= |
974 // Print to message log |
979 // Print to message log |
|
980 // TODO: I don't think that the message log being a widget in the window |
|
981 // is a very good idea... maybe this should log into the renderer? Or into |
|
982 // another dialog that can be popped up? |
975 void ForgeWindow::logVA (LogType type, const char* fmtstr, va_list va) { |
983 void ForgeWindow::logVA (LogType type, const char* fmtstr, va_list va) { |
976 return; // FIXME: crashes for some reason o_O |
984 (void) type; |
977 |
985 (void) fmtstr; |
978 char* buf = vdynformat (fmtstr, va, 128); |
986 (void) va; |
979 str zText (buf); |
|
980 delete[] buf; |
|
981 |
|
982 // Log it to standard output |
|
983 printf ("%s", zText.chars ()); |
|
984 |
|
985 // Replace some things out with HTML entities |
|
986 zText.replace ("<", "<"); |
|
987 zText.replace (">", ">"); |
|
988 zText.replace ("\n", "<br />"); |
|
989 |
|
990 str& log = m_msglogHTML; |
|
991 |
|
992 switch (type) { |
|
993 case LOG_Normal: |
|
994 log.append (zText); |
|
995 break; |
|
996 |
|
997 case LOG_Error: |
|
998 log.appendformat ("<span style=\"color: #F8F8F8; background-color: #800\"><b>[ERROR]</b> %s</span>", |
|
999 zText.chars()); |
|
1000 break; |
|
1001 |
|
1002 case LOG_Warning: |
|
1003 log.appendformat ("<span style=\"color: #C50\"><b>[WARNING]</b> %s</span>", |
|
1004 zText.chars()); |
|
1005 break; |
|
1006 |
|
1007 case LOG_Dev: |
|
1008 #ifndef RELEASE |
|
1009 log.appendformat ("<span style=\"color: #0AC\"><b>[DEV]</b> %s</span>", |
|
1010 zText.chars()); |
|
1011 #endif // RELEASE |
|
1012 break; |
|
1013 } |
|
1014 |
|
1015 m_msglog->setHtml (log); |
|
1016 } |
987 } |
1017 |
988 |
1018 // ============================================================================= |
989 // ============================================================================= |
1019 QAction* findAction (str name) { |
990 QAction* findAction (str name) { |
1020 for (actionmeta& meta : g_ActionMeta) |
991 for (actionmeta& meta : g_ActionMeta) |