[Igarden-commit] Garden/source/PlanTool ToolPalette.h, 1.10.2.1, 1.10.2.2 ToolPalette.cpp, 1.20.2.2
Status: Beta
Brought to you by:
jlbedell
|
From: Jeffrey B. <jlb...@us...> - 2007-02-10 18:32:56
|
Update of /cvsroot/igarden/Garden/source/PlanTool In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv19062 Modified Files: Tag: Release_branch_v1 ToolPalette.h ToolPalette.cpp Log Message: Reorganize the tool palette to split off drawing, placement, and planting bed tools Index: ToolPalette.h =================================================================== RCS file: /cvsroot/igarden/Garden/source/PlanTool/ToolPalette.h,v retrieving revision 1.10.2.1 retrieving revision 1.10.2.2 diff -C2 -d -r1.10.2.1 -r1.10.2.2 *** ToolPalette.h 20 Jan 2007 15:50:13 -0000 1.10.2.1 --- ToolPalette.h 10 Feb 2007 18:32:53 -0000 1.10.2.2 *************** *** 77,81 **** void DrawOnCanvas(PlanView * view); void PickTool(PlanView*view, Int32 id); ! void AddTool(PlanTool * tool, UInt32 index); void PickPathTool(PlanView*view, Int32 id); void AddPathTool(PathTool * tool, Int32 index); --- 77,82 ---- void DrawOnCanvas(PlanView * view); void PickTool(PlanView*view, Int32 id); ! void PickPathElementTool( PlanView*view, Int32 id ); ! void AddTool(PlanTool *tool); void PickPathTool(PlanView*view, Int32 id); void AddPathTool(PathTool * tool, Int32 index); *************** *** 104,111 **** --- 105,115 ---- XGDynArray<PathTool*> _pathTools; XGDynArray<paletteEntry_t> _planTools; + XGDynArray<paletteEntry_t> _pathElementTools; XGPaletteView* _planControls; + XGPaletteView* _pathElementControls; XGPaletteView* _pathControls; PlanTool* _currentPlanTool; long _currentToolID; + bool _currentToolIsPathElement; PathTool* _currentPathTool; XGSDynArray<toolLookup_t> _toolLookup; Index: ToolPalette.cpp =================================================================== RCS file: /cvsroot/igarden/Garden/source/PlanTool/ToolPalette.cpp,v retrieving revision 1.20.2.2 retrieving revision 1.20.2.3 diff -C2 -d -r1.20.2.2 -r1.20.2.3 *** ToolPalette.cpp 28 Jan 2007 03:55:42 -0000 1.20.2.2 --- ToolPalette.cpp 10 Feb 2007 18:32:53 -0000 1.20.2.3 *************** *** 56,59 **** --- 56,60 ---- const long kPlanToolsViewID = 5; const long kPathToolsViewID = 6; + const long kPathElementToolsViewID = 7; using yaaf::XGViewFactory; *************** *** 81,84 **** --- 82,86 ---- _parent = NULL; _planControls = NULL; + _pathElementControls = NULL; _pathControls = NULL; _currentToolID = -1; *************** *** 253,262 **** // --------------------------------------------------------------------------- ! // void ToolPalette::PickTool( Int32 id ) ! // --------------------------------------------------------------------------- // ! /* Pick a tool by its index. Plan tools are mutually exclusive, but may coexist with one path tool. */ ! void ! ToolPalette::PickTool( PlanView*view, Int32 id ) { short n, count, path, pathCount; --- 255,264 ---- // --------------------------------------------------------------------------- ! /// PickTool // ! /// Pick a tool by its index. Plan tools are mutually exclusive. ! /// PathElement tools are also exclusive, but may coexist with one path tool. ! // ! void ToolPalette::PickTool( PlanView*view, Int32 id ) { short n, count, path, pathCount; *************** *** 265,269 **** previous = _currentPlanTool; ! if(previous != NULL && _currentToolID != id) { previous->SetToolActive(view, false); --- 267,271 ---- previous = _currentPlanTool; ! if(previous != NULL && (_currentToolID != id || _currentToolIsPathElement)) { previous->SetToolActive(view, false); *************** *** 273,276 **** --- 275,279 ---- _currentPlanTool = _planTools[id].planTool; _currentToolID = id; + _currentToolIsPathElement = false; if(_currentPlanTool != NULL) { *************** *** 280,287 **** if(_currentPathTool != NULL) ! _currentPathTool->SetAssociatedPlanTool(_currentPlanTool); if(_planControls->GetCurrent() != id) - { _planControls->SetCurrent(id); } --- 283,293 ---- if(_currentPathTool != NULL) ! _currentPathTool->SetAssociatedPlanTool(_currentPlanTool); if(_planControls->GetCurrent() != id) _planControls->SetCurrent(id); + if(_pathElementControls != NULL) + { + _pathElementControls->SetCurrent(-1); // Disable all + _pathElementControls->InvalView(); } *************** *** 319,322 **** --- 325,388 ---- } + // --------------------------------------------------------------------------- + /// PickPathElementTool + // + /// Pick a tool by its index. Plan tools are mutually exclusive. + /// PathElement tools are also exclusive, but may coexist with one path tool. + // + void ToolPalette::PickPathElementTool( PlanView*view, Int32 id ) + { + short n, count, path, pathCount; + bool enabled, changed = false; + PlanTool *previous; + + previous = _currentPlanTool; + if(previous != NULL && (_currentToolID != id || !_currentToolIsPathElement)) + { + previous->SetToolActive(view, false); + if(_pathElementTools[_currentToolID].subPaletteWin != NULL) + _pathElementTools[_currentToolID].subPaletteWin->HideWindow(); + } + _currentPlanTool = _pathElementTools[id].planTool; + _currentToolID = id; + _currentToolIsPathElement = true; + if(_currentPlanTool != NULL) + { + _currentPlanTool->SetToolActive(view, true); + if(_parent != NULL) + _parent->_currentPlanTool = _currentPlanTool; + + if(_currentPathTool != NULL) + _currentPathTool->SetAssociatedPlanTool(_currentPlanTool); + if(_planControls->GetCurrent() != (id)) + _pathElementControls->SetCurrent(id); + _planControls->SetCurrent(-1); // Disable all + _planControls->InvalView(); + + count = _pathTools.Length(); + for(n = 0, changed = false; n < count; n++) + { + enabled = _pathTools[n]->IsEnabled(); + if(_pathControls->SetItemEnabled(n, enabled) != enabled) + { + changed = true; + } + if(!enabled && _currentPathTool == _pathTools[n]) + { + pathCount = _pathTools.Length(); + for(path = 0; path < pathCount; path++) + { + if(_pathTools[path]->IsEnabled()) + PickPathTool(view, path); + } + } + } + } + + if(changed) + _pathControls->InvalView(); + } + + void ToolPalette::PickBasePaletteTool(PlanView*view, Int32 id) { *************** *** 336,349 **** void ! ToolPalette::AddTool( PlanTool * tool, UInt32 index ) { ! UInt32 xPlace, yPlace, numItems; XGString tooltipText; paletteEntry_t entry; Element *elem; toolLookup_t lookup; ! xPlace = (index-1) % kNumToolsWide; ! yPlace = (index-1) / kNumToolsWide; entry.planTool = tool; --- 402,416 ---- void ! ToolPalette::AddTool( PlanTool * tool ) { ! UInt32 xPlace, yPlace; XGString tooltipText; paletteEntry_t entry; Element *elem; toolLookup_t lookup; + long index; + bool isPathElementTool; ! isPathElementTool = tool->isPathElementTool(); entry.planTool = tool; *************** *** 351,367 **** entry.subPalette = NULL; ! numItems = _planTools.Length(); ! if(index == numItems) ! _planTools.push_back(entry); ! else if(index < numItems) ! _planTools[index] = entry; else { ! MyAssert(false); // Out of range } /**/ tool->GetTooltipText(tooltipText); ! _planControls->AddTool(tool->GetIconID(), 32100+(numItems+1), (char*)tooltipText.c_str()); tool->SetToolPalette(this); --- 418,441 ---- entry.subPalette = NULL; ! if(isPathElementTool) ! { ! index = _pathElementTools.Length(); ! _pathElementTools.push_back(entry); ! } else { ! index = _planTools.Length(); ! _planTools.push_back(entry); } + xPlace = (index-1) % kNumToolsWide; + yPlace = (index-1) / kNumToolsWide; + /**/ tool->GetTooltipText(tooltipText); ! if(isPathElementTool) ! _pathElementControls->AddTool(tool->GetIconID(), 32100+(index+1), (char*)tooltipText.c_str()); ! else ! _planControls->AddTool(tool->GetIconID(), 32100+(index+1), (char*)tooltipText.c_str()); tool->SetToolPalette(this); *************** *** 422,431 **** changed = true; } ! if(!enabled && _currentPlanTool == _planTools[n].planTool) { toolCount = _planTools.Length(); for(tool = 0; tool < toolCount; tool++) { ! if(_planTools[tool].planTool->IsEnabled()) PickPathTool(view, tool); } --- 496,517 ---- changed = true; } ! } ! } ! count = _pathElementTools.Length(); ! for(n = 0, changed = false; n < count; n++) ! { ! if(_pathElementTools[n].planTool != NULL) ! { ! enabled = _pathElementTools[n].planTool->IsEnabled(); ! if(_pathElementControls->SetItemEnabled(n, enabled) != enabled) ! { ! changed = true; ! } ! if(!enabled && _currentPlanTool == _pathElementTools[n].planTool) { toolCount = _planTools.Length(); for(tool = 0; tool < toolCount; tool++) { ! if(_pathElementTools[tool].planTool->IsEnabled()) PickPathTool(view, tool); } *************** *** 434,438 **** --- 520,527 ---- } if(changed) + { _planControls->InvalView(); + _pathElementControls->InvalView(); + } } // --------------------------------------------------------------------------- *************** *** 584,599 **** _planControls = dynamic_cast<XGPaletteView*>(view->FindViewByID(5)); AssertValidView(_planControls); ! AddTool(new SelectTool(), 0); ! AddTool(new HandScrollerTool(), 1); ! AddTool(new PaintTool(), 2); ! AddTool(new PlacementTool(), 3); ! AddTool(new InfoTool(), 4); ! AddTool(new PlantingBedTool(), 5); ! AddTool(new TextBoxTool(), 6); ! AddTool(new DimensionTool(), 7); sub = MakeSubPalette(180, 3, 5, 8, 1047, "Standard Elements"); ! sub->AddTool(new TitleBoxTool(), 0); ! AddTool(new SmoothTool(), 9 ); // PickTool(NULL, 0); //!! Do this on view creation initComplete = true; --- 673,690 ---- _planControls = dynamic_cast<XGPaletteView*>(view->FindViewByID(5)); AssertValidView(_planControls); ! _pathElementControls = dynamic_cast<XGPaletteView*>(view->FindViewByID(7)); ! AssertValidView(_pathElementControls); ! AddTool(new SelectTool()); ! AddTool(new HandScrollerTool()); ! AddTool(new InfoTool()); ! AddTool(new TextBoxTool()); ! AddTool(new DimensionTool()); sub = MakeSubPalette(180, 3, 5, 8, 1047, "Standard Elements"); ! sub->AddTool(new TitleBoxTool()); ! AddTool(new SmoothTool()); + AddTool(new PaintTool()); + AddTool(new PlacementTool()); + AddTool(new PlantingBedTool()); // PickTool(NULL, 0); //!! Do this on view creation initComplete = true; *************** *** 653,657 **** PlanView *view; long button = pv->GetCurrent(); ! PRECONDITION((arg == kPlanToolsViewID) || (arg == kPathToolsViewID)); view = CGardenForm::TopDocumentPlanView(); --- 744,748 ---- PlanView *view; long button = pv->GetCurrent(); ! PRECONDITION((arg == kPlanToolsViewID) || (arg == kPathToolsViewID) || (arg == kPathElementToolsViewID)); view = CGardenForm::TopDocumentPlanView(); *************** *** 662,665 **** --- 753,760 ---- PickTool(view, button); } + else if(arg == kPathElementToolsViewID) + { + PickPathElementTool(view, button); + } else { |