Fix7734. Avoid race conditions in ToolBar animation
Signed-off-by: Axel Dörfler <[email protected]>
This commit is contained in:
@@ -210,6 +210,8 @@ ShowImageWindow::ShowImageWindow(BRect frame, const entry_ref& ref,
|
|||||||
else
|
else
|
||||||
fToolBarView->Hide();
|
fToolBarView->Hide();
|
||||||
|
|
||||||
|
fToolBarVisible = fShowToolBar;
|
||||||
|
|
||||||
viewFrame.bottom = contentView->Bounds().bottom;
|
viewFrame.bottom = contentView->Bounds().bottom;
|
||||||
viewFrame.bottom -= B_H_SCROLL_BAR_HEIGHT;
|
viewFrame.bottom -= B_H_SCROLL_BAR_HEIGHT;
|
||||||
|
|
||||||
@@ -1051,12 +1053,9 @@ ShowImageWindow::MessageReceived(BMessage* message)
|
|||||||
if (message->FindFloat("offset", &offset) == B_OK
|
if (message->FindFloat("offset", &offset) == B_OK
|
||||||
&& message->FindBool("show", &show) == B_OK) {
|
&& message->FindBool("show", &show) == B_OK) {
|
||||||
// Compensate rounding errors with the final placement
|
// Compensate rounding errors with the final placement
|
||||||
if (show)
|
fToolBarView->MoveTo(fToolBarView->Frame().left, offset);
|
||||||
fToolBarView->MoveTo(fToolBarView->Frame().left, 0);
|
if (!show)
|
||||||
else {
|
|
||||||
fToolBarView->MoveTo(fToolBarView->Frame().left, offset);
|
|
||||||
fToolBarView->Hide();
|
fToolBarView->Hide();
|
||||||
}
|
|
||||||
BRect frame = fToolBarView->Parent()->Bounds();
|
BRect frame = fToolBarView->Parent()->Bounds();
|
||||||
frame.top = fToolBarView->Frame().bottom + 1;
|
frame.top = fToolBarView->Frame().bottom + 1;
|
||||||
fScrollView->MoveTo(fScrollView->Frame().left, frame.top);
|
fScrollView->MoveTo(fScrollView->Frame().left, frame.top);
|
||||||
@@ -1519,9 +1518,10 @@ ShowImageWindow::_UpdateRatingMenu()
|
|||||||
void
|
void
|
||||||
ShowImageWindow::_SetToolBarVisible(bool visible, bool animate)
|
ShowImageWindow::_SetToolBarVisible(bool visible, bool animate)
|
||||||
{
|
{
|
||||||
if (visible == !fToolBarView->IsHidden())
|
if (visible == fToolBarVisible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
fToolBarVisible = visible;
|
||||||
float diff = fToolBarView->Bounds().Height() + 2;
|
float diff = fToolBarView->Bounds().Height() + 2;
|
||||||
if (!visible)
|
if (!visible)
|
||||||
diff = -diff;
|
diff = -diff;
|
||||||
@@ -1533,14 +1533,13 @@ ShowImageWindow::_SetToolBarVisible(bool visible, bool animate)
|
|||||||
// not to block the window thread.
|
// not to block the window thread.
|
||||||
const float kAnimationOffsets[] = { 0.05, 0.2, 0.5, 0.2, 0.05 };
|
const float kAnimationOffsets[] = { 0.05, 0.2, 0.5, 0.2, 0.05 };
|
||||||
const int32 steps = sizeof(kAnimationOffsets) / sizeof(float);
|
const int32 steps = sizeof(kAnimationOffsets) / sizeof(float);
|
||||||
float originalY = fToolBarView->Frame().top;
|
|
||||||
for (int32 i = 0; i < steps; i++) {
|
for (int32 i = 0; i < steps; i++) {
|
||||||
BMessage message(kMsgSlideToolBar);
|
BMessage message(kMsgSlideToolBar);
|
||||||
message.AddFloat("offset", floorf(diff * kAnimationOffsets[i]));
|
message.AddFloat("offset", floorf(diff * kAnimationOffsets[i]));
|
||||||
PostMessage(&message, this);
|
PostMessage(&message, this);
|
||||||
}
|
}
|
||||||
BMessage finalMessage(kMsgFinishSlidingToolBar);
|
BMessage finalMessage(kMsgFinishSlidingToolBar);
|
||||||
finalMessage.AddFloat("offset", originalY + diff);
|
finalMessage.AddFloat("offset", visible ? 0 : diff);
|
||||||
finalMessage.AddBool("show", visible);
|
finalMessage.AddBool("show", visible);
|
||||||
PostMessage(&finalMessage, this);
|
PostMessage(&finalMessage, this);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ private:
|
|||||||
BMenu* fSlideShowDelayMenu;
|
BMenu* fSlideShowDelayMenu;
|
||||||
BMenu* fRatingMenu;
|
BMenu* fRatingMenu;
|
||||||
ToolBarView* fToolBarView;
|
ToolBarView* fToolBarView;
|
||||||
|
bool fToolBarVisible;
|
||||||
BScrollView* fScrollView;
|
BScrollView* fScrollView;
|
||||||
BScrollBar* fVerticalScrollBar;
|
BScrollBar* fVerticalScrollBar;
|
||||||
ShowImageView* fImageView;
|
ShowImageView* fImageView;
|
||||||
|
|||||||
Reference in New Issue
Block a user