[Igarden-commit] Garden/source/PlanTool PlacementTool.h, 1.7, 1.7.2.1 PlacementTool.cpp, 1.10.2.1,
Status: Beta
Brought to you by:
jlbedell
|
From: Jeffrey B. <jlb...@us...> - 2007-01-20 15:50:17
|
Update of /cvsroot/igarden/Garden/source/PlanTool In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv7941 Modified Files: Tag: Release_branch_v1 PlacementTool.h PlacementTool.cpp ToolPalette.cpp PlantingBedTool.cpp ToolPalette.h Log Message: BUG: Only enable tools which are valid for the active material Index: PlacementTool.h =================================================================== RCS file: /cvsroot/igarden/Garden/source/PlanTool/PlacementTool.h,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -C2 -d -r1.7 -r1.7.2.1 *** PlacementTool.h 21 Jun 2006 02:45:27 -0000 1.7 --- PlacementTool.h 20 Jan 2007 15:50:13 -0000 1.7.2.1 *************** *** 36,39 **** --- 36,40 ---- virtual short GetIconID(); virtual bool KeyPressed(PlanView * view, long keyEvent, Element* element); + virtual bool IsEnabled(); protected: Index: ToolPalette.h =================================================================== RCS file: /cvsroot/igarden/Garden/source/PlanTool/ToolPalette.h,v retrieving revision 1.10 retrieving revision 1.10.2.1 diff -C2 -d -r1.10 -r1.10.2.1 *** ToolPalette.h 28 Oct 2005 12:53:07 -0000 1.10 --- ToolPalette.h 20 Jan 2007 15:50:13 -0000 1.10.2.1 *************** *** 99,102 **** --- 99,103 ---- // methods void SetParentPalette(ToolPalette *parent); + void UpdatePlanToolState(PlanView *view); // attributes Index: ToolPalette.cpp =================================================================== RCS file: /cvsroot/igarden/Garden/source/PlanTool/ToolPalette.cpp,v retrieving revision 1.20 retrieving revision 1.20.2.1 diff -C2 -d -r1.20 -r1.20.2.1 *** ToolPalette.cpp 21 Jun 2006 02:46:58 -0000 1.20 --- ToolPalette.cpp 20 Jan 2007 15:50:13 -0000 1.20.2.1 *************** *** 388,393 **** ToolPalette::PickPathTool( PlanView*view, Int32 id ) { - short n, count, tool, toolCount; - bool enabled, changed; PathTool *previous; --- 388,391 ---- *************** *** 405,409 **** _pathControls->SetCurrent(id); } ! count = _planTools.Length(); for(n = 0, changed = false; n < count; n++) --- 403,414 ---- _pathControls->SetCurrent(id); } ! UpdatePlanToolState(view); ! } ! ! void ToolPalette::UpdatePlanToolState(PlanView *view) ! { ! short n, count, tool, toolCount; ! bool enabled, changed; ! count = _planTools.Length(); for(n = 0, changed = false; n < count; n++) *************** *** 688,691 **** --- 693,697 ---- } + view = CGardenForm::TopDocumentPlanView(); if(isNonPlant != _nonPlantMaterialSelected) { *************** *** 699,703 **** if(isEnabled & !picked) { - view = CGardenForm::TopDocumentPlanView(); PickPathTool(view, n); picked = true; --- 705,708 ---- *************** *** 706,709 **** --- 711,715 ---- InvalView(); } + UpdatePlanToolState(view); return 0; Index: PlantingBedTool.cpp =================================================================== RCS file: /cvsroot/igarden/Garden/source/PlanTool/PlantingBedTool.cpp,v retrieving revision 1.8.2.1 retrieving revision 1.8.2.2 diff -C2 -d -r1.8.2.1 -r1.8.2.2 *** PlantingBedTool.cpp 20 Jan 2007 00:42:23 -0000 1.8.2.1 --- PlantingBedTool.cpp 20 Jan 2007 15:50:13 -0000 1.8.2.2 *************** *** 160,166 **** PlantingBedTool::IsEnabled() { ! PathTool *pt = CurrentPathTool(); PRECONDITION(pt != NULL); ! return pt->CanMakeClosedPath(); } // --------------------------------------------------------------------------- --- 160,168 ---- PlantingBedTool::IsEnabled() { ! PathTool *pt = CurrentPathTool(); ! Material *mat = GetActiveMaterial(); ! bool validMaterial = mat && ((mat->GetMaterialType() & kMajorMaterialType) == kMaterialTypePlant); PRECONDITION(pt != NULL); ! return pt->CanMakeClosedPath() && validMaterial; } // --------------------------------------------------------------------------- Index: PlacementTool.cpp =================================================================== RCS file: /cvsroot/igarden/Garden/source/PlanTool/PlacementTool.cpp,v retrieving revision 1.10.2.1 retrieving revision 1.10.2.2 diff -C2 -d -r1.10.2.1 -r1.10.2.2 *** PlacementTool.cpp 20 Jan 2007 00:42:23 -0000 1.10.2.1 --- PlacementTool.cpp 20 Jan 2007 15:50:13 -0000 1.10.2.2 *************** *** 152,155 **** --- 152,158 ---- } + // --------------------------------------------------------------------------- + /// KeyPressed + // bool PlacementTool::KeyPressed(PlanView * view, long keyEvent, Element* element) { *************** *** 162,163 **** --- 165,186 ---- return accepted; } + + // --------------------------------------------------------------------------- + /// IsEnabled + // + bool PlacementTool::IsEnabled() + { + Material *mat = GetActiveMaterial(); + materialType_t mtype, majorType; + bool result = false; + + if(mat != NULL) + { + mtype = mat->GetMaterialType(); + majorType = static_cast<materialType_t>(mtype & kMajorMaterialType); + if(majorType != kMaterialTypeUnspecified && majorType != kMaterialTypeBackground) + result = true; + } + + return result; + } |