* Added ImageListView showing the list of images. It will probably eventually
become a tree view, showing the source files as subitems of the images. * Added the image list to the team window and changed the layout more towards what it's intended to look like. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31087 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
160f2d1081
commit
42f07f3fea
@ -28,6 +28,7 @@ Application Debugger :
|
||||
Variant.cpp
|
||||
|
||||
# gui/team_window
|
||||
ImageListView.cpp
|
||||
TeamWindow.cpp
|
||||
ThreadListView.cpp
|
||||
|
||||
|
244
src/apps/debugger/gui/team_window/ImageListView.cpp
Normal file
244
src/apps/debugger/gui/team_window/ImageListView.cpp
Normal file
@ -0,0 +1,244 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include "ImageListView.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
#include <Looper.h>
|
||||
#include <Message.h>
|
||||
|
||||
#include <AutoLocker.h>
|
||||
#include <ObjectList.h>
|
||||
|
||||
#include "table/TableColumns.h"
|
||||
|
||||
|
||||
enum {
|
||||
MSG_SYNC_IMAGE_LIST = 'sytl'
|
||||
};
|
||||
|
||||
|
||||
// #pragma mark - ImagesTableModel
|
||||
|
||||
|
||||
class ImageListView::ImagesTableModel : public TableModel {
|
||||
public:
|
||||
ImagesTableModel(Team* team)
|
||||
:
|
||||
fTeam(team)
|
||||
{
|
||||
Update();
|
||||
}
|
||||
|
||||
~ImagesTableModel()
|
||||
{
|
||||
fTeam = NULL;
|
||||
Update();
|
||||
}
|
||||
|
||||
bool Update()
|
||||
{
|
||||
if (fTeam == NULL) {
|
||||
for (int32 i = 0; Image* image = fImages.ItemAt(i); i++)
|
||||
image->RemoveReference();
|
||||
fImages.MakeEmpty();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
AutoLocker<Team> locker(fTeam);
|
||||
|
||||
ImageList::ConstIterator it = fTeam->Images().GetIterator();
|
||||
Image* newImage = it.Next();
|
||||
int32 index = 0;
|
||||
|
||||
// remove no longer existing images
|
||||
while (Image* oldImage = fImages.ItemAt(index)) {
|
||||
if (oldImage == newImage) {
|
||||
index++;
|
||||
newImage = it.Next();
|
||||
} else {
|
||||
// TODO: Not particularly efficient!
|
||||
fImages.RemoveItemAt(index);
|
||||
oldImage->RemoveReference();
|
||||
NotifyRowsRemoved(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// add new images
|
||||
int32 countBefore = fImages.CountItems();
|
||||
while (newImage != NULL) {
|
||||
if (!fImages.AddItem(newImage))
|
||||
return false;
|
||||
|
||||
newImage->AddReference();
|
||||
newImage = it.Next();
|
||||
}
|
||||
|
||||
int32 count = fImages.CountItems();
|
||||
if (count > countBefore)
|
||||
NotifyRowsAdded(countBefore, count - countBefore);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual int32 CountColumns() const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
virtual int32 CountRows() const
|
||||
{
|
||||
return fImages.CountItems();
|
||||
}
|
||||
|
||||
virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, Variant& value)
|
||||
{
|
||||
Image* image = fImages.ItemAt(rowIndex);
|
||||
if (image == NULL)
|
||||
return false;
|
||||
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
value.SetTo(image->ID());
|
||||
return true;
|
||||
case 1:
|
||||
value.SetTo(image->Name(), VARIANT_DONT_COPY_DATA);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Image* ImageAt(int32 index) const
|
||||
{
|
||||
return fImages.ItemAt(index);
|
||||
}
|
||||
|
||||
private:
|
||||
Team* fTeam;
|
||||
BObjectList<Image> fImages;
|
||||
};
|
||||
|
||||
|
||||
// #pragma mark - ImageListView
|
||||
|
||||
|
||||
ImageListView::ImageListView()
|
||||
:
|
||||
BGroupView(B_VERTICAL),
|
||||
fTeam(NULL),
|
||||
fImagesTable(NULL),
|
||||
fImagesTableModel(NULL)
|
||||
{
|
||||
SetName("Images");
|
||||
}
|
||||
|
||||
|
||||
ImageListView::~ImageListView()
|
||||
{
|
||||
SetTeam(NULL);
|
||||
fImagesTable->SetTableModel(NULL);
|
||||
delete fImagesTableModel;
|
||||
}
|
||||
|
||||
|
||||
/*static*/ ImageListView*
|
||||
ImageListView::Create()
|
||||
{
|
||||
ImageListView* self = new ImageListView;
|
||||
|
||||
try {
|
||||
self->_Init();
|
||||
} catch (...) {
|
||||
delete self;
|
||||
throw;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ImageListView::SetTeam(Team* team)
|
||||
{
|
||||
if (team == fTeam)
|
||||
return;
|
||||
|
||||
if (fTeam != NULL) {
|
||||
fTeam->RemoveListener(this);
|
||||
fImagesTable->SetTableModel(NULL);
|
||||
delete fImagesTableModel;
|
||||
fImagesTableModel = NULL;
|
||||
}
|
||||
|
||||
fTeam = team;
|
||||
|
||||
if (fTeam != NULL) {
|
||||
fImagesTableModel = new(std::nothrow) ImagesTableModel(fTeam);
|
||||
fImagesTable->SetTableModel(fImagesTableModel);
|
||||
fImagesTable->ResizeAllColumnsToPreferred();
|
||||
fTeam->AddListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ImageListView::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case MSG_SYNC_IMAGE_LIST:
|
||||
if (fImagesTableModel != NULL)
|
||||
fImagesTableModel->Update();
|
||||
break;
|
||||
default:
|
||||
BGroupView::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ImageListView::ImageAdded(Team* team, Image* image)
|
||||
{
|
||||
Looper()->PostMessage(MSG_SYNC_IMAGE_LIST, this);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ImageListView::ImageRemoved(Team* team, Image* image)
|
||||
{
|
||||
Looper()->PostMessage(MSG_SYNC_IMAGE_LIST, this);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ImageListView::TableRowInvoked(Table* table, int32 rowIndex)
|
||||
{
|
||||
// if (fImagesTableModel != NULL) {
|
||||
// Image* image = fImagesTableModel->ImageAt(rowIndex);
|
||||
// if (image != NULL)
|
||||
// fParent->OpenImageWindow(image);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ImageListView::_Init()
|
||||
{
|
||||
fImagesTable = new Table("images list", 0);
|
||||
AddChild(fImagesTable->ToView());
|
||||
|
||||
// columns
|
||||
fImagesTable->AddColumn(new Int32TableColumn(0, "ID", 40, 20, 1000,
|
||||
B_TRUNCATE_MIDDLE, B_ALIGN_RIGHT));
|
||||
fImagesTable->AddColumn(new StringTableColumn(1, "Name", 80, 40, 1000,
|
||||
B_TRUNCATE_END, B_ALIGN_LEFT));
|
||||
|
||||
fImagesTable->AddTableListener(this);
|
||||
}
|
47
src/apps/debugger/gui/team_window/ImageListView.h
Normal file
47
src/apps/debugger/gui/team_window/ImageListView.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef IMAGE_LIST_VIEW_H
|
||||
#define IMAGE_LIST_VIEW_H
|
||||
|
||||
#include <GroupView.h>
|
||||
|
||||
#include "table/Table.h"
|
||||
#include "Team.h"
|
||||
|
||||
|
||||
class ImageListView : public BGroupView, private Team::Listener,
|
||||
private TableListener {
|
||||
public:
|
||||
ImageListView();
|
||||
~ImageListView();
|
||||
|
||||
static ImageListView* Create();
|
||||
// throws
|
||||
|
||||
void SetTeam(Team* team);
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
private:
|
||||
class ImagesTableModel;
|
||||
|
||||
private:
|
||||
// Team::Listener
|
||||
virtual void ImageAdded(Team* team, Image* image);
|
||||
virtual void ImageRemoved(Team* team, Image* image);
|
||||
|
||||
// TableListener
|
||||
virtual void TableRowInvoked(Table* table, int32 rowIndex);
|
||||
|
||||
void _Init();
|
||||
|
||||
private:
|
||||
Team* fTeam;
|
||||
Table* fImagesTable;
|
||||
ImagesTableModel* fImagesTableModel;
|
||||
};
|
||||
|
||||
|
||||
#endif // IMAGE_LIST_VIEW_H
|
@ -8,7 +8,10 @@
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <Message.h>
|
||||
#include <TabView.h>
|
||||
#include <SplitView.h>
|
||||
#include <TextView.h>
|
||||
|
||||
#include "ImageListView.h"
|
||||
#include "Team.h"
|
||||
#include "ThreadListView.h"
|
||||
|
||||
@ -18,12 +21,13 @@
|
||||
|
||||
TeamWindow::TeamWindow(::Team* team, Listener* listener)
|
||||
:
|
||||
BWindow(BRect(100, 100, 399, 299), _GetWindowTitle(team).String(),
|
||||
BWindow(BRect(100, 100, 699, 499), _GetWindowTitle(team).String(),
|
||||
B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS),
|
||||
fTeam(team),
|
||||
fListener(listener),
|
||||
fTabView(NULL),
|
||||
fThreadListView(NULL)
|
||||
fThreadListView(NULL),
|
||||
fImageListView(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@ -83,16 +87,26 @@ TeamWindow::_Init()
|
||||
BGroupLayout* rootLayout = new BGroupLayout(B_VERTICAL);
|
||||
SetLayout(rootLayout);
|
||||
|
||||
fTabView = new BTabView("tab view");
|
||||
|
||||
BSplitView* mainSplitView = new BSplitView(B_VERTICAL, 3.0f);
|
||||
BGroupLayoutBuilder(rootLayout)
|
||||
.Add(fTabView);
|
||||
.Add(mainSplitView);
|
||||
|
||||
fTabView = new BTabView("tab view");
|
||||
mainSplitView->AddChild(fTabView, 0.4f);
|
||||
|
||||
fTabView->AddTab(fThreadListView = ThreadListView::Create());
|
||||
// fTabView->AddTab(fTeamsPage = new TeamsPage(this));
|
||||
// fTabView->AddTab(fThreadsPage = new ThreadsPage(this));
|
||||
|
||||
BSplitView* imageAndSourceSplitView = new BSplitView(B_HORIZONTAL, 3.0f);
|
||||
mainSplitView->AddChild(imageAndSourceSplitView);
|
||||
|
||||
fImageListView = ImageListView::Create();
|
||||
imageAndSourceSplitView->AddChild(fImageListView);
|
||||
imageAndSourceSplitView->AddChild(new BTextView("source view"), 2.0f);
|
||||
|
||||
fThreadListView->SetTeam(fTeam);
|
||||
fImageListView->SetTeam(fTeam);
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
|
||||
class BTabView;
|
||||
class ImageListView;
|
||||
class Team;
|
||||
class ThreadListView;
|
||||
|
||||
@ -37,6 +38,7 @@ private:
|
||||
Listener* fListener;
|
||||
BTabView* fTabView;
|
||||
ThreadListView* fThreadListView;
|
||||
ImageListView* fImageListView;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user