From d6f6b835adcb34abfca03207f272614373f38bb1 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Fri, 26 Oct 2012 21:45:09 -0400 Subject: [PATCH] Draw a nice menu background on the inline scroll view and when scroll faster when you push control/option/command and click the little arrow button. --- src/apps/deskbar/BarMenuBar.cpp | 8 +-- src/apps/deskbar/ExpandoMenuBar.cpp | 6 +- src/apps/deskbar/InlineScrollView.cpp | 99 +++++++++++++++++++++------ src/apps/deskbar/InlineScrollView.h | 2 + 4 files changed, 86 insertions(+), 29 deletions(-) diff --git a/src/apps/deskbar/BarMenuBar.cpp b/src/apps/deskbar/BarMenuBar.cpp index ae3689fb0c..ce4932edc2 100644 --- a/src/apps/deskbar/BarMenuBar.cpp +++ b/src/apps/deskbar/BarMenuBar.cpp @@ -170,17 +170,17 @@ TBarMenuBar::RemoveSeperatorItem() void -TBarMenuBar::Draw(BRect rect) +TBarMenuBar::Draw(BRect updateRect) { // want to skip the fancy BMenuBar drawing code. - BMenu::Draw(rect); + BMenu::Draw(updateRect); } void -TBarMenuBar::DrawBackground(BRect rect) +TBarMenuBar::DrawBackground(BRect updateRect) { - BMenu::DrawBackground(rect); + BMenu::DrawBackground(updateRect); } diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp index 1e493fad2f..f2cbca65b9 100644 --- a/src/apps/deskbar/ExpandoMenuBar.cpp +++ b/src/apps/deskbar/ExpandoMenuBar.cpp @@ -741,14 +741,14 @@ TExpandoMenuBar::MenuLayout() const void -TExpandoMenuBar::Draw(BRect update) +TExpandoMenuBar::Draw(BRect updateRect) { - BMenu::Draw(update); + BMenu::Draw(updateRect); } void -TExpandoMenuBar::DrawBackground(BRect) +TExpandoMenuBar::DrawBackground(BRect updateRect) { if (fVertical) return; diff --git a/src/apps/deskbar/InlineScrollView.cpp b/src/apps/deskbar/InlineScrollView.cpp index 7571bea0b6..5d38f40797 100644 --- a/src/apps/deskbar/InlineScrollView.cpp +++ b/src/apps/deskbar/InlineScrollView.cpp @@ -146,11 +146,23 @@ UpScrollArrow::MouseDown(BPoint where) return; TInlineScrollView* parent = dynamic_cast(Parent()); + if (parent == NULL) + return; - if (parent != NULL) { - parent->ScrollBy(-kDefaultScrollStep); - snooze(5000); - } + float smallStep; + float largeStep; + parent->GetSteps(&smallStep, &largeStep); + + BMessage* message = Window()->CurrentMessage(); + int32 modifiers = 0; + message->FindInt32("modifiers", &modifiers); + // pressing the option/command/control key scrolls faster + if ((modifiers & (B_OPTION_KEY | B_COMMAND_KEY | B_CONTROL_KEY)) != 0) + parent->ScrollBy(-largeStep); + else + parent->ScrollBy(-smallStep); + + snooze(5000); } @@ -200,11 +212,23 @@ DownScrollArrow::MouseDown(BPoint where) TInlineScrollView* grandparent = dynamic_cast(Parent()->Parent()); + if (grandparent == NULL) + return; - if (grandparent != NULL) { - grandparent->ScrollBy(kDefaultScrollStep); - snooze(5000); - } + float smallStep; + float largeStep; + grandparent->GetSteps(&smallStep, &largeStep); + + BMessage* message = Window()->CurrentMessage(); + int32 modifiers = 0; + message->FindInt32("modifiers", &modifiers); + // pressing the option/command/control key scrolls faster + if ((modifiers & (B_OPTION_KEY | B_COMMAND_KEY | B_CONTROL_KEY)) != 0) + grandparent->ScrollBy(largeStep); + else + grandparent->ScrollBy(smallStep); + + snooze(5000); } @@ -251,11 +275,23 @@ LeftScrollArrow::MouseDown(BPoint where) return; TInlineScrollView* parent = dynamic_cast(Parent()); + if (parent == NULL) + return; - if (parent != NULL) { - parent->ScrollBy(-kDefaultScrollStep); - snooze(5000); - } + float smallStep; + float largeStep; + parent->GetSteps(&smallStep, &largeStep); + + BMessage* message = Window()->CurrentMessage(); + int32 modifiers = 0; + message->FindInt32("modifiers", &modifiers); + // pressing the option/command/control key scrolls faster + if ((modifiers & (B_OPTION_KEY | B_COMMAND_KEY | B_CONTROL_KEY)) != 0) + parent->ScrollBy(-largeStep); + else + parent->ScrollBy(-smallStep); + + snooze(5000); } @@ -304,11 +340,23 @@ RightScrollArrow::MouseDown(BPoint where) TInlineScrollView* grandparent = dynamic_cast(Parent()->Parent()); + if (grandparent == NULL) + return; - if (grandparent != NULL) { - grandparent->ScrollBy(kDefaultScrollStep); - snooze(5000); - } + float smallStep; + float largeStep; + grandparent->GetSteps(&smallStep, &largeStep); + + BMessage* message = Window()->CurrentMessage(); + int32 modifiers = 0; + message->FindInt32("modifiers", &modifiers); + // pressing the option/command/control key scrolls faster + if ((modifiers & (B_OPTION_KEY | B_COMMAND_KEY | B_CONTROL_KEY)) != 0) + grandparent->ScrollBy(largeStep); + else + grandparent->ScrollBy(smallStep); + + snooze(5000); } @@ -318,7 +366,7 @@ RightScrollArrow::MouseDown(BPoint where) TInlineScrollView::TInlineScrollView(BRect frame, BView* target, enum orientation orientation) : - BView(frame, "inline scroll view", B_FOLLOW_NONE, 0), + BView(frame, "inline scroll view", B_FOLLOW_NONE, B_WILL_DRAW), fTarget(target), fBeginScrollArrow(NULL), fEndScrollArrow(NULL), @@ -375,6 +423,15 @@ TInlineScrollView::DetachedFromWindow() } +void +TInlineScrollView::Draw(BRect updateRect) +{ + BRect frame = Bounds(); + be_control_look->DrawButtonBackground(this, frame, updateRect, + ui_color(B_MENU_BACKGROUND_COLOR)); +} + + // #pragma mark - @@ -481,7 +538,8 @@ TInlineScrollView::DetachScrollers() bool TInlineScrollView::HasScrollers() const { - return fTarget != NULL && fBeginScrollArrow != NULL && fEndScrollArrow != NULL; + return fTarget != NULL && fBeginScrollArrow != NULL + && fEndScrollArrow != NULL; } @@ -498,10 +556,7 @@ TInlineScrollView::GetSteps(float* _smallStep, float* _largeStep) const if (_smallStep != NULL) *_smallStep = fScrollStep; if (_largeStep != NULL) { - if (fTarget != NULL) - *_largeStep = fTarget->Frame().Height() - fScrollStep; - else - *_largeStep = fScrollStep * 2; + *_largeStep = fScrollStep * 3; } } diff --git a/src/apps/deskbar/InlineScrollView.h b/src/apps/deskbar/InlineScrollView.h index e483e0e2f8..0a80cbead5 100644 --- a/src/apps/deskbar/InlineScrollView.h +++ b/src/apps/deskbar/InlineScrollView.h @@ -27,6 +27,8 @@ public: virtual void AttachedToWindow(); virtual void DetachedFromWindow(); + virtual void Draw(BRect updateRect); + void AttachScrollers(); void DetachScrollers(); bool HasScrollers() const;