* 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
|
// save view state into object
|
||||||
BMallocIO stream;
|
BMallocIO stream;
|
||||||
|
|
||||||
if (ViewMode() == kListMode)
|
|
||||||
fViewState->SetListOrigin(LeftTop());
|
|
||||||
else
|
|
||||||
fViewState->SetIconOrigin(LeftTop());
|
|
||||||
|
|
||||||
stream.Seek(0, SEEK_SET);
|
stream.Seek(0, SEEK_SET);
|
||||||
fViewState->ArchiveToStream(&stream);
|
fViewState->ArchiveToStream(&stream);
|
||||||
|
|
||||||
@ -631,7 +626,6 @@ BPoseView::SaveState(AttributeStreamNode *node)
|
|||||||
stream.Position(), stream.Buffer());
|
stream.Position(), stream.Buffer());
|
||||||
|
|
||||||
fStateNeedsSaving = false;
|
fStateNeedsSaving = false;
|
||||||
fViewState->MarkSaved();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -639,12 +633,6 @@ void
|
|||||||
BPoseView::SaveState(BMessage &message) const
|
BPoseView::SaveState(BMessage &message) const
|
||||||
{
|
{
|
||||||
SaveColumnState(message);
|
SaveColumnState(message);
|
||||||
|
|
||||||
if (ViewMode() == kListMode)
|
|
||||||
fViewState->SetListOrigin(LeftTop());
|
|
||||||
else
|
|
||||||
fViewState->SetIconOrigin(LeftTop());
|
|
||||||
|
|
||||||
fViewState->ArchiveToMessage(message);
|
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
|
void
|
||||||
BPoseView::AttachedToWindow()
|
BPoseView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
@ -1504,7 +1505,7 @@ BPoseView::AddPosesCompleted()
|
|||||||
BRect bounds(Bounds());
|
BRect bounds(Bounds());
|
||||||
float lastItemTop = (fPoseList->CountItems() - 1) * fListElemHeight;
|
float lastItemTop = (fPoseList->CountItems() - 1) * fListElemHeight;
|
||||||
if (bounds.top > lastItemTop)
|
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
|
// we must save the current view origin if we come from
|
||||||
// any icon mode. We can't do that in SetViewMode() since
|
// any icon mode. We can't do that in SetViewMode() since
|
||||||
// Refresh() resets the current view origin.
|
// Refresh() resets the current view origin.
|
||||||
|
// TODO: Shouldn't be needed anymore
|
||||||
if (ViewMode() != kListMode)
|
if (ViewMode() != kListMode)
|
||||||
fViewState->SetIconOrigin(LeftTop());
|
fViewState->SetIconOrigin(LeftTop());
|
||||||
|
|
||||||
@ -2727,6 +2729,7 @@ BPoseView::SetViewMode(uint32 newMode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// save the current origin and get origin for new view mode
|
// save the current origin and get origin for new view mode
|
||||||
|
// TODO: shouldn't be needed anymore
|
||||||
BPoint origin(LeftTop());
|
BPoint origin(LeftTop());
|
||||||
BPoint newOrigin(origin);
|
BPoint newOrigin(origin);
|
||||||
|
|
||||||
@ -7221,7 +7224,8 @@ BPoseView::DeletePose(const node_ref *itemNode, BPose *pose, int32 index)
|
|||||||
int32 index = (int32)(bounds.bottom / fListElemHeight);
|
int32 index = (int32)(bounds.bottom / fListElemHeight);
|
||||||
BPose *pose = fPoseList->ItemAt(index);
|
BPose *pose = fPoseList->ItemAt(index);
|
||||||
if (!pose && bounds.top > 0) // scroll up a little
|
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;
|
delete pose;
|
||||||
|
@ -146,6 +146,7 @@ class BPoseView : public BView {
|
|||||||
virtual void KeyDown(const char *, int32);
|
virtual void KeyDown(const char *, int32);
|
||||||
virtual void Pulse();
|
virtual void Pulse();
|
||||||
virtual void MoveBy(float, float);
|
virtual void MoveBy(float, float);
|
||||||
|
virtual void ScrollTo(BPoint point);
|
||||||
|
|
||||||
// misc. mode setters
|
// misc. mode setters
|
||||||
void SetMultipleSelection(bool);
|
void SetMultipleSelection(bool);
|
||||||
|
@ -287,7 +287,8 @@ BViewState::BViewState()
|
|||||||
fSecondarySortAttr = 0;
|
fSecondarySortAttr = 0;
|
||||||
fSecondarySortType = 0;
|
fSecondarySortType = 0;
|
||||||
fReverseSort = false;
|
fReverseSort = false;
|
||||||
fStateNeedsSaving = false;
|
|
||||||
|
_StorePreviousState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -317,8 +318,7 @@ BViewState::BViewState(BMallocIO *stream, bool endianSwap)
|
|||||||
fSecondarySortType = B_SWAP_INT32(fSecondarySortType);
|
fSecondarySortType = B_SWAP_INT32(fSecondarySortType);
|
||||||
}
|
}
|
||||||
|
|
||||||
fStateNeedsSaving = false;
|
_StorePreviousState();
|
||||||
|
|
||||||
_Sanitize(this, true);
|
_Sanitize(this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,8 +334,8 @@ BViewState::BViewState(const BMessage &message)
|
|||||||
message.FindInt32(kViewStateSecondarySortAttrName, (int32 *)&fSecondarySortAttr);
|
message.FindInt32(kViewStateSecondarySortAttrName, (int32 *)&fSecondarySortAttr);
|
||||||
message.FindInt32(kViewStateSecondarySortTypeName, (int32 *)&fSecondarySortType);
|
message.FindInt32(kViewStateSecondarySortTypeName, (int32 *)&fSecondarySortType);
|
||||||
message.FindBool(kViewStateReverseSortName, &fReverseSort);
|
message.FindBool(kViewStateReverseSortName, &fReverseSort);
|
||||||
fStateNeedsSaving = false;
|
|
||||||
|
|
||||||
|
_StorePreviousState();
|
||||||
_Sanitize(this, true);
|
_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 *
|
||||||
BViewState::_Sanitize(BViewState *state, bool fixOnly)
|
BViewState::_Sanitize(BViewState *state, bool fixOnly)
|
||||||
{
|
{
|
||||||
|
@ -133,7 +133,6 @@ class BViewState {
|
|||||||
void SetReverseSort(bool);
|
void SetReverseSort(bool);
|
||||||
|
|
||||||
bool StateNeedsSaving();
|
bool StateNeedsSaving();
|
||||||
void MarkSaved();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static BViewState *_Sanitize(BViewState *state, bool fixOnly = false);
|
static BViewState *_Sanitize(BViewState *state, bool fixOnly = false);
|
||||||
@ -148,7 +147,19 @@ class BViewState {
|
|||||||
uint32 fPrimarySortType;
|
uint32 fPrimarySortType;
|
||||||
uint32 fSecondarySortType;
|
uint32 fSecondarySortType;
|
||||||
bool fReverseSort;
|
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
|
inline void
|
||||||
BViewState::SetViewMode(uint32 mode)
|
BViewState::SetViewMode(uint32 mode)
|
||||||
{
|
{
|
||||||
if (mode != fViewMode)
|
|
||||||
fStateNeedsSaving = true;
|
|
||||||
|
|
||||||
fViewMode = mode;
|
fViewMode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
BViewState::SetLastIconMode(uint32 mode)
|
BViewState::SetLastIconMode(uint32 mode)
|
||||||
{
|
{
|
||||||
if (mode != fLastIconMode)
|
|
||||||
fStateNeedsSaving = true;
|
|
||||||
|
|
||||||
fLastIconMode = mode;
|
fLastIconMode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,79 +316,60 @@ BViewState::SetIconSize(uint32 size)
|
|||||||
inline void
|
inline void
|
||||||
BViewState::SetListOrigin(BPoint newOrigin)
|
BViewState::SetListOrigin(BPoint newOrigin)
|
||||||
{
|
{
|
||||||
if (newOrigin != fListOrigin)
|
|
||||||
fStateNeedsSaving = true;
|
|
||||||
|
|
||||||
fListOrigin = newOrigin;
|
fListOrigin = newOrigin;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
BViewState::SetIconOrigin(BPoint newOrigin)
|
BViewState::SetIconOrigin(BPoint newOrigin)
|
||||||
{
|
{
|
||||||
if (newOrigin != fIconOrigin)
|
|
||||||
fStateNeedsSaving = true;
|
|
||||||
|
|
||||||
fIconOrigin = newOrigin;
|
fIconOrigin = newOrigin;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
BViewState::SetPrimarySort(uint32 attr)
|
BViewState::SetPrimarySort(uint32 attr)
|
||||||
{
|
{
|
||||||
if (attr != fPrimarySortAttr)
|
|
||||||
fStateNeedsSaving = true;
|
|
||||||
|
|
||||||
fPrimarySortAttr = attr;
|
fPrimarySortAttr = attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
BViewState::SetSecondarySort(uint32 attr)
|
BViewState::SetSecondarySort(uint32 attr)
|
||||||
{
|
{
|
||||||
if (attr != fSecondarySortAttr)
|
|
||||||
fStateNeedsSaving = true;
|
|
||||||
|
|
||||||
fSecondarySortAttr = attr;
|
fSecondarySortAttr = attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
BViewState::SetPrimarySortType(uint32 type)
|
BViewState::SetPrimarySortType(uint32 type)
|
||||||
{
|
{
|
||||||
if (type != fPrimarySortType)
|
|
||||||
fStateNeedsSaving = true;
|
|
||||||
|
|
||||||
fPrimarySortType = type;
|
fPrimarySortType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
BViewState::SetSecondarySortType(uint32 type)
|
BViewState::SetSecondarySortType(uint32 type)
|
||||||
{
|
{
|
||||||
if (type != fSecondarySortType)
|
|
||||||
fStateNeedsSaving = true;
|
|
||||||
|
|
||||||
fSecondarySortType = type;
|
fSecondarySortType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
BViewState::SetReverseSort(bool on)
|
BViewState::SetReverseSort(bool on)
|
||||||
{
|
{
|
||||||
if (fReverseSort != on)
|
|
||||||
fStateNeedsSaving = true;
|
|
||||||
|
|
||||||
fReverseSort = on;
|
fReverseSort = on;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
BViewState::StateNeedsSaving()
|
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
|
} // namespace BPrivate
|
||||||
|
|
||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
|
Loading…
Reference in New Issue
Block a user