* Small code cleanups, a bigger style cleanup should be done, but I didn't

want to mix too much cleanups into real changes.
* Got rid of the weird lines between rows.
* Tweaked colors (selections are usually dark everywhere else in Haiku).
* Implemented slightly tinting alternating rows.
* Removed the code duplication to figure out the appropriate background
  row color, fixed some inconsistencies between Draw() and RedrawColumn()
  in this regard.

TODO: Default colors should be computed based on current panel color though.

TODO: Figure out why the outline view does not scroll (at least not visibly)
when the vertical scroll bar is used.

TODO: Remove remaining redraw bugs. I observe a column of pixels not being
updated in some cases when resizing columns.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24033 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2008-02-20 12:27:36 +00:00
parent 1d9a705ed4
commit da5d970124
+190 -239
View File
@@ -154,15 +154,7 @@ static const unsigned char kDownSortArrow8x8Invert[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
}; };
/* static const float kTintedLineTint = 0.7 * B_NO_TINT + 0.3 * B_DARKEN_1_TINT;
static const rgb_color kTitleColor = {215, 215, 215, 255};
static const rgb_color kTitleTextColor = { 0, 0, 0, 255 };
static const rgb_color kDefaultBackgroundColor = {236, 236, 236, 255};
static const rgb_color kRowDividerColor = {148, 148, 148, 255};
static const rgb_color kDefaultSelectionColor = {255, 255, 255, 255};
static const rgb_color kDefaultEditColor = {180, 180, 180, 180};
static const rgb_color kNonFocusSelectionColor = {220, 220, 220, 255};
*/
static const float kTitleHeight = 17.0; static const float kTitleHeight = 17.0;
static const float kLatchWidth = 15.0; static const float kLatchWidth = 15.0;
@@ -173,9 +165,9 @@ static const rgb_color kColor[B_COLOR_TOTAL] =
{236, 236, 236, 255}, // B_COLOR_BACKGROUND {236, 236, 236, 255}, // B_COLOR_BACKGROUND
{ 0, 0, 0, 255}, // B_COLOR_TEXT { 0, 0, 0, 255}, // B_COLOR_TEXT
{148, 148, 148, 255}, // B_COLOR_ROW_DIVIDER {148, 148, 148, 255}, // B_COLOR_ROW_DIVIDER
{255, 255, 255, 255}, // B_COLOR_SELECTION {190, 190, 190, 255}, // B_COLOR_SELECTION
{ 0, 0, 0, 255}, // B_COLOR_SELECTION_TEXT { 0, 0, 0, 255}, // B_COLOR_SELECTION_TEXT
{220, 220, 220, 255}, // B_COLOR_NON_FOCUS_SELECTION {200, 200, 200, 255}, // B_COLOR_NON_FOCUS_SELECTION
{180, 180, 180, 180}, // B_COLOR_EDIT_BACKGROUND {180, 180, 180, 180}, // B_COLOR_EDIT_BACKGROUND
{ 0, 0, 0, 255}, // B_COLOR_EDIT_TEXT { 0, 0, 0, 255}, // B_COLOR_EDIT_TEXT
{215, 215, 215, 255}, // B_COLOR_HEADER_BACKGROUND {215, 215, 215, 255}, // B_COLOR_HEADER_BACKGROUND
@@ -1573,8 +1565,7 @@ void BColumnListView::SetEditMode(bool state)
void BColumnListView::Refresh() void BColumnListView::Refresh()
{ {
if(LockLooper()) if (LockLooper()) {
{
Invalidate(); Invalidate();
fOutlineView->FixScrollBar (true); fOutlineView->FixScrollBar (true);
fOutlineView->Invalidate(); fOutlineView->Invalidate();
@@ -1780,13 +1771,10 @@ void TitleView::MoveColumn(BColumn *column, int32 index)
{ {
fColumns->RemoveItem((void*) column); fColumns->RemoveItem((void*) column);
if (-1 == index) if (-1 == index) {
{
// Re-add the column at the end of the list. // Re-add the column at the end of the list.
fColumns->AddItem((void*) column); fColumns->AddItem((void*) column);
} } else {
else
{
fColumns->AddItem((void*) column, index); fColumns->AddItem((void*) column, index);
} }
} }
@@ -2513,148 +2501,138 @@ void OutlineView::RecursiveDeleteRows(BRowContainer* List, bool IsOwner)
void OutlineView::RedrawColumn(BColumn *column, float leftEdge, bool isFirstColumn) void OutlineView::RedrawColumn(BColumn *column, float leftEdge, bool isFirstColumn)
{ {
if (column) { // TODO: Remove code duplication (private function which takes a view
font_height fh; // pointer, pass "this" in non-double buffered mode)!
GetFontHeight(&fh); // Watch out for sourceRect versus destRect though!
float line = 0.0; if (!column)
for (RecursiveOutlineIterator iterator(&fRows); iterator.CurrentRow(); return;
line += iterator.CurrentRow()->Height() + 1, iterator.GoToNext()) {
BRow *row = iterator.CurrentRow(); font_height fh;
float rowHeight = row->Height(); GetFontHeight(&fh);
if (line > fVisibleRect.bottom) float line = 0.0;
break; bool tintedLine = true;
for (RecursiveOutlineIterator iterator(&fRows); iterator.CurrentRow();
if (line + rowHeight >= fVisibleRect.top) { line += iterator.CurrentRow()->Height() + 1, iterator.GoToNext()) {
BRect sourceRect(0, 0, column->Width(), rowHeight); BRow *row = iterator.CurrentRow();
BRect destRect(leftEdge, line, leftEdge + column->Width(), line + rowHeight); float rowHeight = row->Height();
if (line > fVisibleRect.bottom)
#if DOUBLE_BUFFERED_COLUMN_RESIZE break;
fDrawBuffer->Lock(); tintedLine = !tintedLine;
if (row->fNextSelected != 0) {
if(fEditMode) { if (line + rowHeight >= fVisibleRect.top) {
fDrawBufferView->SetHighColor(fMasterView->Color(B_COLOR_EDIT_BACKGROUND)); BRect sourceRect(0, 0, column->Width(), rowHeight);
fDrawBufferView->SetLowColor(fMasterView->Color(B_COLOR_EDIT_BACKGROUND)); BRect destRect(leftEdge, line, leftEdge + column->Width(), line + rowHeight);
} else {
fDrawBufferView->SetHighColor(fMasterView->Color(B_COLOR_SELECTION)); rgb_color highColor;
fDrawBufferView->SetLowColor(fMasterView->Color(B_COLOR_SELECTION)); rgb_color lowColor;
} if (row->fNextSelected != 0) {
if (fEditMode) {
highColor = fMasterView->Color(B_COLOR_EDIT_BACKGROUND);
lowColor = fMasterView->Color(B_COLOR_EDIT_BACKGROUND);
} else { } else {
fDrawBufferView->SetHighColor(fMasterView->Color(B_COLOR_BACKGROUND)); highColor = fMasterView->Color(B_COLOR_SELECTION);
fDrawBufferView->SetLowColor(fMasterView->Color(B_COLOR_BACKGROUND)); lowColor = fMasterView->Color(B_COLOR_SELECTION);
} }
BFont font; } else {
GetFont(&font); highColor = fMasterView->Color(B_COLOR_BACKGROUND);
fDrawBufferView->SetFont(&font); lowColor = fMasterView->Color(B_COLOR_BACKGROUND);
fDrawBufferView->FillRect(sourceRect); }
if (tintedLine)
if (isFirstColumn) { lowColor = tint_color(lowColor, kTintedLineTint);
// If this is the first column, double buffer drawing the latch too.
destRect.left += iterator.CurrentLevel() * kOutlineLevelIndent
- fMasterView->LatchWidth(); #if DOUBLE_BUFFERED_COLUMN_RESIZE
sourceRect.left += iterator.CurrentLevel() * kOutlineLevelIndent fDrawBuffer->Lock();
- fMasterView->LatchWidth();
fDrawBufferView->SetHighColor(highColor);
LatchType pos = B_NO_LATCH; fDrawBufferView->SetLowColor(lowColor);
if (row->HasLatch())
pos = row->fIsExpanded ? B_OPEN_LATCH : B_CLOSED_LATCH; BFont font;
GetFont(&font);
BRect latchRect(sourceRect); fDrawBufferView->SetFont(&font);
latchRect.right = latchRect.left + fMasterView->LatchWidth(); fDrawBufferView->FillRect(sourceRect, B_SOLID_LOW);
fMasterView->DrawLatch(fDrawBufferView, latchRect, pos, row);
} if (isFirstColumn) {
// If this is the first column, double buffer drawing the latch too.
BField *field = row->GetField(column->fFieldID); destRect.left += iterator.CurrentLevel() * kOutlineLevelIndent
if (field) { - fMasterView->LatchWidth();
BRect fieldRect(sourceRect); sourceRect.left += iterator.CurrentLevel() * kOutlineLevelIndent
if (isFirstColumn) - fMasterView->LatchWidth();
fieldRect.left += fMasterView->LatchWidth();
LatchType pos = B_NO_LATCH;
#if CONSTRAIN_CLIPPING_REGION if (row->HasLatch())
BRegion clipRegion; pos = row->fIsExpanded ? B_OPEN_LATCH : B_CLOSED_LATCH;
clipRegion.Set(fieldRect);
fDrawBufferView->ConstrainClippingRegion(&clipRegion); BRect latchRect(sourceRect);
fDrawBufferView->PushState(); latchRect.right = latchRect.left + fMasterView->LatchWidth();
#endif fMasterView->DrawLatch(fDrawBufferView, latchRect, pos, row);
fDrawBufferView->SetHighColor(fMasterView->Color(row->fNextSelected ? B_COLOR_SELECTION_TEXT : B_COLOR_TEXT)); }
float baseline = floor(fieldRect.top + fh.ascent
+ (fieldRect.Height()+1-(fh.ascent+fh.descent))/2); BField *field = row->GetField(column->fFieldID);
fDrawBufferView->MovePenTo(fieldRect.left + 8, baseline); if (field) {
column->DrawField(field, fieldRect, fDrawBufferView); BRect fieldRect(sourceRect);
#if CONSTRAIN_CLIPPING_REGION if (isFirstColumn)
fDrawBufferView->PopState(); fieldRect.left += fMasterView->LatchWidth();
fDrawBufferView->ConstrainClippingRegion(NULL);
#endif #if CONSTRAIN_CLIPPING_REGION
} BRegion clipRegion;
clipRegion.Set(fieldRect);
if (fFocusRow == row) { fDrawBufferView->ConstrainClippingRegion(&clipRegion);
if(!fEditMode) { fDrawBufferView->PushState();
fDrawBufferView->SetHighColor(fMasterView->Color(B_COLOR_SELECTION_TEXT)); #endif
fDrawBufferView->StrokeRect(BRect(-1, sourceRect.top, 10000.0, sourceRect.bottom - 1)); fDrawBufferView->SetHighColor(fMasterView->Color(row->fNextSelected ? B_COLOR_SELECTION_TEXT : B_COLOR_TEXT));
} float baseline = floor(fieldRect.top + fh.ascent
} + (fieldRect.Height()+1-(fh.ascent+fh.descent))/2);
fDrawBufferView->MovePenTo(fieldRect.left + 8, baseline);
fDrawBufferView->SetHighColor(fMasterView->Color(B_COLOR_ROW_DIVIDER)); column->DrawField(field, fieldRect, fDrawBufferView);
// StrokeLine(BPoint(0, line + rowHeight - 2), BPoint(Bounds().Width(), line + rowHeight - 2)); #if CONSTRAIN_CLIPPING_REGION
// StrokeLine(BPoint(0, line + rowHeight - 1), BPoint(Bounds().Width(), line + rowHeight - 1)); fDrawBufferView->PopState();
fDrawBufferView->StrokeLine(BPoint(0, rowHeight), BPoint(Bounds().right, rowHeight)); fDrawBufferView->ConstrainClippingRegion(NULL);
fDrawBufferView->Sync();
fDrawBuffer->Unlock();
SetDrawingMode(B_OP_OVER);
DrawBitmap(fDrawBuffer, sourceRect, destRect);
#else
if (row->fNextSelected != 0) {
if(fEditMode) {
SetHighColor(fMasterView->Color(B_COLOR_EDIT_BACKGROUND));
SetLowColor(fMasterView->Color(B_COLOR_EDIT_BACKGROUND));
}
else {
SetHighColor(fMasterView->Color(B_COLOR_SELECTION));
SetLowColor(fMasterView->Color(B_COLOR_SELECTION));
}
} else {
SetHighColor(fMasterView->Color(B_COLOR_BACKGROUND));
SetLowColor(fMasterView->Color(B_COLOR_BACKGROUND));
}
FillRect(destRect);
BField *field = row->GetField(column->fFieldID);
if (field) {
#if CONSTRAIN_CLIPPING_REGION
BRegion clipRegion;
clipRegion.Set(destRect);
ConstrainClippingRegion(&clipRegion);
PushState();
#endif
SetHighColor(fColorList[row->fNextSelected ? B_COLOR_SELECTION_TEXT : B_COLOR_TEXT]);
float baseline = floor(destRect.top + fh.ascent
+ (destRect.Height()+1-(fh.ascent+fh.descent))/2);
MovePenTo(destRect.left + 8, baseline);
column->DrawField(field, destRect, this);
#if CONSTRAIN_CLIPPING_REGION
PopState();
ConstrainClippingRegion(NULL);
#endif
}
if (fFocusRow == row) {
if(!fEditMode) {
SetHighColor(fColorList[B_COLOR_SELECTION_TEXT]);
StrokeRect(BRect(0, destRect.top, 10000.0, destRect.bottom - 1));
}
}
rgb_color color = HighColor();
SetHighColor(fMasterView->Color(B_COLOR_ROW_DIVIDER));
// StrokeLine(BPoint(0, line + rowHeight - 2), BPoint(Bounds().Width(), line + rowHeight - 2));
// StrokeLine(BPoint(0, line + rowHeight - 1), BPoint(Bounds().Width(), line + rowHeight - 1));
StrokeLine(BPoint(0, line + rowHeight), BPoint(Bounds().right, line + rowHeight));
SetHighColor(color);
#endif #endif
} }
if (fFocusRow == row && !fEditMode && fMasterView->IsFocus()
&& Window()->IsActive()) {
fDrawBufferView->SetHighColor(fMasterView->Color(B_COLOR_ROW_DIVIDER));
fDrawBufferView->StrokeRect(BRect(-1, sourceRect.top, 10000.0, sourceRect.bottom));
}
fDrawBufferView->Sync();
fDrawBuffer->Unlock();
SetDrawingMode(B_OP_COPY);
DrawBitmap(fDrawBuffer, sourceRect, destRect);
#else
SetHighColor(highColor);
SetLowColor(lowColor);
FillRect(destRect, B_SOLID_LOW);
BField *field = row->GetField(column->fFieldID);
if (field) {
#if CONSTRAIN_CLIPPING_REGION
BRegion clipRegion;
clipRegion.Set(destRect);
ConstrainClippingRegion(&clipRegion);
PushState();
#endif
SetHighColor(fColorList[row->fNextSelected ? B_COLOR_SELECTION_TEXT : B_COLOR_TEXT]);
float baseline = floor(destRect.top + fh.ascent
+ (destRect.Height()+1-(fh.ascent+fh.descent))/2);
MovePenTo(destRect.left + 8, baseline);
column->DrawField(field, destRect, this);
#if CONSTRAIN_CLIPPING_REGION
PopState();
ConstrainClippingRegion(NULL);
#endif
}
if (fFocusRow == row && !fEditMode && fMasterView->IsFocus()
&& Window()->IsActive()) {
SetHighColor(fColorList[B_COLOR_ROW_DIVIDER]);
StrokeRect(BRect(0, destRect.top, 10000.0, destRect.bottom));
}
#endif
} }
} }
} }
@@ -2670,18 +2648,37 @@ void OutlineView::Draw(BRect invalidBounds)
GetFontHeight(&fh); GetFontHeight(&fh);
float line = 0.0; float line = 0.0;
bool tintedLine = true;
int32 numColumns = fColumns->CountItems(); int32 numColumns = fColumns->CountItems();
for (RecursiveOutlineIterator iterator(&fRows); iterator.CurrentRow(); for (RecursiveOutlineIterator iterator(&fRows); iterator.CurrentRow();
iterator.GoToNext()) { iterator.GoToNext()) {
BRow *row = iterator.CurrentRow(); BRow *row = iterator.CurrentRow();
if (line > invalidBounds.bottom) if (line > invalidBounds.bottom)
break; break;
tintedLine = !tintedLine;
float rowHeight = row->Height(); float rowHeight = row->Height();
if (line > invalidBounds.top - rowHeight) { if (line > invalidBounds.top - rowHeight) {
bool isFirstColumn = true; bool isFirstColumn = true;
float fieldLeftEdge = MAX(kLeftMargin, fMasterView->LatchWidth()); float fieldLeftEdge = MAX(kLeftMargin, fMasterView->LatchWidth());
// setup background color
rgb_color lowColor;
if (row->fNextSelected != 0) {
if (Window()->IsActive()) {
if (fEditMode)
lowColor = fMasterView->Color(B_COLOR_EDIT_BACKGROUND);
else
lowColor = fMasterView->Color(B_COLOR_SELECTION);
}
else
lowColor = fMasterView->Color(B_COLOR_NON_FOCUS_SELECTION);
} else
lowColor = fMasterView->Color(B_COLOR_BACKGROUND);
if (tintedLine)
lowColor = tint_color(lowColor, kTintedLineTint);
for (int columnIndex = 0; columnIndex < numColumns; columnIndex++) { for (int columnIndex = 0; columnIndex < numColumns; columnIndex++) {
BColumn *column = (BColumn*) fColumns->ItemAt(columnIndex); BColumn *column = (BColumn*) fColumns->ItemAt(columnIndex);
if (!column->IsVisible()) if (!column->IsVisible())
@@ -2698,17 +2695,7 @@ void OutlineView::Draw(BRect invalidBounds)
// This happens when a column is indented past the // This happens when a column is indented past the
// beginning of the next column. // beginning of the next column.
if (row->fNextSelected != 0) { SetHighColor(lowColor);
if (Window()->IsActive()) {
if(fEditMode)
SetHighColor(fMasterView->Color(B_COLOR_EDIT_BACKGROUND));
else
SetHighColor(fMasterView->Color(B_COLOR_SELECTION));
}
else
SetHighColor(fMasterView->Color(B_COLOR_NON_FOCUS_SELECTION));
} else
SetHighColor(fMasterView->Color(B_COLOR_BACKGROUND));
BRect destRect(fullRect); BRect destRect(fullRect);
if (isFirstColumn) { if (isFirstColumn) {
@@ -2721,7 +2708,6 @@ void OutlineView::Draw(BRect invalidBounds)
clippedFirstColumn = true; clippedFirstColumn = true;
} }
FillRect(BRect(0, line, MAX(kLeftMargin, fMasterView->LatchWidth()), line + row->Height())); FillRect(BRect(0, line, MAX(kLeftMargin, fMasterView->LatchWidth()), line + row->Height()));
} }
@@ -2760,21 +2746,10 @@ void OutlineView::Draw(BRect invalidBounds)
row); row);
} }
} }
if (row->fNextSelected != 0) {
if (Window()->IsActive()) {
if(fEditMode)
SetLowColor(fMasterView->Color(B_COLOR_EDIT_BACKGROUND));
else
SetLowColor(fMasterView->Color(B_COLOR_SELECTION));
}
else
SetLowColor(fMasterView->Color(B_COLOR_NON_FOCUS_SELECTION));
} else
SetLowColor(fMasterView->Color(B_COLOR_BACKGROUND));
SetHighColor(fMasterView->HighColor()); SetHighColor(fMasterView->HighColor());
// The master view just holds the high color for us. // The master view just holds the high color for us.
SetLowColor(lowColor);
BField *field = row->GetField(column->fFieldID); BField *field = row->GetField(column->fFieldID);
if (field) { if (field) {
@@ -2802,39 +2777,23 @@ void OutlineView::Draw(BRect invalidBounds)
} }
if (fieldLeftEdge <= invalidBounds.right) { if (fieldLeftEdge <= invalidBounds.right) {
if (row->fNextSelected != 0) { SetHighColor(lowColor);
if (Window()->IsActive()) {
if(fEditMode)
SetHighColor(fMasterView->Color(B_COLOR_EDIT_BACKGROUND));
else
SetHighColor(fMasterView->Color(B_COLOR_SELECTION));
}
else
SetHighColor(fMasterView->Color(B_COLOR_NON_FOCUS_SELECTION));
} else
SetHighColor(fMasterView->Color(B_COLOR_BACKGROUND));
FillRect(BRect(fieldLeftEdge, line, invalidBounds.right, FillRect(BRect(fieldLeftEdge, line, invalidBounds.right,
line + rowHeight)); line + rowHeight));
} }
} }
if (fFocusRow == row && fMasterView->IsFocus() && Window()->IsActive()) { // indicate the keyboard focus row
if(!fEditMode) { if (fFocusRow == row && !fEditMode && fMasterView->IsFocus() && Window()->IsActive()) {
SetHighColor(fMasterView->Color(B_COLOR_SELECTION_TEXT)); SetHighColor(fMasterView->Color(B_COLOR_ROW_DIVIDER));
StrokeRect(BRect(0, line, 10000.0, line + rowHeight - 1)); StrokeRect(BRect(0, line, 10000.0, line + rowHeight));
}
} }
rgb_color color = HighColor();
SetHighColor(fMasterView->Color(B_COLOR_ROW_DIVIDER));
// StrokeLine(BPoint(0, line + rowHeight - 2), BPoint(Bounds().Width(), line + rowHeight - 2));
// StrokeLine(BPoint(0, line + rowHeight - 1), BPoint(Bounds().Width(), line + rowHeight - 1));
StrokeLine(BPoint(invalidBounds.left, line + rowHeight), BPoint(invalidBounds.right, line + rowHeight));
SetHighColor(color);
line += rowHeight + 1; line += rowHeight + 1;
} }
if (line <= invalidBounds.bottom) { if (line <= invalidBounds.bottom) {
// fill background below last item
SetHighColor(fMasterView->Color(B_COLOR_BACKGROUND)); SetHighColor(fMasterView->Color(B_COLOR_BACKGROUND));
FillRect(BRect(invalidBounds.left, line, invalidBounds.right, invalidBounds.bottom)); FillRect(BRect(invalidBounds.left, line, invalidBounds.right, invalidBounds.bottom));
} }
@@ -3036,24 +2995,24 @@ void OutlineView::MouseDown(BPoint position)
void OutlineView::MouseMoved(BPoint position, uint32 /*transit*/, const BMessage */*message*/) void OutlineView::MouseMoved(BPoint position, uint32 /*transit*/, const BMessage */*message*/)
{ {
if(!fMouseDown) { if (!fMouseDown) {
// Update fCurrentField // Update fCurrentField
bool handle_field = false; bool handle_field = false;
BField *new_field = 0; BField *new_field = 0;
BRow *new_row = 0; BRow *new_row = 0;
BColumn *new_column = 0; BColumn *new_column = 0;
BRect new_rect(0,0,0,0); BRect new_rect(0,0,0,0);
if(position.y >=0 ) { if (position.y >=0 ) {
float top; float top;
int32 indent; int32 indent;
BRow *row = FindRow(position.y, &indent, &top); BRow *row = FindRow(position.y, &indent, &top);
if(row && position.x >=0 ) { if (row && position.x >=0 ) {
float x=0; float x=0;
for(int32 c=0;c<fMasterView->CountColumns();c++) { for (int32 c=0;c<fMasterView->CountColumns();c++) {
new_column = fMasterView->ColumnAt(c); new_column = fMasterView->ColumnAt(c);
if (!new_column->IsVisible()) if (!new_column->IsVisible())
continue; continue;
if((MAX(kLeftMargin, fMasterView->LatchWidth())+x)+new_column->Width() > position.x) { if ((MAX(kLeftMargin, fMasterView->LatchWidth())+x)+new_column->Width() > position.x) {
if(new_column->WantsEvents()) { if(new_column->WantsEvents()) {
new_field = row->GetField(c); new_field = row->GetField(c);
new_row = row; new_row = row;
@@ -3070,9 +3029,9 @@ void OutlineView::MouseMoved(BPoint position, uint32 /*transit*/, const BMessage
} }
// Handle mouse moved // Handle mouse moved
if(handle_field) { if (handle_field) {
if(new_field != fCurrentField) { if (new_field != fCurrentField) {
if(fCurrentField) { if (fCurrentField) {
fCurrentColumn->MouseMoved(fMasterView, fCurrentRow, fCurrentColumn->MouseMoved(fMasterView, fCurrentRow,
fCurrentField, fFieldRect, position, 0, fCurrentCode = B_EXITED_VIEW); fCurrentField, fFieldRect, position, 0, fCurrentCode = B_EXITED_VIEW);
} }
@@ -3091,7 +3050,7 @@ void OutlineView::MouseMoved(BPoint position, uint32 /*transit*/, const BMessage
} }
} }
} else { } else {
if(fCurrentField) { if (fCurrentField) {
fCurrentColumn->MouseMoved(fMasterView, fCurrentRow, fCurrentColumn->MouseMoved(fMasterView, fCurrentRow,
fCurrentField, fFieldRect, position, 0, fCurrentCode = B_EXITED_VIEW); fCurrentField, fFieldRect, position, 0, fCurrentCode = B_EXITED_VIEW);
fCurrentField = 0; fCurrentField = 0;
@@ -3100,11 +3059,10 @@ void OutlineView::MouseMoved(BPoint position, uint32 /*transit*/, const BMessage
} }
} }
} else { } else {
if(fCurrentField) { if (fCurrentField) {
if(fFieldRect.Contains(position)) { if (fFieldRect.Contains(position)) {
if ( fCurrentCode == B_OUTSIDE_VIEW if (fCurrentCode == B_OUTSIDE_VIEW
|| fCurrentCode == B_EXITED_VIEW || fCurrentCode == B_EXITED_VIEW) {
) {
fCurrentColumn->MouseMoved(fMasterView, fCurrentRow, fCurrentColumn->MouseMoved(fMasterView, fCurrentRow,
fCurrentField, fFieldRect, position, 1, fCurrentCode = B_ENTERED_VIEW); fCurrentField, fFieldRect, position, 1, fCurrentCode = B_ENTERED_VIEW);
} else { } else {
@@ -3112,9 +3070,8 @@ void OutlineView::MouseMoved(BPoint position, uint32 /*transit*/, const BMessage
fCurrentField, fFieldRect, position, 1, fCurrentCode = B_INSIDE_VIEW); fCurrentField, fFieldRect, position, 1, fCurrentCode = B_INSIDE_VIEW);
} }
} else { } else {
if ( fCurrentCode == B_INSIDE_VIEW if (fCurrentCode == B_INSIDE_VIEW
|| fCurrentCode == B_ENTERED_VIEW || fCurrentCode == B_ENTERED_VIEW) {
) {
fCurrentColumn->MouseMoved(fMasterView, fCurrentRow, fCurrentColumn->MouseMoved(fMasterView, fCurrentRow,
fCurrentField, fFieldRect, position, 1, fCurrentCode = B_EXITED_VIEW); fCurrentField, fFieldRect, position, 1, fCurrentCode = B_EXITED_VIEW);
} else { } else {
@@ -3125,7 +3082,7 @@ void OutlineView::MouseMoved(BPoint position, uint32 /*transit*/, const BMessage
} }
} }
if(!fEditMode) { if (!fEditMode) {
switch (fCurrentState) { switch (fCurrentState) {
case LATCH_CLICKED: case LATCH_CLICKED:
@@ -3182,8 +3139,7 @@ void OutlineView::MouseMoved(BPoint position, uint32 /*transit*/, const BMessage
BRow *target = FindRow(position.y, &indent, &top); BRow *target = FindRow(position.y, &indent, &top);
if(target==fRollOverRow) if(target==fRollOverRow)
break; break;
if(fRollOverRow) if (fRollOverRow) {
{
BRect rect; BRect rect;
FindRect(fRollOverRow, &rect); FindRect(fRollOverRow, &rect);
Invalidate(rect); Invalidate(rect);
@@ -3202,8 +3158,7 @@ void OutlineView::MouseMoved(BPoint position, uint32 /*transit*/, const BMessage
PopState(); PopState();
#endif #endif
} else { } else {
if(fRollOverRow) if (fRollOverRow) {
{
BRect rect; BRect rect;
FindRect(fRollOverRow, &rect); FindRect(fRollOverRow, &rect);
Invalidate(rect); Invalidate(rect);
@@ -3218,12 +3173,12 @@ void OutlineView::MouseMoved(BPoint position, uint32 /*transit*/, const BMessage
void OutlineView::MouseUp(BPoint position) void OutlineView::MouseUp(BPoint position)
{ {
if(fCurrentField) { if (fCurrentField) {
fCurrentColumn->MouseUp(fMasterView,fCurrentRow,fCurrentField); fCurrentColumn->MouseUp(fMasterView,fCurrentRow,fCurrentField);
fMouseDown = false; fMouseDown = false;
} }
if(!fEditMode) { if (!fEditMode) {
switch (fCurrentState) { switch (fCurrentState) {
case LATCH_CLICKED: case LATCH_CLICKED:
if (fLatchRect.Contains(position)) if (fLatchRect.Contains(position))
@@ -3254,7 +3209,7 @@ void OutlineView::MouseUp(BPoint position)
} }
} }
} }
} // end of MouseUp() }
void OutlineView::MessageReceived(BMessage *message) void OutlineView::MessageReceived(BMessage *message)
{ {
@@ -3453,8 +3408,7 @@ void OutlineView::RemoveRow(BRow *row)
if (parentRow) { if (parentRow) {
if (parentRow->fIsExpanded) if (parentRow->fIsExpanded)
fItemsHeight -= subTreeHeight + 1; fItemsHeight -= subTreeHeight + 1;
} } else {
else {
fItemsHeight -= subTreeHeight + 1; fItemsHeight -= subTreeHeight + 1;
} }
FixScrollBar(false); FixScrollBar(false);
@@ -3791,10 +3745,8 @@ bool OutlineView::FindRect(const BRow *row, BRect *out_rect)
void OutlineView::ScrollTo(const BRow* Row) void OutlineView::ScrollTo(const BRow* Row)
{ {
BRect rect; BRect rect;
if( true == FindRect(Row, &rect) ) if (FindRect(Row, &rect))
{
ScrollTo(BPoint(rect.left, rect.top)); ScrollTo(BPoint(rect.left, rect.top));
}
} }
@@ -3834,12 +3786,11 @@ BRow* OutlineView::FocusRow() const
void OutlineView::SetFocusRow(BRow* Row, bool Select) void OutlineView::SetFocusRow(BRow* Row, bool Select)
{ {
if (Row) if (Row) {
{ if (Select)
if(Select)
AddToSelection(Row); AddToSelection(Row);
if(fFocusRow == Row) if (fFocusRow == Row)
return; return;
Invalidate(fFocusRowRect); // invalidate previous Invalidate(fFocusRowRect); // invalidate previous