Tracker: Truncate name better in icon mode, don't draw outside.

The max width of the file name was getting set by the width of the
name column, even in icon mode. Use an arbitrary max width of 30em
for the name field in icon (and mini-icon) mode instead.

Set fValueIsDefined on name and other attributes.

Do not attempt to truncate name if !fValueIsDefined, this means
that the value is "-" to show that it is undefined. We assume this
should fit and there is no way to truncate the value.

If the value is later defined it is marked fDirty to truncate it
to the available space.

Fixes #19431

Change-Id: I4cb7953bc746039600ee578b4fa6b786c802bdf8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9516
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: John Scipione <[email protected]>
This commit is contained in:
John Scipione
2025-07-30 04:02:39 +00:00
parent 08bdab7600
commit f1cc4cf8cb
2 changed files with 32 additions and 9 deletions
+5
View File
@@ -639,6 +639,9 @@ BTextWidget::Draw(BRect eraseRect, BRect textRect, BPoseView* view, BView* drawV
textRect.OffsetBy(offset);
BRegion textRegion(textRect);
drawView->ConstrainClippingRegion(&textRegion);
// We are only concerned with setting the correct text color.
// For active views the selection is drawn as inverse text
@@ -784,4 +787,6 @@ BTextWidget::Draw(BRect eraseRect, BRect textRect, BPoseView* view, BView* drawV
if (direct && clipboardMode != kMoveSelectionTo)
drawView->SetDrawingMode(B_OP_OVER);
}
drawView->ConstrainClippingRegion(NULL);
}
+27 -9
View File
@@ -300,10 +300,9 @@ WidgetAttributeText::~WidgetAttributeText()
const char*
WidgetAttributeText::FittingText(const BPoseView* view)
{
if (fDirty || fColumn->Width() != fOldWidth || CheckSettingsChanged()
|| !fValueIsDefined) {
bool widthChanged = view->ViewMode() == kListMode ? fColumn->Width() != fOldWidth : false;
if (fDirty || widthChanged || CheckSettingsChanged())
CheckViewChanged(view);
}
ASSERT(!fDirty);
return fText.String();
@@ -649,8 +648,11 @@ PathAttributeText::ReadValue(BString* outString)
if (entry.InitCheck() == B_OK && entry.GetPath(&path) == B_OK) {
*outString = path.Path();
TruncateLeaf(outString);
} else
fValueIsDefined = true;
} else {
*outString = "-";
fValueIsDefined = false;
}
fValueDirty = false;
}
@@ -674,10 +676,13 @@ OriginalPathAttributeText::ReadValue(BString* outString)
BPath path;
// get the original path
if (entry.InitCheck() == B_OK && FSGetOriginalPath(&entry, &path) == B_OK)
if (entry.InitCheck() == B_OK && FSGetOriginalPath(&entry, &path) == B_OK) {
*outString = path.Path();
else
fValueIsDefined = true;
} else {
*outString = "-";
fValueIsDefined = false;
}
fValueDirty = false;
}
@@ -709,6 +714,7 @@ KindAttributeText::ReadValue(BString* outString)
*outString = fModel->MimeType();
fValueDirty = false;
fValueIsDefined = true;
}
@@ -746,6 +752,7 @@ NameAttributeText::ReadValue(BString* outString)
*outString = fModel->Name();
fValueDirty = false;
fValueIsDefined = true;
}
@@ -755,7 +762,11 @@ NameAttributeText::FitValue(BString* outString, const BPoseView* view)
if (fValueDirty)
ReadValue(&fFullValueText);
fOldWidth = fColumn->Width();
if (view->ViewMode() != kListMode)
fOldWidth = view->StringWidth("M") * 30;
else
fOldWidth = fColumn->Width();
fTruncatedWidth = TruncString(outString, fFullValueText.String(),
fFullValueText.Length(), view, fOldWidth, B_TRUNCATE_MIDDLE);
fDirty = false;
@@ -839,6 +850,7 @@ RealNameAttributeText::ReadValue(BString* outString)
*outString = fModel->EntryRef()->name;
fValueDirty = false;
fValueIsDefined = true;
}
@@ -897,9 +909,11 @@ OwnerAttributeText::ReadValue(BString* outString)
user << "root";
} else
user << nodeOwner;
*outString = user.String();
fValueDirty = false;
fValueIsDefined = true;
}
@@ -924,9 +938,11 @@ GroupAttributeText::ReadValue(BString* outString)
group << "0";
} else
group << nodeGroup;
*outString = group.String();
fValueDirty = false;
fValueIsDefined = true;
}
#endif // OWNER_GROUP_ATTRIBUTES
@@ -971,6 +987,7 @@ ModeAttributeText::ReadValue(BString* outString)
*outString = buffer;
fValueDirty = false;
fValueIsDefined = true;
}
@@ -1142,8 +1159,7 @@ GenericAttributeText::CheckAttributeChanged()
// fDirty could already be true, in that case we mustn't set it to
// false, even if the attribute text hasn't changed
bool changed = fValue.int64t != tmpValue.int64t
|| tmpString != fFullValueText;
bool changed = fValue.int64t != tmpValue.int64t || tmpString != fFullValueText;
if (changed)
fDirty = true;
@@ -2063,9 +2079,11 @@ VersionAttributeText::ReadValue(BString* outString)
&& info.GetVersionInfo(&version, fAppVersion
? B_APP_VERSION_KIND : B_SYSTEM_VERSION_KIND) == B_OK) {
*outString = version.short_info;
fValueIsDefined = true;
return;
}
}
*outString = "-";
fValueIsDefined = false;
}