* On date format change, remove the need for the synchronous call to
DrawViewCommon(), simply invalidate since the logic is simplified now, see below. * Reworked the way TimeAttributeText was updated when date format is changed. Got rid of the recalculatText flag propagation, it was broken since forever anyway (was here on r5 max4.1): It was only updating visible poses and wasn't robust in certain cases. Besides, it was cluttering the code on several layers upfront only for date format changes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28402 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
9aec3dd627
commit
e984242155
@ -526,7 +526,7 @@ BPose::PointInPose(BPoint loc, const BPoseView *poseView, BPoint where,
|
||||
|
||||
void
|
||||
BPose::Draw(BRect rect, BPoseView *poseView, BView *drawView, bool fullDraw,
|
||||
const BRegion *updateRgn, BPoint offset, bool selected, bool recalculateText)
|
||||
const BRegion *updateRgn, BPoint offset, bool selected)
|
||||
{
|
||||
// If the background wasn't cleared and Draw() is not called after
|
||||
// having edited a name or similar (with fullDraw)
|
||||
@ -536,7 +536,7 @@ BPose::Draw(BRect rect, BPoseView *poseView, BView *drawView, bool fullDraw,
|
||||
return;
|
||||
} else
|
||||
fBackgroundClean = false;
|
||||
|
||||
|
||||
bool directDraw = (drawView == poseView);
|
||||
bool windowActive = poseView->Window()->IsActive();
|
||||
bool showSelectionWhenInactive = poseView->fShowSelectionWhenInactive;
|
||||
@ -577,9 +577,6 @@ BPose::Draw(BRect rect, BPoseView *poseView, BView *drawView, bool fullDraw,
|
||||
BRect widgetTextRect(widget->CalcRect(rect.LeftTop(), column,
|
||||
poseView));
|
||||
|
||||
if (recalculateText)
|
||||
widget->RecalculateText(poseView);
|
||||
|
||||
bool selectDuringDraw = directDraw && selected
|
||||
&& windowActive;
|
||||
|
||||
|
@ -63,10 +63,10 @@ class BPose {
|
||||
void SetLocation(BPoint);
|
||||
void MoveTo(BPoint, BPoseView *, bool inval = true);
|
||||
|
||||
void Draw(BRect, BPoseView *, bool fullDraw = true, const BRegion * = 0,
|
||||
bool recalculateText = false);
|
||||
void Draw(BRect, BPoseView *, bool fullDraw = true,
|
||||
const BRegion * = 0);
|
||||
void Draw(BRect, BPoseView *, BView *drawView, bool fullDraw,
|
||||
const BRegion *, BPoint offset, bool selected, bool recalculateText = false);
|
||||
const BRegion *, BPoint offset, bool selected);
|
||||
void DeselectWithoutErasingBackground(BRect rect, BPoseView *poseView);
|
||||
// special purpose draw call for deselecting over a textured
|
||||
// background
|
||||
@ -252,11 +252,11 @@ debugger("BPose::SetLocation() - infinite location");
|
||||
|
||||
|
||||
inline void
|
||||
BPose::Draw(BRect rect, BPoseView *view, bool fullDraw, const BRegion *updateRgn,
|
||||
bool recalculateText)
|
||||
BPose::Draw(BRect rect, BPoseView *view, bool fullDraw,
|
||||
const BRegion *updateRgn)
|
||||
{
|
||||
Draw(rect, view, (BView *)view, fullDraw, updateRgn, BPoint(0, 0),
|
||||
IsSelected(), recalculateText);
|
||||
IsSelected());
|
||||
}
|
||||
|
||||
|
||||
|
@ -8143,7 +8143,7 @@ BPoseView::SynchronousUpdate(BRect updateRect, bool clip)
|
||||
|
||||
|
||||
void
|
||||
BPoseView::DrawViewCommon(BRect updateRect, bool recalculateText)
|
||||
BPoseView::DrawViewCommon(const BRect &updateRect)
|
||||
{
|
||||
GetClippingRegion(fUpdateRegion);
|
||||
|
||||
@ -8158,7 +8158,7 @@ BPoseView::DrawViewCommon(BRect updateRect, bool recalculateText)
|
||||
for (int32 index = startIndex; index < count; index++) {
|
||||
BPose *pose = fPoseList->ItemAt(index);
|
||||
BRect poseRect(pose->CalcRect(loc, this, true));
|
||||
pose->Draw(poseRect, this, true, fUpdateRegion, recalculateText);
|
||||
pose->Draw(poseRect, this, true, fUpdateRegion);
|
||||
loc.y += fListElemHeight;
|
||||
if (loc.y >= updateRect.bottom)
|
||||
break;
|
||||
@ -9213,7 +9213,7 @@ BPoseView::UpdateDateColumns(BMessage *message)
|
||||
if (col && col->AttrType() == B_TIME_TYPE) {
|
||||
columnRect.left = col->Offset();
|
||||
columnRect.right = columnRect.left + col->Width();
|
||||
DrawViewCommon(columnRect, true); // true means recalculate texts.
|
||||
Invalidate(columnRect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -471,7 +471,7 @@ class BPoseView : public BView {
|
||||
// pose handling
|
||||
BRect CalcPoseRect(BPose *, int32 index, bool minimal = false) const;
|
||||
void DrawPose(BPose *, int32 index, bool fullDraw = true);
|
||||
void DrawViewCommon(BRect, bool recalculateText = false);
|
||||
void DrawViewCommon(const BRect &updateRect);
|
||||
|
||||
// pose list handling
|
||||
int32 BSearchList(const BPose *, int32 *index);
|
||||
|
@ -83,14 +83,6 @@ BTextWidget::Compare(const BTextWidget &with, BPoseView *view) const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BTextWidget::RecalculateText(const BPoseView *view)
|
||||
{
|
||||
fText->SetDirty(true);
|
||||
fText->CheckViewChanged(view);
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
BTextWidget::Text(const BPoseView *view) const
|
||||
{
|
||||
|
@ -91,8 +91,6 @@ public:
|
||||
float PreferredWidth(const BPoseView *) const;
|
||||
int Compare(const BTextWidget &, BPoseView *) const;
|
||||
// used for sorting in PoseViews
|
||||
|
||||
void RecalculateText(const BPoseView *view);
|
||||
|
||||
private:
|
||||
BRect CalcRectCommon(BPoint poseLoc, const BColumn *, const BPoseView *, float width);
|
||||
|
@ -155,7 +155,8 @@ WidgetAttributeText::~WidgetAttributeText()
|
||||
const char *
|
||||
WidgetAttributeText::FittingText(const BPoseView *view)
|
||||
{
|
||||
if (fDirty || fColumn->Width() != fOldWidth || !fValueIsDefined)
|
||||
if (fDirty || fColumn->Width() != fOldWidth || CheckSettingsChanged()
|
||||
|| !fValueIsDefined )
|
||||
CheckViewChanged(view);
|
||||
|
||||
ASSERT(!fDirty);
|
||||
@ -168,7 +169,6 @@ WidgetAttributeText::CheckViewChanged(const BPoseView *view)
|
||||
{
|
||||
BString newText;
|
||||
FitValue(&newText, view);
|
||||
|
||||
if (newText == fText)
|
||||
return false;
|
||||
|
||||
@ -177,6 +177,13 @@ WidgetAttributeText::CheckViewChanged(const BPoseView *view)
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
WidgetAttributeText::CheckSettingsChanged()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
WidgetAttributeText::TruncString(BString *result, const char *str,
|
||||
int32 length, const BPoseView *view, float width, uint32 truncMode)
|
||||
@ -1087,6 +1094,23 @@ TimeAttributeText::FitValue(BString *result, const BPoseView *view)
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TimeAttributeText::CheckSettingsChanged()
|
||||
{
|
||||
bool changed = fLastClockIs24 != fSettings.ClockIs24Hr()
|
||||
|| fLastDateOrder != fSettings.DateOrderFormat()
|
||||
|| fLastTimeFormatSeparator != fSettings.TimeFormatSeparator();
|
||||
|
||||
if (changed) {
|
||||
fLastClockIs24 = fSettings.ClockIs24Hr();
|
||||
fLastDateOrder = fSettings.DateOrderFormat();
|
||||
fLastTimeFormatSeparator = fSettings.TimeFormatSeparator();
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
CreationTimeAttributeText::CreationTimeAttributeText(const Model *model,
|
||||
const BColumn *column)
|
||||
: TimeAttributeText(model, column)
|
||||
|
@ -66,6 +66,9 @@ class WidgetAttributeText {
|
||||
// returns true if fitted text changed, either because value
|
||||
// changed or because width/view changed
|
||||
|
||||
virtual bool CheckSettingsChanged();
|
||||
// override if the text rendering depends on a setting
|
||||
|
||||
const char *FittingText(const BPoseView *);
|
||||
// returns text, recalculating if not yet calculated
|
||||
|
||||
@ -233,10 +236,17 @@ class GenericAttributeText : public StringAttributeText {
|
||||
|
||||
|
||||
class TimeAttributeText : public ScalarAttributeText {
|
||||
protected:
|
||||
public:
|
||||
TimeAttributeText(const Model *, const BColumn *);
|
||||
protected:
|
||||
virtual float PreferredWidth(const BPoseView *) const;
|
||||
virtual void FitValue(BString *result, const BPoseView *);
|
||||
virtual bool CheckSettingsChanged();
|
||||
|
||||
TrackerSettings fSettings;
|
||||
bool fLastClockIs24;
|
||||
DateOrder fLastDateOrder;
|
||||
FormatSeparator fLastTimeFormatSeparator;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user