Ticket #9755: 9755-4.patch

File 9755-4.patch, 9.0 KB (added by anevilyak, 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  
    1111#include <new>
    1212#include <set>
    1313
     14#include <LayoutBuilder.h>
     15#include <MessageRunner.h>
    1416#include <StringList.h>
     17#include <TextControl.h>
    1518
    1619#include <AutoDeleter.h>
    1720
     
    2528#include "Tracing.h"
    2629
    2730
     31static const uint32 MSG_FUNCTION_FILTER_CHANGED = 'mffc';
     32static const uint32 MSG_FUNCTION_TYPING_TIMEOUT = 'mftt';
     33
     34static const uint32 kKeypressTimeout = 250000;
     35
     36// from ColumnTypes.cpp
     37static const float kTextMargin = 8.0;
     38
     39
    2840// #pragma mark - SourcePathComponentNode
    2941
    3042
    private:  
    151163};
    152164
    153165
     166// #pragma mark - HighlightingTableColumn
     167
     168
     169class ImageFunctionsView::HighlightingTableColumn : public StringTableColumn {
     170public:
     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
     219private:
     220    BString fFilter;
     221    float   fFilterWidth;
     222};
     223
     224
    154225// #pragma mark - FunctionsTableModel
    155226
    156227
    public:  
    198269
    199270        LocatableFile* currentFile = NULL;
    200271        BStringList pathComponents;
     272        bool applyFilter = !fCurrentFilter.IsEmpty();
    201273        int32 functionCount = fImageDebugInfo->CountFunctions();
    202274        for (int32 i = 0; i < functionCount; i++) {
    203275            FunctionInstance* instance = fImageDebugInfo->FunctionAt(i);
    public:  
    213285            }
    214286
    215287            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
    216295            if (sourceFile == NULL) {
    217296                if (!_AddFunctionNode(sourcelessNode, instance, NULL))
    218297                    return;
    public:  
    221300
    222301            if (sourceFile != currentFile) {
    223302                currentFile = sourceFile;
    224                 if (!_GetSourcePathComponents(currentFile,
     303                pathComponents.MakeEmpty();
     304                if (!applyFilter && !_GetSourcePathComponents(currentFile,
    225305                        pathComponents)) {
    226306                    return;
    227                 }
     307                } else
     308                    pathComponents.Add(sourcePath);
    228309            }
    229310
    230311            if (!_AddFunctionByPath(pathComponents, instance, currentFile))
    public:  
    351432        return false;
    352433    }
    353434
     435    void SetFilter(const char* filter)
     436    {
     437        fCurrentFilter = filter;
     438
     439        SetImageDebugInfo(fImageDebugInfo);
     440    }
     441
    354442private:
    355443    bool _GetSourcePathComponents(LocatableFile* currentFile,
    356444        BStringList& pathComponents)
    private:  
    360448        if (sourcePath.IsEmpty())
    361449            return false;
    362450
    363         pathComponents.MakeEmpty();
    364 
    365451        int32 startIndex = 0;
    366452        if (sourcePath[0] == '/')
    367453            startIndex = 1;
    private:  
    438524        return true;
    439525    }
    440526
     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
    441536private:
    442537    typedef BObjectList<SourcePathComponentNode> ChildPathComponentList;
    443538
    private:  
    445540    ImageDebugInfo*         fImageDebugInfo;
    446541    ChildPathComponentList  fChildPathComponents;
    447542    SourcePathComponentNode* fSourcelessNode;
     543    BString                 fCurrentFilter;
    448544};
    449545
    450546
    ImageFunctionsView::ImageFunctionsView(Listener* listener)  
    455551    :
    456552    BGroupView(B_VERTICAL),
    457553    fImageDebugInfo(NULL),
     554    fFilterField(NULL),
    458555    fFunctionsTable(NULL),
    459556    fFunctionsTableModel(NULL),
    460     fListener(listener)
     557    fListener(listener),
     558    fHighlightingColumn(NULL),
     559    fLastFilterKeypress(0)
    461560{
    462561    SetName("Functions");
    463562}
    ImageFunctionsView::SetFunction(FunctionInstance* function)  
    545644
    546645
    547646void
     647ImageFunctionsView::AttachedToWindow()
     648{
     649    BView::AttachedToWindow();
     650
     651    fFilterField->SetTarget(this);
     652}
     653
     654
     655void
     656ImageFunctionsView::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
     685void
    548686ImageFunctionsView::LoadSettings(const BMessage& settings)
    549687{
    550688    BMessage tableSettings;
    ImageFunctionsView::_Init()  
    591729{
    592730    fFunctionsTable = new TreeTable("functions", 0, B_FANCY_BORDER);
    593731    AddChild(fFunctionsTable->ToView());
     732    AddChild(fFilterField = new BTextControl("filtertext", "Filter:",
     733            NULL, NULL));
     734
     735    fFilterField->SetModificationMessage(new BMessage(
     736            MSG_FUNCTION_FILTER_CHANGED));
    594737    fFunctionsTable->SetSortingEnabled(false);
    595738
    596739    // 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));
    599743
    600744    fFunctionsTableModel = new FunctionsTableModel();
    601745    fFunctionsTable->SetTreeTableModel(fFunctionsTableModel);
    ImageFunctionsView::_Init()  
    605749}
    606750
    607751
     752void
     753ImageFunctionsView::_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
    608769// #pragma mark - Listener
    609770
    610771
  • 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  
    1212#include "Team.h"
    1313
    1414
     15class BTextControl;
    1516class FunctionInstance;
    1617
    1718
    public:  
    3132            void                SetImageDebugInfo(
    3233                                    ImageDebugInfo* imageDebugInfo);
    3334            void                SetFunction(FunctionInstance* function);
     35    virtual void                AttachedToWindow();
     36    virtual void                MessageReceived(BMessage* message);
    3437
    3538            void                LoadSettings(const BMessage& settings);
    3639            status_t            SaveSettings(BMessage& settings);
    3740
    3841private:
    3942            class FunctionsTableModel;
     43            class HighlightingTableColumn;
    4044            class SourcePathComponentNode;
    4145
    4246private:
    private:  
    4549
    4650            void                _Init();
    4751
     52            void                _ExpandFilteredNodes();
     53
    4854private:
    4955            ImageDebugInfo*     fImageDebugInfo;
     56            BTextControl*       fFilterField;
    5057            TreeTable*          fFunctionsTable;
    5158            FunctionsTableModel* fFunctionsTableModel;
    5259            Listener*           fListener;
     60            HighlightingTableColumn* fHighlightingColumn;
     61            bigtime_t           fLastFilterKeypress;
    5362};
    5463
    5564
  • 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()  
    30703070    DeselectAll();
    30713071        // Make sure selection list doesn't point to deleted rows!
    30723072    RecursiveDeleteRows(&fRows, false);
    3073     Invalidate();
    30743073    fItemsHeight = 0.0;
    30753074    FixScrollBar(true);
     3075    Invalidate();
    30763076}
    30773077
    30783078
    OutlineView::FixScrollBar(bool scrollToFit)  
    43784378                vScrollBar->SetRange(0.0, maxScrollBarValue);
    43794379                vScrollBar->SetSteps(20.0, fVisibleRect.Height());
    43804380            }
    4381         } else if (vScrollBar->Value() == 0.0)
     4381        } else if (vScrollBar->Value() == 0.0 || fItemsHeight == 0.0)
    43824382            vScrollBar->SetRange(0.0, 0.0);     // disable scroll bar.
    43834383    }
    43844384}