[haiku-commits] haiku: hrev44351 - in src/apps: debugger/user_interface/gui/team_window debuganalyzer/gui/table

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 19 Jul 2012 00:45:44 +0200 (CEST)

hrev44351 adds 4 changesets to branch 'master'
old head: a2e7d8df7bf39721a597b0473831f25813d71b0e
new head: 3a5779744ed04ad4dd000e1680e0872b3b99b56e

----------------------------------------------------------------------------

489cc35: Add Tooltip support to TreeTable.

2216ccb: Implement support for tooltips in VariableView. Implements #8286.
  
  - These show the memory or register location(s) of the variable over which
    the mouse is hovering.

666222d: Resolve register names, print memory piece size information.

3a57797: Handle compound node values in variables view.
  
  - If the node we're looking at is a compound node, retrieve its location
    and show that as the value with an indicator to clarify that it's an object.
  
  - Minor tweaks to tooltip format.
  - Style cleanups.

                                      [ Rene Gollent <anevilyak@xxxxxxxxx> ]

----------------------------------------------------------------------------

3 files changed, 147 insertions(+), 5 deletions(-)
src/apps/debuganalyzer/gui/table/TreeTable.cpp     |   42 ++++++++
src/apps/debuganalyzer/gui/table/TreeTable.h       |   20 ++++
.../gui/team_window/VariablesView.cpp              |   90 +++++++++++++++-

############################################################################

Commit:      489cc3566148e0889a035fc49e5a16b0499e208c
URL:         http://cgit.haiku-os.org/haiku/commit/?id=489cc35
Author:      Rene Gollent <anevilyak@xxxxxxxxx>
Date:        Tue Jul 17 23:10:35 2012 UTC

Add Tooltip support to TreeTable.

----------------------------------------------------------------------------

diff --git a/src/apps/debuganalyzer/gui/table/TreeTable.cpp 
b/src/apps/debuganalyzer/gui/table/TreeTable.cpp
index 0c20843..851342a 100644
--- a/src/apps/debuganalyzer/gui/table/TreeTable.cpp
+++ b/src/apps/debuganalyzer/gui/table/TreeTable.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxxx
+ * Copyright 2012, Rene Gollent, rene@xxxxxxxxxxxx
  * Distributed under the terms of the MIT License.
  */
 
@@ -226,6 +227,14 @@ TreeTableModel::NotifyNodesChanged(const TreeTablePath& 
path, int32 childIndex,
 }
 
 
+// #pragma mark - TreeTableToolTipProvider
+
+
+TreeTableToolTipProvider::~TreeTableToolTipProvider()
+{
+}
+
+
 // #pragma mark - TreeTableListener
 
 
@@ -650,6 +659,7 @@ TreeTable::TreeTable(const char* name, uint32 flags, 
border_style borderStyle,
        :
        AbstractTable(name, flags, borderStyle, showHorizontalScrollbar),
        fModel(NULL),
+       fToolTipProvider(NULL),
        fRootNode(NULL),
        fSelectionModel(this),
        fIgnoreSelectionChange(0)
@@ -731,6 +741,13 @@ TreeTable::SetTreeTableModel(TreeTableModel* model)
 }
 
 
+void
+TreeTable::SetToolTipProvider(TreeTableToolTipProvider* toolTipProvider)
+{
+       fToolTipProvider = toolTipProvider;
+}
+
+
 TreeTableSelectionModel*
 TreeTable::SelectionModel()
 {
@@ -810,6 +827,31 @@ TreeTable::RemoveTreeTableListener(TreeTableListener* 
listener)
 }
 
 
+bool
+TreeTable::GetToolTipAt(BPoint point, BToolTip** _tip)
+{
+       if (fToolTipProvider == NULL)
+               return AbstractTable::GetToolTipAt(point, _tip);
+
+       // get the table row
+       BRow* row = RowAt(point);
+       if (row == NULL)
+               return AbstractTable::GetToolTipAt(point, _tip);
+
+       TreeTableRow* treeRow = dynamic_cast<TreeTableRow*>(row);
+       // get the table column
+       BColumn* column = ColumnAt(point);
+
+       int32 columnIndex = column != NULL ? column->LogicalFieldNum() : -1;
+
+       TreeTablePath path;
+       _GetPathForNode(treeRow->Node(), path);
+
+       return fToolTipProvider->GetToolTipForTablePath(path, columnIndex,
+               _tip);
+}
+
+
 void
 TreeTable::SelectionChanged()
 {
diff --git a/src/apps/debuganalyzer/gui/table/TreeTable.h 
b/src/apps/debuganalyzer/gui/table/TreeTable.h
index a475869..b006e08 100644
--- a/src/apps/debuganalyzer/gui/table/TreeTable.h
+++ b/src/apps/debuganalyzer/gui/table/TreeTable.h
@@ -1,5 +1,6 @@
 /*
  * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxxx
+ * Copyright 2012, Rene Gollent, rene@xxxxxxxxxxxx
  * Distributed under the terms of the MIT License.
  */
 #ifndef TREE_TABLE_H
@@ -122,6 +123,17 @@ private:
 };
 
 
+class TreeTableToolTipProvider {
+public:
+       virtual                                         
~TreeTableToolTipProvider();
+
+       virtual bool                            GetToolTipForTablePath(
+                                                                       const 
TreeTablePath& path,
+                                                                       int32 
columnIndex, BToolTip** _tip) = 0;
+                                                                       // 
columnIndex can be -1, if not in a column
+};
+
+
 class TreeTableListener {
 public:
        virtual                                         ~TreeTableListener();
@@ -157,6 +169,11 @@ public:
                        bool                            
SetTreeTableModel(TreeTableModel* model);
                        TreeTableModel*         GetTreeTableModel() const       
{ return fModel; }
 
+                       void                            SetToolTipProvider(
+                                                                       
TreeTableToolTipProvider* toolTipProvider);
+                       TreeTableToolTipProvider* ToolTipProvider() const
+                                                                       { 
return fToolTipProvider; }
+
                        TreeTableSelectionModel* SelectionModel();
 
                        void                            SelectNode(const 
TreeTablePath& path,
@@ -177,6 +194,8 @@ public:
                                                                        
TreeTableListener* listener);
 
 protected:
+       virtual bool                            GetToolTipAt(BPoint point, 
BToolTip** _tip);
+
        virtual void                            SelectionChanged();
 
        virtual AbstractColumn*         CreateColumn(TableColumn* column);
@@ -226,6 +245,7 @@ private:
 
 private:
                        TreeTableModel*         fModel;
+                       TreeTableToolTipProvider* fToolTipProvider;
                        TreeTableNode*          fRootNode;
                        TreeTableSelectionModel fSelectionModel;
                        ListenerList            fListeners;

############################################################################

Commit:      2216ccb7e2396a7356edfb5b1c8777fc853937be
URL:         http://cgit.haiku-os.org/haiku/commit/?id=2216ccb
Author:      Rene Gollent <anevilyak@xxxxxxxxx>
Date:        Tue Jul 17 23:12:47 2012 UTC

Ticket:      https://dev.haiku-os.org/ticket/8286

Implement support for tooltips in VariableView. Implements #8286.

- These show the memory or register location(s) of the variable over which
  the mouse is hovering.

----------------------------------------------------------------------------

diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp 
b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp
index 04ad5d4..0c0dc4c 100644
--- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp
+++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp
@@ -13,6 +13,7 @@
 
 #include <Looper.h>
 #include <PopUpMenu.h>
+#include <ToolTip.h>
 
 #include <AutoDeleter.h>
 #include <AutoLocker.h>
@@ -345,7 +346,8 @@ protected:
 // #pragma mark - VariableTableModel
 
 
-class VariablesView::VariableTableModel : public TreeTableModel {
+class VariablesView::VariableTableModel : public TreeTableModel,
+       public TreeTableToolTipProvider {
 public:
                                                                
VariableTableModel();
                                                                
~VariableTableModel();
@@ -379,6 +381,10 @@ public:
                        void                            
NotifyNodeChanged(ModelNode* node);
                        void                            
NotifyNodeHidden(ModelNode* node);
 
+       virtual bool                            GetToolTipForTablePath(
+                                                                       const 
TreeTablePath& path,
+                                                                       int32 
columnIndex, BToolTip** _tip);
+
 private:
                        struct NodeHashDefinition {
                                typedef ValueNodeChild* KeyType;
@@ -1159,6 +1165,45 @@ 
VariablesView::VariableTableModel::NotifyNodeHidden(ModelNode* node)
 }
 
 
+bool
+VariablesView::VariableTableModel::GetToolTipForTablePath(
+       const TreeTablePath& path, int32 columnIndex, BToolTip** _tip)
+{
+       ModelNode* node = (ModelNode*)NodeForPath(path);
+       if (node == NULL)
+               return false;
+
+       if (node->NodeChild()->LocationResolutionState() != B_OK)
+               return false;
+
+       ValueLocation* location = node->NodeChild()->Location();
+       BString tipData("Location piece(s):");
+       for (int32 i = 0; i < location->CountPieces(); i++) {
+               ValuePieceLocation piece = location->PieceAt(i);
+               BString pieceData;
+               switch (piece.type) {
+               case VALUE_PIECE_LOCATION_MEMORY:
+                       pieceData.SetToFormat("\n\t(%ld): Address: 0x%llx",
+                               i, piece.address);
+                       break;
+               case VALUE_PIECE_LOCATION_REGISTER:
+                       pieceData.SetToFormat("\n\t(%ld): Register (%lu)",
+                               i, piece.reg);
+                       break;
+               default:
+                       break;
+               }
+               tipData += pieceData;
+       }
+
+       *_tip = new(std::nothrow) BTextToolTip(tipData);
+       if (*_tip == NULL)
+               return false;
+
+       return true;
+}
+
+
 status_t
 VariablesView::VariableTableModel::_AddNode(Variable* variable,
        ModelNode* parent, ValueNodeChild* nodeChild, bool isPresentationNode,
@@ -1734,6 +1779,7 @@ VariablesView::_Init()
        if (fVariableTableModel->Init() != B_OK)
                throw std::bad_alloc();
        fVariableTable->SetTreeTableModel(fVariableTableModel);
+       fVariableTable->SetToolTipProvider(fVariableTableModel);
 
        fContainerListener = new ContainerListener(this);
        fVariableTableModel->SetContainerListener(fContainerListener);

############################################################################

Commit:      666222d3fd5bb1964565da7875df2570a0783673
URL:         http://cgit.haiku-os.org/haiku/commit/?id=666222d
Author:      Rene Gollent <anevilyak@xxxxxxxxx>
Date:        Wed Jul 18 00:58:40 2012 UTC

Resolve register names, print memory piece size information.

----------------------------------------------------------------------------

diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp 
b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp
index 0c0dc4c..ece5836 100644
--- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp
+++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp
@@ -26,6 +26,7 @@
 #include "FunctionInstance.h"
 #include "GUISettingsUtils.h"
 #include "MessageCodes.h"
+#include "Register.h"
 #include "SettingsMenu.h"
 #include "StackFrame.h"
 #include "StackFrameValues.h"
@@ -1183,13 +1184,17 @@ 
VariablesView::VariableTableModel::GetToolTipForTablePath(
                BString pieceData;
                switch (piece.type) {
                case VALUE_PIECE_LOCATION_MEMORY:
-                       pieceData.SetToFormat("\n\t(%ld): Address: 0x%llx",
-                               i, piece.address);
+                       pieceData.SetToFormat("\n\t(%ld): Address: 0x%llx, 
Size: "
+                               "%lld bytes", i, piece.address, piece.size);
                        break;
                case VALUE_PIECE_LOCATION_REGISTER:
-                       pieceData.SetToFormat("\n\t(%ld): Register (%lu)",
-                               i, piece.reg);
+               {
+                       Architecture* architecture = 
fThread->GetTeam()->GetArchitecture();
+                       pieceData.SetToFormat("\n\t(%ld): Register (%s)",
+                               i, architecture->Registers()[piece.reg].Name());
+
                        break;
+               }
                default:
                        break;
                }

############################################################################

Revision:    hrev44351
Commit:      3a5779744ed04ad4dd000e1680e0872b3b99b56e
URL:         http://cgit.haiku-os.org/haiku/commit/?id=3a57797
Author:      Rene Gollent <anevilyak@xxxxxxxxx>
Date:        Wed Jul 18 22:42:25 2012 UTC

Handle compound node values in variables view.

- If the node we're looking at is a compound node, retrieve its location
  and show that as the value with an indicator to clarify that it's an object.

- Minor tweaks to tooltip format.
- Style cleanups.

----------------------------------------------------------------------------

diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp 
b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp
index ece5836..b0beb9c 100644
--- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp
+++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp
@@ -314,10 +314,12 @@ protected:
                                        targetView);
                                return;
                        }
+               } else if (value.Type() == B_STRING_TYPE) {
+                       fField.SetString(value.ToString());
+               } else {
+                       // fall back to drawing an empty string
+                       fField.SetString("");
                }
-
-               // fall back to drawing an empty string
-               fField.SetString("");
                fField.SetWidth(Width());
                fColumn.DrawField(&fField, rect, targetView);
        }
@@ -1112,8 +1114,29 @@ VariablesView::VariableTableModel::GetValueAt(void* 
object, int32 columnIndex,
                        _value.SetTo(node->Name(), B_VARIANT_DONT_COPY_DATA);
                        return true;
                case 1:
-                       if (node->GetValue() == NULL)
+                       if (node->GetValue() == NULL) {
+                               ValueLocation* location = 
node->NodeChild()->Location();
+                               if (location == NULL)
+                                       return false;
+
+                               Type* nodeChildRawType = 
node->NodeChild()->Node()->GetType()
+                                       ->ResolveRawType(false);
+                               if (nodeChildRawType->Kind() == TYPE_COMPOUND)
+                               {
+                                       if (location->CountPieces() > 1)
+                                               return false;
+
+                                       BString data;
+                                       ValuePieceLocation piece = 
location->PieceAt(0);
+                                       if (piece.type != 
VALUE_PIECE_LOCATION_MEMORY)
+                                               return false;
+
+                                       data.SetToFormat("[@ 0x%llx]", 
piece.address);
+                                       _value.SetTo(data);
+                                       return true;
+                               }
                                return false;
+                       }
 
                        _value.SetTo(node, VALUE_NODE_TYPE);
                        return true;
@@ -1178,29 +1201,35 @@ 
VariablesView::VariableTableModel::GetToolTipForTablePath(
                return false;
 
        ValueLocation* location = node->NodeChild()->Location();
-       BString tipData("Location piece(s):");
+       BString tipData;
        for (int32 i = 0; i < location->CountPieces(); i++) {
                ValuePieceLocation piece = location->PieceAt(i);
                BString pieceData;
                switch (piece.type) {
-               case VALUE_PIECE_LOCATION_MEMORY:
-                       pieceData.SetToFormat("\n\t(%ld): Address: 0x%llx, 
Size: "
-                               "%lld bytes", i, piece.address, piece.size);
-                       break;
-               case VALUE_PIECE_LOCATION_REGISTER:
-               {
-                       Architecture* architecture = 
fThread->GetTeam()->GetArchitecture();
-                       pieceData.SetToFormat("\n\t(%ld): Register (%s)",
-                               i, architecture->Registers()[piece.reg].Name());
+                       case VALUE_PIECE_LOCATION_MEMORY:
+                               pieceData.SetToFormat("(%ld): Address: 0x%llx, 
Size: "
+                                       "%lld bytes", i, piece.address, 
piece.size);
+                               break;
+                       case VALUE_PIECE_LOCATION_REGISTER:
+                       {
+                               Architecture* architecture = 
fThread->GetTeam()->GetArchitecture();
+                               pieceData.SetToFormat("(%ld): Register (%s)",
+                                       i, 
architecture->Registers()[piece.reg].Name());
 
-                       break;
-               }
-               default:
-                       break;
+                               break;
+                       }
+                       default:
+                               break;
                }
+
                tipData += pieceData;
+               if (i < location->CountPieces() - 1)
+                       tipData += "\n";
        }
 
+       if (tipData.IsEmpty())
+               return false;
+
        *_tip = new(std::nothrow) BTextToolTip(tipData);
        if (*_tip == NULL)
                return false;


Other related posts:

  • » [haiku-commits] haiku: hrev44351 - in src/apps: debugger/user_interface/gui/team_window debuganalyzer/gui/table - anevilyak