Tracker: List view icons now grow with font size

* This also removes the mini/large icon mode for list views; it's now
  simply always matching your font size.

Change-Id: Ieedd86cc3a50dd0f950d97bbd9839384d44f8bd3
Reviewed-on: https://review.haiku-os.org/662
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Axel Dörfler 2018-11-04 09:20:37 +00:00 committed by waddlesplash
parent 65d8c2f34f
commit 0f03d737b9
5 changed files with 27 additions and 102 deletions

View File

@ -2142,29 +2142,11 @@ BContainerWindow::AddWindowMenu(BMenu* menu)
item->SetTarget(PoseView());
menu->AddItem(item);
BMenu* listViewMenu = new BMenu(B_TRANSLATE("List view"));
message = new BMessage(kListMode);
message->AddInt32("icon_size", B_MINI_ICON);
item = new BMenuItem(listViewMenu, message);
item->SetShortcut('3', B_COMMAND_KEY);
item = new BMenuItem(B_TRANSLATE("List view"),
new BMessage(kListMode), '3');
item->SetTarget(PoseView());
menu->AddItem(item);
message = new BMessage(kListMode);
message->AddInt32("icon_size", B_MINI_ICON);
item = new BMenuItem(B_TRANSLATE("Mini"), message);
item->SetTarget(PoseView());
listViewMenu->AddItem(item);
message = new BMessage(kListMode);
message->AddInt32("icon_size", B_LARGE_ICON);
item = new BMenuItem(B_TRANSLATE("Large"), message);
item->SetTarget(PoseView());
listViewMenu->AddItem(item);
listViewMenu->SetTargetForItems(PoseView());
menu->AddSeparatorItem();
item = new BMenuItem(B_TRANSLATE("Resize to fit"),
@ -3291,33 +3273,6 @@ BContainerWindow::UpdateMenu(BMenu* menu, UpdateMenuContext context)
}
}
BMenu* listSizeMenu = NULL;
if (BMenuItem* item = menu->FindItem(kListMode))
listSizeMenu = item->Submenu();
if (listSizeMenu != NULL) {
if (viewMode == kListMode) {
int32 iconSize = PoseView()->IconSizeInt();
BMenuItem* item = listSizeMenu->ItemAt(0);
for (int32 i = 0; (item = listSizeMenu->ItemAt(i)) != NULL;
i++) {
BMessage* message = item->Message();
if (message == NULL) {
item->SetMarked(false);
continue;
}
int32 size;
if (message->FindInt32("icon_size", &size) != B_OK)
size = -1;
item->SetMarked(iconSize == size);
}
} else {
BMenuItem* item;
for (int32 i = 0; (item = listSizeMenu->ItemAt(i)) != NULL; i++)
item->SetMarked(false);
}
}
MarkNamedMenuItem(menu, kIconMode, viewMode == kIconMode);
MarkNamedMenuItem(menu, kListMode, viewMode == kListMode);
MarkNamedMenuItem(menu, kMiniIconMode, viewMode == kMiniIconMode);

View File

@ -235,6 +235,7 @@ BPoseView::BPoseView(Model* model, uint32 viewMode)
fCountView(NULL),
fListElemHeight(0.0f),
fIconPoseHeight(0.0f),
fListIconSize(0.0f),
fDropTarget(NULL),
fAlreadySelectedDropTarget(NULL),
fSelectionHandler(be_app),
@ -277,10 +278,12 @@ BPoseView::BPoseView(Model* model, uint32 viewMode)
fDeskbarFrame(0, 0, -1, -1),
fTextWidgetToCheck(NULL)
{
fViewState->SetViewMode(viewMode);
if (viewMode == kIconMode && fViewState->IconSize() == B_MINI_ICON)
fViewState->SetIconSize(B_LARGE_ICON);
fListIconSize = std::max((float)B_MINI_ICON,
B_MINI_ICON * be_plain_font->Size() / 12);
fListElemHeight = std::max(fListIconSize,
ceilf(sFontHeight) < 20 ? 20 : ceilf(sFontHeight * 1.1f));
fViewState->SetViewMode(viewMode);
fShowSelectionWhenInactive
= TrackerSettings().ShowSelectionWhenInactive();
fTransparentSelection = TrackerSettings().TransparentSelection();
@ -345,14 +348,10 @@ BPoseView::InitCommon()
PinPointToValidRange(origin);
// init things related to laying out items
SetIconPoseHeight();
GetLayoutInfo(ViewMode(), &fGrid, &fOffset);
ResetPosePlacementHint();
if (ViewMode() == kListMode)
SetListElemHeight();
DisableScrollBars();
ScrollTo(origin);
UpdateScrollRange();
@ -434,6 +433,7 @@ BPoseView::RestoreColumnState(AttributeStreamNode* node)
}
}
_ResetStartOffset();
SetUpDefaultColumnsIfNeeded();
if (!ColumnFor(PrimarySort())) {
fViewState->SetPrimarySort(FirstColumn()->AttrHash());
@ -461,6 +461,7 @@ BPoseView::RestoreColumnState(const BMessage &message)
AddColumnList(&tempSortedList);
_ResetStartOffset();
SetUpDefaultColumnsIfNeeded();
if (!ColumnFor(PrimarySort())) {
fViewState->SetPrimarySort(FirstColumn()->AttrHash());
@ -1031,7 +1032,7 @@ BPoseView::SetIconPoseHeight()
case kListMode:
default:
{
SetListElemHeight();
fViewState->SetIconSize(fListIconSize);
fIconPoseHeight = fListElemHeight;
break;
}
@ -2251,36 +2252,6 @@ BPoseView::MessageReceived(BMessage* message)
}
case kListMode:
{
uint32 oldMode = fViewState->ViewMode();
int32 oldIconSize = fViewState->IconSize();
int32 iconSize;
if (message->FindInt32("icon_size", &iconSize) == B_OK) {
// sanatize
if ((icon_size)iconSize != B_LARGE_ICON)
iconSize = B_MINI_ICON;
} else
iconSize = B_MINI_ICON;
fViewState->SetIconSize(iconSize);
SetViewMode(message->what);
if (oldMode == kListMode && iconSize == oldIconSize)
break;
if (iconSize == B_MINI_ICON)
ResizeColumn(FirstColumn(), FirstColumn()->Width() - B_MINI_ICON);
else
ResizeColumn(FirstColumn(), FirstColumn()->Width() + B_MINI_ICON);
SetListElemHeight();
Invalidate();
if (fTitleView != NULL && !fTitleView->IsHidden())
fTitleView->Invalidate();
break;
}
case kMiniIconMode:
SetViewMode(message->what);
break;
@ -10479,6 +10450,17 @@ BPoseView::ExcludeTrashFromSelection()
}
/*! Since the start offset of the first column is part of the stored
column state, it has to be corrected to match the current offset
(that depends on the font size).
*/
void
BPoseView::_ResetStartOffset()
{
fColumnList->ItemAt(0)->SetOffset(StartOffset());
}
// #pragma mark - TScrollBar

View File

@ -224,7 +224,6 @@ public:
// returns height, descent, etc.
float FontHeight() const;
float ListElemHeight() const;
void SetListElemHeight();
void SetIconPoseHeight();
float IconPoseHeight() const;
@ -698,6 +697,7 @@ private:
void DrawOpenAnimation(BRect);
void MoveSelectionOrEntryToTrash(const entry_ref* ref, bool selectNext);
void _ResetStartOffset();
protected:
TScrollBar* fHScrollBar;
@ -724,6 +724,7 @@ protected:
BCountView* fCountView;
float fListElemHeight;
float fIconPoseHeight;
float fListIconSize;
BPose* fDropTarget;
BPose* fAlreadySelectedDropTarget;
BLooper* fSelectionHandler;
@ -865,18 +866,6 @@ BPoseView::ListElemHeight() const
}
inline void
BPoseView::SetListElemHeight()
{
float extra = 0;
if (IconSize() > B_MINI_ICON)
extra = kLargeIconSeparator;
fListElemHeight = std::max((float)IconSize() + extra,
ceilf(sFontHeight) < 20 ? 20 : ceilf(sFontHeight * 1.1f));
}
inline float
BPoseView::IconPoseHeight() const
{
@ -1076,7 +1065,7 @@ BPoseView::CountColumns() const
inline float
BPoseView::StartOffset() const
{
return kListOffset + IconSizeInt() + kMiniIconSeparator + 1;
return kListOffset + fListIconSize + kMiniIconSeparator + 1;
}

View File

@ -79,7 +79,6 @@ const int64 kGBSize = 1073741824;
const int64 kTBSize = kGBSize * kKBSize;
const int32 kMiniIconSeparator = 3;
const int32 kLargeIconSeparator = 6;
const color_space kDefaultIconDepth = B_RGBA32;

View File

@ -460,8 +460,8 @@ BViewState::_Init()
{
fViewMode = kListMode;
fLastIconMode = 0;
fIconSize = B_MINI_ICON;
fLastIconSize = B_MINI_ICON;
fIconSize = B_LARGE_ICON;
fLastIconSize = B_LARGE_ICON;
fListOrigin.Set(0, 0);
fIconOrigin.Set(0, 0);
fPrimarySortAttr = AttrHashString(kAttrStatName, B_STRING_TYPE);