[haiku-commits] haiku: hrev45249 - src/apps/showimage

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 7 Feb 2013 23:21:15 +0100 (CET)

hrev45249 adds 1 changeset to branch 'master'
old head: 74e14f5c701c73f1367548e8e7d72ba6434830a2
new head: 956670089702cab586ca0f916a31778bf620880a
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=9566700+%5E74e14f5

----------------------------------------------------------------------------

9566700: Fix7734. Avoid race conditions in ToolBar animation
  
  Signed-off-by: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>

                                                [ Janus <janus2@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev45249
Commit:      956670089702cab586ca0f916a31778bf620880a
URL:         http://cgit.haiku-os.org/haiku/commit/?id=9566700
Author:      Janus <janus2@xxxxxxxxx>
Date:        Sun Dec  2 12:55:06 2012 UTC
Committer:   Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Commit-Date: Thu Feb  7 22:17:57 2013 UTC

----------------------------------------------------------------------------

2 files changed, 8 insertions(+), 8 deletions(-)
src/apps/showimage/ShowImageWindow.cpp | 15 +++++++--------
src/apps/showimage/ShowImageWindow.h   |  1 +

----------------------------------------------------------------------------

diff --git a/src/apps/showimage/ShowImageWindow.cpp 
b/src/apps/showimage/ShowImageWindow.cpp
index 85d4f3c..8464ed2 100644
--- a/src/apps/showimage/ShowImageWindow.cpp
+++ b/src/apps/showimage/ShowImageWindow.cpp
@@ -210,6 +210,8 @@ ShowImageWindow::ShowImageWindow(BRect frame, const 
entry_ref& ref,
        else
                fToolBarView->Hide();
 
+       fToolBarVisible = fShowToolBar;
+
        viewFrame.bottom = contentView->Bounds().bottom;
        viewFrame.bottom -= B_H_SCROLL_BAR_HEIGHT;
 
@@ -1051,12 +1053,9 @@ ShowImageWindow::MessageReceived(BMessage* message)
                        if (message->FindFloat("offset", &offset) == B_OK
                                && message->FindBool("show", &show) == B_OK) {
                                // Compensate rounding errors with the final 
placement
-                               if (show)
-                                       
fToolBarView->MoveTo(fToolBarView->Frame().left, 0);
-                               else {
-                                       
fToolBarView->MoveTo(fToolBarView->Frame().left, offset);
+                               
fToolBarView->MoveTo(fToolBarView->Frame().left, offset);
+                               if (!show)
                                        fToolBarView->Hide();
-                               }
                                BRect frame = fToolBarView->Parent()->Bounds();
                                frame.top = fToolBarView->Frame().bottom + 1;
                                fScrollView->MoveTo(fScrollView->Frame().left, 
frame.top);
@@ -1519,9 +1518,10 @@ ShowImageWindow::_UpdateRatingMenu()
 void
 ShowImageWindow::_SetToolBarVisible(bool visible, bool animate)
 {
-       if (visible == !fToolBarView->IsHidden())
+       if (visible == fToolBarVisible)
                return;
 
+       fToolBarVisible = visible;
        float diff = fToolBarView->Bounds().Height() + 2;
        if (!visible)
                diff = -diff;
@@ -1533,14 +1533,13 @@ ShowImageWindow::_SetToolBarVisible(bool visible, bool 
animate)
                // not to block the window thread.
                const float kAnimationOffsets[] = { 0.05, 0.2, 0.5, 0.2, 0.05 };
                const int32 steps = sizeof(kAnimationOffsets) / sizeof(float);
-               float originalY = fToolBarView->Frame().top;
                for (int32 i = 0; i < steps; i++) {
                        BMessage message(kMsgSlideToolBar);
                        message.AddFloat("offset", floorf(diff * 
kAnimationOffsets[i]));
                        PostMessage(&message, this);
                }
                BMessage finalMessage(kMsgFinishSlidingToolBar);
-               finalMessage.AddFloat("offset", originalY + diff);
+               finalMessage.AddFloat("offset", visible ? 0 : diff);
                finalMessage.AddBool("show", visible);
                PostMessage(&finalMessage, this);
        } else {
diff --git a/src/apps/showimage/ShowImageWindow.h 
b/src/apps/showimage/ShowImageWindow.h
index f5cf499..4834739 100644
--- a/src/apps/showimage/ShowImageWindow.h
+++ b/src/apps/showimage/ShowImageWindow.h
@@ -115,6 +115,7 @@ private:
                        BMenu*                          fSlideShowDelayMenu;
                        BMenu*                          fRatingMenu;
                        ToolBarView*            fToolBarView;
+                       bool                            fToolBarVisible;
                        BScrollView*            fScrollView;
                        BScrollBar*                     fVerticalScrollBar;
                        ShowImageView*          fImageView;


Other related posts:

  • » [haiku-commits] haiku: hrev45249 - src/apps/showimage - axeld