gui.cpp

changeset 170
2247a32e63a8
parent 169
f562323760a2
child 172
a65547b84ef8
equal deleted inserted replaced
169:f562323760a2 170:2247a32e63a8
200 addMenuAction ("cut"); // Cut 200 addMenuAction ("cut"); // Cut
201 addMenuAction ("copy"); // Copy 201 addMenuAction ("copy"); // Copy
202 addMenuAction ("paste"); // Paste 202 addMenuAction ("paste"); // Paste
203 addMenuAction ("del"); // Delete 203 addMenuAction ("del"); // Delete
204 menu->addSeparator (); // ----- 204 menu->addSeparator (); // -----
205
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 (); // -----
205 addMenuAction ("selectAll"); // Select All 211 addMenuAction ("selectAll"); // Select All
206 addMenuAction ("selectByColor"); // Select by Color 212 addMenuAction ("selectByColor"); // Select by Color
207 addMenuAction ("selectByType"); // Select by Type 213 addMenuAction ("selectByType"); // Select by Type
208 menu->addSeparator (); // -----
209 214
210 for (uchar i = 0; i < LDObject::NumGroups; ++i) 215 for (uchar i = 0; i < LDObject::NumGroups; ++i)
211 addMenuAction (fmt ("group%c", 'A' + i)); // Group * 216 addMenuAction (fmt ("selGroup%c", 'A' + i)); // Select Group *
212 addMenuAction ("groupNone"); // No Group
213 217
214 initMenu ("&Tools"); 218 initMenu ("&Tools");
215 addMenuAction ("setColor"); // Set Color 219 addMenuAction ("setColor"); // Set Color
216 addMenuAction ("invert"); // Invert 220 addMenuAction ("invert"); // Invert
217 addMenuAction ("inlineContents"); // Inline 221 addMenuAction ("inlineContents"); // Inline
220 addMenuAction ("setContents"); // Set Contents 224 addMenuAction ("setContents"); // Set Contents
221 addMenuAction ("makeBorders"); // Make Borders 225 addMenuAction ("makeBorders"); // Make Borders
222 addMenuAction ("makeCornerVerts"); // Make Corner Vertices 226 addMenuAction ("makeCornerVerts"); // Make Corner Vertices
223 addMenuAction ("roundCoords"); // Round Coordinates 227 addMenuAction ("roundCoords"); // Round Coordinates
224 addMenuAction ("uncolorize"); // Uncolorize 228 addMenuAction ("uncolorize"); // Uncolorize
229 addMenuAction ("visibility"); // Toggle Visibility
225 230
226 // Move menu 231 // Move menu
227 initMenu ("&Move"); 232 initMenu ("&Move");
228 addMenuAction ("moveUp"); // Move Up 233 addMenuAction ("moveUp"); // Move Up
229 addMenuAction ("moveDown"); // Move Down 234 addMenuAction ("moveDown"); // Move Down
392 addToolBarAction ("makeBorders"); 397 addToolBarAction ("makeBorders");
393 addToolBarAction ("makeCornerVerts"); 398 addToolBarAction ("makeCornerVerts");
394 addToolBarAction ("roundCoords"); 399 addToolBarAction ("roundCoords");
395 addToolBarAction ("screencap"); 400 addToolBarAction ("screencap");
396 addToolBarAction ("uncolorize"); 401 addToolBarAction ("uncolorize");
402 addToolBarAction ("visibility");
397 403
398 initSingleToolBar ("External Programs"); 404 initSingleToolBar ("External Programs");
399 addToolBarAction ("ytruder"); 405 addToolBarAction ("ytruder");
400 406
401 initSingleToolBar ("Groups"); 407 initSingleToolBar ("Groups");
410 btn->setStyleSheet (fmt ("QToolButton { background-color: \"#%.2X%.2X%.2X\"; }", 416 btn->setStyleSheet (fmt ("QToolButton { background-color: \"#%.2X%.2X%.2X\"; }",
411 col.red (), col.green (), col.blue ())); 417 col.red (), col.green (), col.blue ()));
412 g_CurrentToolBar->addWidget (btn); 418 g_CurrentToolBar->addWidget (btn);
413 } 419 }
414 420
415 addToolBarAction ("groupNone"); 421 addToolBarAction ("ungroup");
416 updateToolBars (); 422 updateToolBars ();
417 } 423 }
418 424
419 // ============================================================================= 425 // =============================================================================
420 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 426 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
568 g_bSelectionLocked = true; 574 g_bSelectionLocked = true;
569 575
570 m_objList->clear (); 576 m_objList->clear ();
571 577
572 for (LDObject* obj : g_curfile->m_objs) { 578 for (LDObject* obj : g_curfile->m_objs) {
573 str zText; 579 str descr;
574 switch (obj->getType ()) { 580 switch (obj->getType ()) {
575 case LDObject::Comment: 581 case LDObject::Comment:
576 zText = static_cast<LDComment*> (obj)->text.chars(); 582 descr = static_cast<LDComment*> (obj)->text.chars();
577 583
578 // Remove leading whitespace 584 // Remove leading whitespace
579 while (~zText && zText[0] == ' ') 585 while (~descr && descr[0] == ' ')
580 zText -= -1; 586 descr -= -1;
581 break; 587 break;
582 588
583 case LDObject::Empty: 589 case LDObject::Empty:
584 break; // leave it empty 590 break; // leave it empty
585 591
586 case LDObject::Line: 592 case LDObject::Line:
587 { 593 {
588 LDLine* line = static_cast<LDLine*> (obj); 594 LDLine* line = static_cast<LDLine*> (obj);
589 zText.format ("%s, %s", 595 descr.format ("%s, %s",
590 line->vaCoords[0].stringRep (true).chars(), 596 line->vaCoords[0].stringRep (true).chars(),
591 line->vaCoords[1].stringRep (true).chars()); 597 line->vaCoords[1].stringRep (true).chars());
592 } 598 }
593 break; 599 break;
594 600
595 case LDObject::Triangle: 601 case LDObject::Triangle:
596 { 602 {
597 LDTriangle* triangle = static_cast<LDTriangle*> (obj); 603 LDTriangle* triangle = static_cast<LDTriangle*> (obj);
598 zText.format ("%s, %s, %s", 604 descr.format ("%s, %s, %s",
599 triangle->vaCoords[0].stringRep (true).chars(), 605 triangle->vaCoords[0].stringRep (true).chars(),
600 triangle->vaCoords[1].stringRep (true).chars(), 606 triangle->vaCoords[1].stringRep (true).chars(),
601 triangle->vaCoords[2].stringRep (true).chars()); 607 triangle->vaCoords[2].stringRep (true).chars());
602 } 608 }
603 break; 609 break;
604 610
605 case LDObject::Quad: 611 case LDObject::Quad:
606 { 612 {
607 LDQuad* quad = static_cast<LDQuad*> (obj); 613 LDQuad* quad = static_cast<LDQuad*> (obj);
608 zText.format ("%s, %s, %s, %s", 614 descr.format ("%s, %s, %s, %s",
609 quad->vaCoords[0].stringRep (true).chars(), 615 quad->vaCoords[0].stringRep (true).chars(),
610 quad->vaCoords[1].stringRep (true).chars(), 616 quad->vaCoords[1].stringRep (true).chars(),
611 quad->vaCoords[2].stringRep (true).chars(), 617 quad->vaCoords[2].stringRep (true).chars(),
612 quad->vaCoords[3].stringRep (true).chars()); 618 quad->vaCoords[3].stringRep (true).chars());
613 } 619 }
614 break; 620 break;
615 621
616 case LDObject::CondLine: 622 case LDObject::CondLine:
617 { 623 {
618 LDCondLine* line = static_cast<LDCondLine*> (obj); 624 LDCondLine* line = static_cast<LDCondLine*> (obj);
619 zText.format ("%s, %s, %s, %s", 625 descr.format ("%s, %s, %s, %s",
620 line->vaCoords[0].stringRep (true).chars(), 626 line->vaCoords[0].stringRep (true).chars(),
621 line->vaCoords[1].stringRep (true).chars(), 627 line->vaCoords[1].stringRep (true).chars(),
622 line->vaCoords[2].stringRep (true).chars(), 628 line->vaCoords[2].stringRep (true).chars(),
623 line->vaCoords[3].stringRep (true).chars()); 629 line->vaCoords[3].stringRep (true).chars());
624 } 630 }
625 break; 631 break;
626 632
627 case LDObject::Gibberish: 633 case LDObject::Gibberish:
628 zText.format ("ERROR: %s", 634 descr.format ("ERROR: %s",
629 static_cast<LDGibberish*> (obj)->zContents.chars()); 635 static_cast<LDGibberish*> (obj)->zContents.chars());
630 break; 636 break;
631 637
632 case LDObject::Vertex: 638 case LDObject::Vertex:
633 zText.format ("%s", static_cast<LDVertex*> (obj)->vPosition.stringRep (true).chars()); 639 descr.format ("%s", static_cast<LDVertex*> (obj)->vPosition.stringRep (true).chars());
634 break; 640 break;
635 641
636 case LDObject::Subfile: 642 case LDObject::Subfile:
637 { 643 {
638 LDSubfile* ref = static_cast<LDSubfile*> (obj); 644 LDSubfile* ref = static_cast<LDSubfile*> (obj);
639 645
640 zText.format ("%s %s, (", 646 descr.format ("%s %s, (",
641 ref->zFileName.chars(), ref->vPosition.stringRep (true).chars()); 647 ref->zFileName.chars(), ref->vPosition.stringRep (true).chars());
642 648
643 for (short i = 0; i < 9; ++i) 649 for (short i = 0; i < 9; ++i)
644 zText.appendformat ("%s%s", 650 descr.appendformat ("%s%s",
645 ftoa (ref->mMatrix[i]).chars(), 651 ftoa (ref->mMatrix[i]).chars(),
646 (i != 8) ? " " : ""); 652 (i != 8) ? " " : "");
647 653
648 zText += ')'; 654 descr += ')';
649 } 655 }
650 break; 656 break;
651 657
652 case LDObject::BFC: 658 case LDObject::BFC:
653 { 659 {
654 LDBFC* bfc = static_cast<LDBFC*> (obj); 660 LDBFC* bfc = static_cast<LDBFC*> (obj);
655 zText = LDBFC::statements[bfc->type]; 661 descr = LDBFC::statements[bfc->type];
656 } 662 }
657 break; 663 break;
658 664
659 case LDObject::Radial: 665 case LDObject::Radial:
660 { 666 {
661 LDRadial* pRad = static_cast<LDRadial*> (obj); 667 LDRadial* pRad = static_cast<LDRadial*> (obj);
662 zText.format ("%d / %d %s", pRad->dSegments, pRad->dDivisions, pRad->radialTypeName()); 668 descr.format ("%d / %d %s", pRad->dSegments, pRad->dDivisions, pRad->radialTypeName());
663 669
664 if (pRad->eRadialType == LDRadial::Ring || pRad->eRadialType == LDRadial::Cone) 670 if (pRad->eRadialType == LDRadial::Ring || pRad->eRadialType == LDRadial::Cone)
665 zText.appendformat (" %d", pRad->dRingNum); 671 descr.appendformat (" %d", pRad->dRingNum);
666 672
667 zText.appendformat (" %s", pRad->vPosition.stringRep (true).chars ()); 673 descr.appendformat (" %s", pRad->vPosition.stringRep (true).chars ());
668 } 674 }
669 break; 675 break;
670 676
671 default: 677 default:
672 zText = g_saObjTypeNames[obj->getType ()]; 678 descr = g_saObjTypeNames[obj->getType ()];
673 break; 679 break;
674 } 680 }
675 681
676 QListWidgetItem* item = new QListWidgetItem (zText.chars()); 682 // Put it into brackets if it's hidden
683 if (obj->hidden ()) {
684 str copy = descr.chars ();
685 descr.format ("[[ %s ]]", copy.chars ());
686 }
687
688 QListWidgetItem* item = new QListWidgetItem (descr.chars());
677 item->setIcon (getIcon (g_saObjTypeIcons[obj->getType ()])); 689 item->setIcon (getIcon (g_saObjTypeIcons[obj->getType ()]));
678 690
679 // Color gibberish orange on red so it stands out. 691 // Color gibberish orange on red so it stands out.
680 if (obj->getType() == LDObject::Gibberish) { 692 if (obj->getType() == LDObject::Gibberish) {
681 item->setBackground (QColor ("#AA0000")); 693 item->setBackground (QColor ("#AA0000"));

mercurial