* Rewrote the way BViewState checks if changes needs to be saved on quiting a navigation window (icon mode and
list mode) or switching dir in single window navigation. Fixes the other half of the problem in #2441. Left some todos. I discovered an other bug that can add a random offset after finishing adding poses. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28205 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
64ba396fa7
commit
3d7584da5c
@ -609,11 +609,6 @@ BPoseView::SaveState(AttributeStreamNode *node)
|
||||
// save view state into object
|
||||
BMallocIO stream;
|
||||
|
||||
if (ViewMode() == kListMode)
|
||||
fViewState->SetListOrigin(LeftTop());
|
||||
else
|
||||
fViewState->SetIconOrigin(LeftTop());
|
||||
|
||||
stream.Seek(0, SEEK_SET);
|
||||
fViewState->ArchiveToStream(&stream);
|
||||
|
||||
@ -630,8 +625,7 @@ BPoseView::SaveState(AttributeStreamNode *node)
|
||||
node->Write(viewStateAttr, viewStateAttrForeign, B_RAW_TYPE,
|
||||
stream.Position(), stream.Buffer());
|
||||
|
||||
fStateNeedsSaving = false;
|
||||
fViewState->MarkSaved();
|
||||
fStateNeedsSaving = false;
|
||||
}
|
||||
|
||||
|
||||
@ -639,12 +633,6 @@ void
|
||||
BPoseView::SaveState(BMessage &message) const
|
||||
{
|
||||
SaveColumnState(message);
|
||||
|
||||
if (ViewMode() == kListMode)
|
||||
fViewState->SetListOrigin(LeftTop());
|
||||
else
|
||||
fViewState->SetIconOrigin(LeftTop());
|
||||
|
||||
fViewState->ArchiveToMessage(message);
|
||||
}
|
||||
|
||||
@ -859,6 +847,19 @@ BPoseView::MoveBy(float x, float y)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BPoseView::ScrollTo(BPoint point)
|
||||
{
|
||||
_inherited::ScrollTo(point);
|
||||
|
||||
//keep the view state in sync.
|
||||
if (ViewMode() == kListMode)
|
||||
fViewState->SetListOrigin(LeftTop());
|
||||
else
|
||||
fViewState->SetIconOrigin(LeftTop());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BPoseView::AttachedToWindow()
|
||||
{
|
||||
@ -1504,7 +1505,7 @@ BPoseView::AddPosesCompleted()
|
||||
BRect bounds(Bounds());
|
||||
float lastItemTop = (fPoseList->CountItems() - 1) * fListElemHeight;
|
||||
if (bounds.top > lastItemTop)
|
||||
ScrollTo(bounds.left, max_c(lastItemTop, 0));
|
||||
BView::ScrollTo(bounds.left, max_c(lastItemTop, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1998,6 +1999,7 @@ BPoseView::MessageReceived(BMessage *message)
|
||||
// we must save the current view origin if we come from
|
||||
// any icon mode. We can't do that in SetViewMode() since
|
||||
// Refresh() resets the current view origin.
|
||||
// TODO: Shouldn't be needed anymore
|
||||
if (ViewMode() != kListMode)
|
||||
fViewState->SetIconOrigin(LeftTop());
|
||||
|
||||
@ -2727,6 +2729,7 @@ BPoseView::SetViewMode(uint32 newMode)
|
||||
}
|
||||
|
||||
// save the current origin and get origin for new view mode
|
||||
// TODO: shouldn't be needed anymore
|
||||
BPoint origin(LeftTop());
|
||||
BPoint newOrigin(origin);
|
||||
|
||||
@ -7221,7 +7224,8 @@ BPoseView::DeletePose(const node_ref *itemNode, BPose *pose, int32 index)
|
||||
int32 index = (int32)(bounds.bottom / fListElemHeight);
|
||||
BPose *pose = fPoseList->ItemAt(index);
|
||||
if (!pose && bounds.top > 0) // scroll up a little
|
||||
ScrollTo(bounds.left, max_c(bounds.top - fListElemHeight, 0));
|
||||
BView::ScrollTo(bounds.left,
|
||||
max_c(bounds.top - fListElemHeight, 0));
|
||||
}
|
||||
|
||||
delete pose;
|
||||
|
@ -146,6 +146,7 @@ class BPoseView : public BView {
|
||||
virtual void KeyDown(const char *, int32);
|
||||
virtual void Pulse();
|
||||
virtual void MoveBy(float, float);
|
||||
virtual void ScrollTo(BPoint point);
|
||||
|
||||
// misc. mode setters
|
||||
void SetMultipleSelection(bool);
|
||||
|
@ -287,7 +287,8 @@ BViewState::BViewState()
|
||||
fSecondarySortAttr = 0;
|
||||
fSecondarySortType = 0;
|
||||
fReverseSort = false;
|
||||
fStateNeedsSaving = false;
|
||||
|
||||
_StorePreviousState();
|
||||
}
|
||||
|
||||
|
||||
@ -317,8 +318,7 @@ BViewState::BViewState(BMallocIO *stream, bool endianSwap)
|
||||
fSecondarySortType = B_SWAP_INT32(fSecondarySortType);
|
||||
}
|
||||
|
||||
fStateNeedsSaving = false;
|
||||
|
||||
_StorePreviousState();
|
||||
_Sanitize(this, true);
|
||||
}
|
||||
|
||||
@ -334,8 +334,8 @@ BViewState::BViewState(const BMessage &message)
|
||||
message.FindInt32(kViewStateSecondarySortAttrName, (int32 *)&fSecondarySortAttr);
|
||||
message.FindInt32(kViewStateSecondarySortTypeName, (int32 *)&fSecondarySortType);
|
||||
message.FindBool(kViewStateReverseSortName, &fReverseSort);
|
||||
fStateNeedsSaving = false;
|
||||
|
||||
_StorePreviousState();
|
||||
_Sanitize(this, true);
|
||||
}
|
||||
|
||||
@ -415,6 +415,22 @@ BViewState::InstantiateFromMessage(const BMessage &message)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BViewState::_StorePreviousState()
|
||||
{
|
||||
fPreviousViewMode = fViewMode;
|
||||
fPreviousLastIconMode = fLastIconMode;
|
||||
fPreviousIconSize = fIconSize;
|
||||
fPreviousListOrigin = fListOrigin;
|
||||
fPreviousIconOrigin = fIconOrigin;
|
||||
fPreviousPrimarySortAttr = fPrimarySortAttr;
|
||||
fPreviousSecondarySortAttr = fSecondarySortAttr;
|
||||
fPreviousPrimarySortType = fPrimarySortType;
|
||||
fPreviousSecondarySortType = fSecondarySortType;
|
||||
fPreviousReverseSort = fReverseSort;
|
||||
}
|
||||
|
||||
|
||||
BViewState *
|
||||
BViewState::_Sanitize(BViewState *state, bool fixOnly)
|
||||
{
|
||||
|
@ -133,7 +133,6 @@ class BViewState {
|
||||
void SetReverseSort(bool);
|
||||
|
||||
bool StateNeedsSaving();
|
||||
void MarkSaved();
|
||||
|
||||
private:
|
||||
static BViewState *_Sanitize(BViewState *state, bool fixOnly = false);
|
||||
@ -148,7 +147,19 @@ class BViewState {
|
||||
uint32 fPrimarySortType;
|
||||
uint32 fSecondarySortType;
|
||||
bool fReverseSort;
|
||||
bool fStateNeedsSaving;
|
||||
|
||||
void _StorePreviousState();
|
||||
|
||||
uint32 fPreviousViewMode;
|
||||
uint32 fPreviousLastIconMode;
|
||||
uint32 fPreviousIconSize;
|
||||
BPoint fPreviousListOrigin;
|
||||
BPoint fPreviousIconOrigin;
|
||||
uint32 fPreviousPrimarySortAttr;
|
||||
uint32 fPreviousSecondarySortAttr;
|
||||
uint32 fPreviousPrimarySortType;
|
||||
uint32 fPreviousSecondarySortType;
|
||||
bool fPreviousReverseSort;
|
||||
};
|
||||
|
||||
|
||||
@ -287,18 +298,12 @@ BViewState::ReverseSort() const
|
||||
inline void
|
||||
BViewState::SetViewMode(uint32 mode)
|
||||
{
|
||||
if (mode != fViewMode)
|
||||
fStateNeedsSaving = true;
|
||||
|
||||
fViewMode = mode;
|
||||
}
|
||||
|
||||
inline void
|
||||
BViewState::SetLastIconMode(uint32 mode)
|
||||
{
|
||||
if (mode != fLastIconMode)
|
||||
fStateNeedsSaving = true;
|
||||
|
||||
fLastIconMode = mode;
|
||||
}
|
||||
|
||||
@ -311,79 +316,60 @@ BViewState::SetIconSize(uint32 size)
|
||||
inline void
|
||||
BViewState::SetListOrigin(BPoint newOrigin)
|
||||
{
|
||||
if (newOrigin != fListOrigin)
|
||||
fStateNeedsSaving = true;
|
||||
|
||||
fListOrigin = newOrigin;
|
||||
}
|
||||
|
||||
inline void
|
||||
BViewState::SetIconOrigin(BPoint newOrigin)
|
||||
{
|
||||
if (newOrigin != fIconOrigin)
|
||||
fStateNeedsSaving = true;
|
||||
|
||||
fIconOrigin = newOrigin;
|
||||
}
|
||||
|
||||
inline void
|
||||
BViewState::SetPrimarySort(uint32 attr)
|
||||
{
|
||||
if (attr != fPrimarySortAttr)
|
||||
fStateNeedsSaving = true;
|
||||
|
||||
fPrimarySortAttr = attr;
|
||||
}
|
||||
|
||||
inline void
|
||||
BViewState::SetSecondarySort(uint32 attr)
|
||||
{
|
||||
if (attr != fSecondarySortAttr)
|
||||
fStateNeedsSaving = true;
|
||||
|
||||
fSecondarySortAttr = attr;
|
||||
}
|
||||
|
||||
inline void
|
||||
BViewState::SetPrimarySortType(uint32 type)
|
||||
{
|
||||
if (type != fPrimarySortType)
|
||||
fStateNeedsSaving = true;
|
||||
|
||||
fPrimarySortType = type;
|
||||
}
|
||||
|
||||
inline void
|
||||
BViewState::SetSecondarySortType(uint32 type)
|
||||
{
|
||||
if (type != fSecondarySortType)
|
||||
fStateNeedsSaving = true;
|
||||
|
||||
fSecondarySortType = type;
|
||||
}
|
||||
|
||||
inline void
|
||||
BViewState::SetReverseSort(bool on)
|
||||
{
|
||||
if (fReverseSort != on)
|
||||
fStateNeedsSaving = true;
|
||||
|
||||
fReverseSort = on;
|
||||
}
|
||||
|
||||
inline bool
|
||||
BViewState::StateNeedsSaving()
|
||||
{
|
||||
return fStateNeedsSaving;
|
||||
return (fPreviousViewMode != fViewMode)
|
||||
|| (fPreviousLastIconMode != fLastIconMode)
|
||||
|| (fPreviousIconSize != fIconSize)
|
||||
|| (fPreviousListOrigin != fListOrigin)
|
||||
|| (fPreviousIconOrigin != fIconOrigin)
|
||||
|| (fPreviousPrimarySortAttr != fPrimarySortAttr)
|
||||
|| (fPreviousSecondarySortAttr != fSecondarySortAttr)
|
||||
|| (fPreviousPrimarySortType != fPrimarySortType)
|
||||
|| (fPreviousSecondarySortType != fSecondarySortType)
|
||||
|| (fPreviousReverseSort != fReverseSort);
|
||||
}
|
||||
|
||||
inline void
|
||||
BViewState::MarkSaved()
|
||||
{
|
||||
fStateNeedsSaving = false;
|
||||
}
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
using namespace BPrivate;
|
||||
|
Loading…
Reference in New Issue
Block a user