Ticket #9755: 9755-4.patch
File 9755-4.patch, 9.0 KB (added by , 11 years ago) |
---|
-
src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.cpp
diff --git a/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.cpp b/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.cpp index ac2917a..672996c 100644
a b 11 11 #include <new> 12 12 #include <set> 13 13 14 #include <LayoutBuilder.h> 15 #include <MessageRunner.h> 14 16 #include <StringList.h> 17 #include <TextControl.h> 15 18 16 19 #include <AutoDeleter.h> 17 20 … … 25 28 #include "Tracing.h" 26 29 27 30 31 static const uint32 MSG_FUNCTION_FILTER_CHANGED = 'mffc'; 32 static const uint32 MSG_FUNCTION_TYPING_TIMEOUT = 'mftt'; 33 34 static const uint32 kKeypressTimeout = 250000; 35 36 // from ColumnTypes.cpp 37 static const float kTextMargin = 8.0; 38 39 28 40 // #pragma mark - SourcePathComponentNode 29 41 30 42 … … private: 151 163 }; 152 164 153 165 166 // #pragma mark - HighlightingTableColumn 167 168 169 class ImageFunctionsView::HighlightingTableColumn : public StringTableColumn { 170 public: 171 HighlightingTableColumn(int32 modelIndex, const char* title, float width, 172 float minWidth, float maxWidth, uint32 truncate, 173 alignment align = B_ALIGN_LEFT) 174 : 175 StringTableColumn(modelIndex, title, width, minWidth, maxWidth, 176 truncate, align), 177 fFilter(), 178 fFilterWidth(0.0) 179 { 180 } 181 182 void SetFilter(const BString& filter) 183 { 184 fFilter = filter; 185 fFilterWidth = 0.0; 186 } 187 188 virtual void DrawValue(const BVariant& value, BRect rect, 189 BView* targetView) 190 { 191 StringTableColumn::DrawValue(value, rect, targetView); 192 193 if (!fFilter.IsEmpty()) { 194 if (fFilterWidth == 0.0) 195 fFilterWidth = targetView->StringWidth(fFilter); 196 197 // TODO: handle this case as well 198 if (fField.HasClippedString()) 199 return; 200 201 const char* fieldString = fField.String(); 202 const char* filterMatch = strstr(fieldString, fFilter.String()); 203 if (filterMatch == NULL) 204 return; 205 206 targetView->PushState(); 207 BRect fillRect(rect); 208 fillRect.left += kTextMargin + targetView->StringWidth( 209 fieldString, filterMatch - fieldString); 210 fillRect.right = fillRect.left + fFilterWidth; 211 targetView->SetLowColor(255, 255, 0, 255); 212 targetView->SetDrawingMode(B_OP_MIN); 213 targetView->FillRect(fillRect, B_SOLID_LOW); 214 targetView->PopState(); 215 } 216 } 217 218 219 private: 220 BString fFilter; 221 float fFilterWidth; 222 }; 223 224 154 225 // #pragma mark - FunctionsTableModel 155 226 156 227 … … public: 198 269 199 270 LocatableFile* currentFile = NULL; 200 271 BStringList pathComponents; 272 bool applyFilter = !fCurrentFilter.IsEmpty(); 201 273 int32 functionCount = fImageDebugInfo->CountFunctions(); 202 274 for (int32 i = 0; i < functionCount; i++) { 203 275 FunctionInstance* instance = fImageDebugInfo->FunctionAt(i); … … public: 213 285 } 214 286 215 287 LocatableFile* sourceFile = instance->SourceFile(); 288 BString sourcePath; 289 if (sourceFile != NULL) 290 sourceFile->GetPath(sourcePath); 291 292 if (applyFilter && !_FilterFunction(instance, sourcePath)) 293 continue; 294 216 295 if (sourceFile == NULL) { 217 296 if (!_AddFunctionNode(sourcelessNode, instance, NULL)) 218 297 return; … … public: 221 300 222 301 if (sourceFile != currentFile) { 223 302 currentFile = sourceFile; 224 if (!_GetSourcePathComponents(currentFile, 303 pathComponents.MakeEmpty(); 304 if (!applyFilter && !_GetSourcePathComponents(currentFile, 225 305 pathComponents)) { 226 306 return; 227 } 307 } else 308 pathComponents.Add(sourcePath); 228 309 } 229 310 230 311 if (!_AddFunctionByPath(pathComponents, instance, currentFile)) … … public: 351 432 return false; 352 433 } 353 434 435 void SetFilter(const char* filter) 436 { 437 fCurrentFilter = filter; 438 439 SetImageDebugInfo(fImageDebugInfo); 440 } 441 354 442 private: 355 443 bool _GetSourcePathComponents(LocatableFile* currentFile, 356 444 BStringList& pathComponents) … … private: 360 448 if (sourcePath.IsEmpty()) 361 449 return false; 362 450 363 pathComponents.MakeEmpty();364 365 451 int32 startIndex = 0; 366 452 if (sourcePath[0] == '/') 367 453 startIndex = 1; … … private: 438 524 return true; 439 525 } 440 526 527 bool _FilterFunction(FunctionInstance* instance, const BString& sourcePath) 528 { 529 if (instance->PrettyName().IFindFirst(fCurrentFilter) >= 0) 530 return true; 531 532 return sourcePath.IFindFirst(fCurrentFilter) >= 0; 533 } 534 535 441 536 private: 442 537 typedef BObjectList<SourcePathComponentNode> ChildPathComponentList; 443 538 … … private: 445 540 ImageDebugInfo* fImageDebugInfo; 446 541 ChildPathComponentList fChildPathComponents; 447 542 SourcePathComponentNode* fSourcelessNode; 543 BString fCurrentFilter; 448 544 }; 449 545 450 546 … … ImageFunctionsView::ImageFunctionsView(Listener* listener) 455 551 : 456 552 BGroupView(B_VERTICAL), 457 553 fImageDebugInfo(NULL), 554 fFilterField(NULL), 458 555 fFunctionsTable(NULL), 459 556 fFunctionsTableModel(NULL), 460 fListener(listener) 557 fListener(listener), 558 fHighlightingColumn(NULL), 559 fLastFilterKeypress(0) 461 560 { 462 561 SetName("Functions"); 463 562 } … … ImageFunctionsView::SetFunction(FunctionInstance* function) 545 644 546 645 547 646 void 647 ImageFunctionsView::AttachedToWindow() 648 { 649 BView::AttachedToWindow(); 650 651 fFilterField->SetTarget(this); 652 } 653 654 655 void 656 ImageFunctionsView::MessageReceived(BMessage* message) 657 { 658 switch (message->what) { 659 case MSG_FUNCTION_FILTER_CHANGED: 660 { 661 fLastFilterKeypress = system_time(); 662 BMessage keypressMessage(MSG_FUNCTION_TYPING_TIMEOUT); 663 BMessageRunner::StartSending(BMessenger(this), &keypressMessage, 664 kKeypressTimeout, 1); 665 break; 666 } 667 668 case MSG_FUNCTION_TYPING_TIMEOUT: 669 { 670 if (system_time() - fLastFilterKeypress >= kKeypressTimeout) { 671 fFunctionsTableModel->SetFilter(fFilterField->Text()); 672 fHighlightingColumn->SetFilter(fFilterField->Text()); 673 _ExpandFilteredNodes(); 674 } 675 break; 676 } 677 678 default: 679 BView::MessageReceived(message); 680 break; 681 } 682 } 683 684 685 void 548 686 ImageFunctionsView::LoadSettings(const BMessage& settings) 549 687 { 550 688 BMessage tableSettings; … … ImageFunctionsView::_Init() 591 729 { 592 730 fFunctionsTable = new TreeTable("functions", 0, B_FANCY_BORDER); 593 731 AddChild(fFunctionsTable->ToView()); 732 AddChild(fFilterField = new BTextControl("filtertext", "Filter:", 733 NULL, NULL)); 734 735 fFilterField->SetModificationMessage(new BMessage( 736 MSG_FUNCTION_FILTER_CHANGED)); 594 737 fFunctionsTable->SetSortingEnabled(false); 595 738 596 739 // columns 597 fFunctionsTable->AddColumn(new StringTableColumn(0, "File/Function", 300, 598 100, 1000, B_TRUNCATE_BEGINNING, B_ALIGN_LEFT)); 740 fFunctionsTable->AddColumn(fHighlightingColumn 741 = new HighlightingTableColumn(0, "File/Function", 300, 100, 1000, 742 B_TRUNCATE_BEGINNING, B_ALIGN_LEFT)); 599 743 600 744 fFunctionsTableModel = new FunctionsTableModel(); 601 745 fFunctionsTable->SetTreeTableModel(fFunctionsTableModel); … … ImageFunctionsView::_Init() 605 749 } 606 750 607 751 752 void 753 ImageFunctionsView::_ExpandFilteredNodes() 754 { 755 if (fFilterField->TextView()->TextLength() == 0) 756 return; 757 758 for (int32 i = 0; i < fFunctionsTableModel->CountChildren( 759 fFunctionsTableModel); i++) { 760 TreeTablePath path; 761 path.AddComponent(i); 762 fFunctionsTable->SetNodeExpanded(path, true, true); 763 } 764 765 fFunctionsTable->ResizeAllColumnsToPreferred(); 766 } 767 768 608 769 // #pragma mark - Listener 609 770 610 771 -
src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.h
diff --git a/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.h b/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.h index 55fb959..f5801ac 100644
a b 12 12 #include "Team.h" 13 13 14 14 15 class BTextControl; 15 16 class FunctionInstance; 16 17 17 18 … … public: 31 32 void SetImageDebugInfo( 32 33 ImageDebugInfo* imageDebugInfo); 33 34 void SetFunction(FunctionInstance* function); 35 virtual void AttachedToWindow(); 36 virtual void MessageReceived(BMessage* message); 34 37 35 38 void LoadSettings(const BMessage& settings); 36 39 status_t SaveSettings(BMessage& settings); 37 40 38 41 private: 39 42 class FunctionsTableModel; 43 class HighlightingTableColumn; 40 44 class SourcePathComponentNode; 41 45 42 46 private: … … private: 45 49 46 50 void _Init(); 47 51 52 void _ExpandFilteredNodes(); 53 48 54 private: 49 55 ImageDebugInfo* fImageDebugInfo; 56 BTextControl* fFilterField; 50 57 TreeTable* fFunctionsTable; 51 58 FunctionsTableModel* fFunctionsTableModel; 52 59 Listener* fListener; 60 HighlightingTableColumn* fHighlightingColumn; 61 bigtime_t fLastFilterKeypress; 53 62 }; 54 63 55 64 -
src/kits/interface/ColumnListView.cpp
diff --git a/src/kits/interface/ColumnListView.cpp b/src/kits/interface/ColumnListView.cpp index ec8b1af..f9b67a0 100644
a b OutlineView::Clear() 3070 3070 DeselectAll(); 3071 3071 // Make sure selection list doesn't point to deleted rows! 3072 3072 RecursiveDeleteRows(&fRows, false); 3073 Invalidate();3074 3073 fItemsHeight = 0.0; 3075 3074 FixScrollBar(true); 3075 Invalidate(); 3076 3076 } 3077 3077 3078 3078 … … OutlineView::FixScrollBar(bool scrollToFit) 4378 4378 vScrollBar->SetRange(0.0, maxScrollBarValue); 4379 4379 vScrollBar->SetSteps(20.0, fVisibleRect.Height()); 4380 4380 } 4381 } else if (vScrollBar->Value() == 0.0 )4381 } else if (vScrollBar->Value() == 0.0 || fItemsHeight == 0.0) 4382 4382 vScrollBar->SetRange(0.0, 0.0); // disable scroll bar. 4383 4383 } 4384 4384 }