Renamed BMenuScrollView to TScrollArrowView and moved it into Deskbar
Also gave the Up Arrow and Down Arrow a scroll arrow. The up arrow works but the down arrow doesn't because the sibling menu is stealing the MouseDown event."
This commit is contained in:
@@ -48,7 +48,6 @@ All rights reserved.
|
|||||||
#include <NodeInfo.h>
|
#include <NodeInfo.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
#include <MenuScrollView.h>
|
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include "icons.h"
|
#include "icons.h"
|
||||||
@@ -60,6 +59,7 @@ All rights reserved.
|
|||||||
#include "ExpandoMenuBar.h"
|
#include "ExpandoMenuBar.h"
|
||||||
#include "FSUtils.h"
|
#include "FSUtils.h"
|
||||||
#include "ResourceSet.h"
|
#include "ResourceSet.h"
|
||||||
|
#include "ScrollArrowView.h"
|
||||||
#include "StatusView.h"
|
#include "StatusView.h"
|
||||||
#include "TeamMenuItem.h"
|
#include "TeamMenuItem.h"
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ BarViewMessageFilter::Filter(BMessage* message, BHandler** target)
|
|||||||
TBarView::TBarView(BRect frame, bool vertical, bool left, bool top,
|
TBarView::TBarView(BRect frame, bool vertical, bool left, bool top,
|
||||||
uint32 state, float)
|
uint32 state, float)
|
||||||
: BView(frame, "BarView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW),
|
: BView(frame, "BarView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW),
|
||||||
fMenuScrollView(NULL),
|
fScrollArrowView(NULL),
|
||||||
fBarMenuBar(NULL),
|
fBarMenuBar(NULL),
|
||||||
fExpando(NULL),
|
fExpando(NULL),
|
||||||
fTrayLocation(1),
|
fTrayLocation(1),
|
||||||
@@ -450,10 +450,10 @@ TBarView::PlaceApplicationBar()
|
|||||||
fExpando = NULL;
|
fExpando = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fMenuScrollView != NULL) {
|
if (fScrollArrowView != NULL) {
|
||||||
fMenuScrollView->RemoveSelf();
|
fScrollArrowView->RemoveSelf();
|
||||||
delete fMenuScrollView;
|
delete fScrollArrowView;
|
||||||
fMenuScrollView = NULL;
|
fScrollArrowView = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BRect screenFrame = (BScreen(Window())).Frame();
|
BRect screenFrame = (BScreen(Window())).Frame();
|
||||||
@@ -500,8 +500,8 @@ TBarView::PlaceApplicationBar()
|
|||||||
fExpando = new TExpandoMenuBar(this, expandoFrame, "ExpandoMenuBar",
|
fExpando = new TExpandoMenuBar(this, expandoFrame, "ExpandoMenuBar",
|
||||||
fVertical, !hideLabels && fState != kFullState);
|
fVertical, !hideLabels && fState != kFullState);
|
||||||
|
|
||||||
fMenuScrollView = new BMenuScrollView(menuScrollFrame, fExpando);
|
fScrollArrowView = new TScrollArrowView(menuScrollFrame, fExpando);
|
||||||
AddChild(fMenuScrollView);
|
AddChild(fScrollArrowView);
|
||||||
|
|
||||||
if (fVertical)
|
if (fVertical)
|
||||||
ExpandItems();
|
ExpandItems();
|
||||||
@@ -573,9 +573,9 @@ TBarView::SizeWindow(BRect screenFrame)
|
|||||||
|
|
||||||
if (fExpando != NULL) {
|
if (fExpando != NULL) {
|
||||||
if (fExpando->CheckForSizeOverrun())
|
if (fExpando->CheckForSizeOverrun())
|
||||||
fMenuScrollView->AttachScrollers();
|
fScrollArrowView->AttachScrollers();
|
||||||
else
|
else
|
||||||
fMenuScrollView->DetachScrollers();
|
fScrollArrowView->DetachScrollers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,12 +65,12 @@ const float kStatusHeight = 22.0f;
|
|||||||
const float kHiddenDimension = 1.0f;
|
const float kHiddenDimension = 1.0f;
|
||||||
const float kMaxPreventHidingDist = 80.0f;
|
const float kMaxPreventHidingDist = 80.0f;
|
||||||
|
|
||||||
class BMenuScrollView;
|
|
||||||
class BShelf;
|
class BShelf;
|
||||||
class TBarMenuBar;
|
class TBarMenuBar;
|
||||||
class TExpandoMenuBar;
|
class TExpandoMenuBar;
|
||||||
class TReplicantTray;
|
class TReplicantTray;
|
||||||
class TDragRegion;
|
class TDragRegion;
|
||||||
|
class TScrollArrowView;
|
||||||
class TTeamMenuItem;
|
class TTeamMenuItem;
|
||||||
|
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ class TBarView : public BView {
|
|||||||
void ExpandItems();
|
void ExpandItems();
|
||||||
void _ChangeState(BMessage* message);
|
void _ChangeState(BMessage* message);
|
||||||
|
|
||||||
BMenuScrollView* fMenuScrollView;
|
TScrollArrowView* fScrollArrowView;
|
||||||
TBarMenuBar* fBarMenuBar;
|
TBarMenuBar* fBarMenuBar;
|
||||||
TExpandoMenuBar* fExpando;
|
TExpandoMenuBar* fExpando;
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ All rights reserved.
|
|||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
#include <ControlLook.h>
|
#include <ControlLook.h>
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <MenuScrollView.h>
|
|
||||||
#include <NodeInfo.h>
|
#include <NodeInfo.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
@@ -56,6 +55,7 @@ All rights reserved.
|
|||||||
#include "DeskbarMenu.h"
|
#include "DeskbarMenu.h"
|
||||||
#include "DeskbarUtils.h"
|
#include "DeskbarUtils.h"
|
||||||
#include "ResourceSet.h"
|
#include "ResourceSet.h"
|
||||||
|
#include "ScrollArrowView.h"
|
||||||
#include "ShowHideMenuItem.h"
|
#include "ShowHideMenuItem.h"
|
||||||
#include "StatusView.h"
|
#include "StatusView.h"
|
||||||
#include "TeamMenuItem.h"
|
#include "TeamMenuItem.h"
|
||||||
@@ -269,8 +269,8 @@ TExpandoMenuBar::MessageReceived(BMessage* message)
|
|||||||
if (deltaY == 0)
|
if (deltaY == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BMenuScrollView* scrollMenu
|
TScrollArrowView* scrollMenu
|
||||||
= dynamic_cast<BMenuScrollView*>(Parent());
|
= dynamic_cast<TScrollArrowView*>(Parent());
|
||||||
if (scrollMenu == NULL)
|
if (scrollMenu == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -284,7 +284,7 @@ TExpandoMenuBar::MessageReceived(BMessage* message)
|
|||||||
else
|
else
|
||||||
deltaY *= smallStep;
|
deltaY *= smallStep;
|
||||||
|
|
||||||
scrollMenu->TryScrollBy(deltaY);
|
scrollMenu->ScrollBy(deltaY);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ Application Deskbar :
|
|||||||
DeskbarUtils.cpp
|
DeskbarUtils.cpp
|
||||||
ExpandoMenuBar.cpp
|
ExpandoMenuBar.cpp
|
||||||
PreferencesWindow.cpp
|
PreferencesWindow.cpp
|
||||||
|
ScrollArrowView.cpp
|
||||||
ShowHideMenuItem.cpp
|
ShowHideMenuItem.cpp
|
||||||
StatusView.cpp
|
StatusView.cpp
|
||||||
StatusViewShelf.cpp
|
StatusViewShelf.cpp
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011, Haiku, Inc.
|
* Copyright 2012, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <MenuScrollView.h>
|
#include "ScrollArrowView.h"
|
||||||
|
|
||||||
#include <ControlLook.h>
|
#include <ControlLook.h>
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
@@ -24,10 +24,10 @@ const int kDefaultScrollStep = 19;
|
|||||||
const int kScrollerHeight = 12;
|
const int kScrollerHeight = 12;
|
||||||
|
|
||||||
|
|
||||||
class BMenuScroller : public BView {
|
class ScrollArrow : public BView {
|
||||||
public:
|
public:
|
||||||
BMenuScroller(BRect frame);
|
ScrollArrow(BRect frame);
|
||||||
virtual ~BMenuScroller();
|
virtual ~ScrollArrow();
|
||||||
|
|
||||||
bool IsEnabled() const { return fEnabled; };
|
bool IsEnabled() const { return fEnabled; };
|
||||||
void SetEnabled(bool enabled);
|
void SetEnabled(bool enabled);
|
||||||
@@ -37,28 +37,30 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class BMenuUpScroller : public BMenuScroller {
|
class UpScrollArrow : public ScrollArrow {
|
||||||
public:
|
public:
|
||||||
BMenuUpScroller(BRect frame);
|
UpScrollArrow(BRect frame);
|
||||||
virtual ~BMenuUpScroller();
|
virtual ~UpScrollArrow();
|
||||||
|
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
|
virtual void MouseDown(BPoint where);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class BMenuDownScroller : public BMenuScroller {
|
class DownScrollArrow : public ScrollArrow {
|
||||||
public:
|
public:
|
||||||
BMenuDownScroller(BRect frame);
|
DownScrollArrow(BRect frame);
|
||||||
virtual ~BMenuDownScroller();
|
virtual ~DownScrollArrow();
|
||||||
|
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
|
virtual void MouseDown(BPoint where);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
BMenuScroller::BMenuScroller(BRect frame)
|
ScrollArrow::ScrollArrow(BRect frame)
|
||||||
:
|
:
|
||||||
BView(frame, "menu scroll arrow", 0, B_WILL_DRAW | B_FRAME_EVENTS),
|
BView(frame, "menu scroll arrow", 0, B_WILL_DRAW | B_FRAME_EVENTS),
|
||||||
fEnabled(false)
|
fEnabled(false)
|
||||||
@@ -67,13 +69,13 @@ BMenuScroller::BMenuScroller(BRect frame)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMenuScroller::~BMenuScroller()
|
ScrollArrow::~ScrollArrow()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenuScroller::SetEnabled(bool enabled)
|
ScrollArrow::SetEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
fEnabled = enabled;
|
fEnabled = enabled;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
@@ -83,20 +85,20 @@ BMenuScroller::SetEnabled(bool enabled)
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
BMenuUpScroller::BMenuUpScroller(BRect frame)
|
UpScrollArrow::UpScrollArrow(BRect frame)
|
||||||
:
|
:
|
||||||
BMenuScroller(frame)
|
ScrollArrow(frame)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMenuUpScroller::~BMenuUpScroller()
|
UpScrollArrow::~UpScrollArrow()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenuUpScroller::Draw(BRect updateRect)
|
UpScrollArrow::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
SetLowColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_1_TINT));
|
SetLowColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_1_TINT));
|
||||||
|
|
||||||
@@ -117,23 +119,34 @@ BMenuUpScroller::Draw(BRect updateRect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
UpScrollArrow::MouseDown(BPoint where)
|
||||||
|
{
|
||||||
|
if (!IsEnabled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
dynamic_cast<TScrollArrowView*>(Parent())->ScrollBy(-kDefaultScrollStep);
|
||||||
|
snooze(5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
BMenuDownScroller::BMenuDownScroller(BRect frame)
|
DownScrollArrow::DownScrollArrow(BRect frame)
|
||||||
:
|
:
|
||||||
BMenuScroller(frame)
|
ScrollArrow(frame)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMenuDownScroller::~BMenuDownScroller()
|
DownScrollArrow::~DownScrollArrow()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenuDownScroller::Draw(BRect updateRect)
|
DownScrollArrow::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
SetLowColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_1_TINT));
|
SetLowColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_1_TINT));
|
||||||
|
|
||||||
@@ -155,15 +168,26 @@ BMenuDownScroller::Draw(BRect updateRect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DownScrollArrow::MouseDown(BPoint where)
|
||||||
|
{
|
||||||
|
if (!IsEnabled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
dynamic_cast<TScrollArrowView*>(Parent())->ScrollBy(kDefaultScrollStep);
|
||||||
|
snooze(5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
BMenuScrollView::BMenuScrollView(BRect frame, BMenu* menu)
|
TScrollArrowView::TScrollArrowView(BRect frame, BMenu* menu)
|
||||||
:
|
:
|
||||||
BView(frame, "menu scroll view", B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS),
|
BView(frame, "menu scroll view", B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS),
|
||||||
fMenu(menu),
|
fMenu(menu),
|
||||||
fUpperScroller(NULL),
|
fUpperScrollArrow(NULL),
|
||||||
fLowerScroller(NULL),
|
fLowerScrollArrow(NULL),
|
||||||
fScrollStep(kDefaultScrollStep),
|
fScrollStep(kDefaultScrollStep),
|
||||||
fValue(0),
|
fValue(0),
|
||||||
fLimit(0)
|
fLimit(0)
|
||||||
@@ -171,24 +195,24 @@ BMenuScrollView::BMenuScrollView(BRect frame, BMenu* menu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMenuScrollView::~BMenuScrollView()
|
TScrollArrowView::~TScrollArrowView()
|
||||||
{
|
{
|
||||||
if (fUpperScroller != NULL) {
|
if (fUpperScrollArrow != NULL) {
|
||||||
fUpperScroller->RemoveSelf();
|
fUpperScrollArrow->RemoveSelf();
|
||||||
delete fUpperScroller;
|
delete fUpperScrollArrow;
|
||||||
fUpperScroller = NULL;
|
fUpperScrollArrow = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fLowerScroller != NULL) {
|
if (fLowerScrollArrow != NULL) {
|
||||||
fLowerScroller->RemoveSelf();
|
fLowerScrollArrow->RemoveSelf();
|
||||||
delete fLowerScroller;
|
delete fLowerScrollArrow;
|
||||||
fLowerScroller = NULL;
|
fLowerScrollArrow = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenuScrollView::AttachedToWindow()
|
TScrollArrowView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
BView::AttachedToWindow();
|
BView::AttachedToWindow();
|
||||||
|
|
||||||
@@ -201,18 +225,18 @@ BMenuScrollView::AttachedToWindow()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenuScrollView::DetachedFromWindow()
|
TScrollArrowView::DetachedFromWindow()
|
||||||
{
|
{
|
||||||
BView::DetachedFromWindow();
|
BView::DetachedFromWindow();
|
||||||
|
|
||||||
if (fMenu != NULL)
|
if (fMenu != NULL)
|
||||||
fMenu->RemoveSelf();
|
fMenu->RemoveSelf();
|
||||||
|
|
||||||
if (fUpperScroller != NULL)
|
if (fUpperScrollArrow != NULL)
|
||||||
fUpperScroller->RemoveSelf();
|
fUpperScrollArrow->RemoveSelf();
|
||||||
|
|
||||||
if (fLowerScroller != NULL)
|
if (fLowerScrollArrow != NULL)
|
||||||
fLowerScroller->RemoveSelf();
|
fLowerScrollArrow->RemoveSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -220,7 +244,7 @@ BMenuScrollView::DetachedFromWindow()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenuScrollView::AttachScrollers()
|
TScrollArrowView::AttachScrollers()
|
||||||
{
|
{
|
||||||
if (fMenu == NULL)
|
if (fMenu == NULL)
|
||||||
return;
|
return;
|
||||||
@@ -236,23 +260,23 @@ BMenuScrollView::AttachScrollers()
|
|||||||
|
|
||||||
fMenu->MakeFocus(true);
|
fMenu->MakeFocus(true);
|
||||||
|
|
||||||
if (fUpperScroller == NULL) {
|
if (fUpperScrollArrow == NULL) {
|
||||||
fUpperScroller = new BMenuUpScroller(
|
fUpperScrollArrow = new UpScrollArrow(
|
||||||
BRect(0, 0, frame.right, kScrollerHeight - 1));
|
BRect(0, 0, frame.right, kScrollerHeight - 1));
|
||||||
AddChild(fUpperScroller, fMenu);
|
AddChild(fUpperScrollArrow);
|
||||||
}
|
}
|
||||||
|
|
||||||
fMenu->MoveBy(0, kScrollerHeight);
|
fMenu->MoveBy(0, kScrollerHeight);
|
||||||
|
|
||||||
if (fLowerScroller == NULL) {
|
if (fLowerScrollArrow == NULL) {
|
||||||
fLowerScroller = new BMenuDownScroller(
|
fLowerScrollArrow = new DownScrollArrow(
|
||||||
BRect(0, frame.bottom - kScrollerHeight + 1, frame.right,
|
BRect(0, frame.bottom - kScrollerHeight + 1, frame.right,
|
||||||
frame.bottom));
|
frame.bottom));
|
||||||
AddChild(fLowerScroller);
|
AddChild(fLowerScrollArrow, fMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
fUpperScroller->SetEnabled(false);
|
fUpperScrollArrow->SetEnabled(false);
|
||||||
fLowerScroller->SetEnabled(true);
|
fLowerScrollArrow->SetEnabled(true);
|
||||||
|
|
||||||
fLimit = Window()->Frame().bottom + 2 * kScrollerHeight
|
fLimit = Window()->Frame().bottom + 2 * kScrollerHeight
|
||||||
- screenFrame.bottom;
|
- screenFrame.bottom;
|
||||||
@@ -261,21 +285,21 @@ BMenuScrollView::AttachScrollers()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenuScrollView::DetachScrollers()
|
TScrollArrowView::DetachScrollers()
|
||||||
{
|
{
|
||||||
if (!HasScrollers())
|
if (!HasScrollers())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fLowerScroller) {
|
if (fLowerScrollArrow) {
|
||||||
fLowerScroller->RemoveSelf();
|
fLowerScrollArrow->RemoveSelf();
|
||||||
delete fLowerScroller;
|
delete fLowerScrollArrow;
|
||||||
fLowerScroller = NULL;
|
fLowerScrollArrow = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fUpperScroller) {
|
if (fUpperScrollArrow) {
|
||||||
fUpperScroller->RemoveSelf();
|
fUpperScrollArrow->RemoveSelf();
|
||||||
delete fUpperScroller;
|
delete fUpperScrollArrow;
|
||||||
fUpperScroller = NULL;
|
fUpperScrollArrow = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fMenu) {
|
if (fMenu) {
|
||||||
@@ -289,21 +313,21 @@ BMenuScrollView::DetachScrollers()
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BMenuScrollView::HasScrollers() const
|
TScrollArrowView::HasScrollers() const
|
||||||
{
|
{
|
||||||
return fMenu != NULL && fUpperScroller != NULL && fLowerScroller != NULL;
|
return fMenu != NULL && fUpperScrollArrow != NULL && fLowerScrollArrow != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenuScrollView::SetSmallStep(float step)
|
TScrollArrowView::SetSmallStep(float step)
|
||||||
{
|
{
|
||||||
fScrollStep = step;
|
fScrollStep = step;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenuScrollView::GetSteps(float* _smallStep, float* _largeStep) const
|
TScrollArrowView::GetSteps(float* _smallStep, float* _largeStep) const
|
||||||
{
|
{
|
||||||
if (_smallStep != NULL)
|
if (_smallStep != NULL)
|
||||||
*_smallStep = fScrollStep;
|
*_smallStep = fScrollStep;
|
||||||
@@ -316,8 +340,45 @@ BMenuScrollView::GetSteps(float* _smallStep, float* _largeStep) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TScrollArrowView::ScrollBy(const float& step)
|
||||||
|
{
|
||||||
|
if (!HasScrollers())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (step > 0) {
|
||||||
|
if (fValue == 0)
|
||||||
|
fUpperScrollArrow->SetEnabled(true);
|
||||||
|
|
||||||
|
if (fValue + step >= fLimit) {
|
||||||
|
// If we reached the limit, only scroll to the end
|
||||||
|
fMenu->ScrollBy(0, fLimit - fValue);
|
||||||
|
fValue = fLimit;
|
||||||
|
fLowerScrollArrow->SetEnabled(false);
|
||||||
|
} else {
|
||||||
|
fMenu->ScrollBy(0, step);
|
||||||
|
fValue += step;
|
||||||
|
}
|
||||||
|
fMenu->Invalidate();
|
||||||
|
} else if (step < 0) {
|
||||||
|
if (fValue == fLimit)
|
||||||
|
fLowerScrollArrow->SetEnabled(true);
|
||||||
|
|
||||||
|
if (fValue + step <= 0) {
|
||||||
|
fMenu->ScrollBy(0, -fValue);
|
||||||
|
fValue = 0;
|
||||||
|
fUpperScrollArrow->SetEnabled(false);
|
||||||
|
} else {
|
||||||
|
fMenu->ScrollBy(0, step);
|
||||||
|
fValue += step;
|
||||||
|
}
|
||||||
|
fMenu->Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BMenuScrollView::CheckForScrolling(const BPoint &cursor)
|
TScrollArrowView::CheckForScrolling(const BPoint &cursor)
|
||||||
{
|
{
|
||||||
if (!HasScrollers())
|
if (!HasScrollers())
|
||||||
return false;
|
return false;
|
||||||
@@ -327,30 +388,19 @@ BMenuScrollView::CheckForScrolling(const BPoint &cursor)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BMenuScrollView::TryScrollBy(const float& step)
|
TScrollArrowView::_Scroll(const BPoint& where)
|
||||||
{
|
{
|
||||||
if (!HasScrollers())
|
ASSERT((fLowerScrollArrow != NULL));
|
||||||
return false;
|
ASSERT((fUpperScrollArrow != NULL));
|
||||||
|
|
||||||
_ScrollBy(step);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
BMenuScrollView::_Scroll(const BPoint& where)
|
|
||||||
{
|
|
||||||
ASSERT((fLowerScroller != NULL));
|
|
||||||
ASSERT((fUpperScroller != NULL));
|
|
||||||
|
|
||||||
const BPoint cursor = ConvertFromScreen(where);
|
const BPoint cursor = ConvertFromScreen(where);
|
||||||
const BRect &lowerFrame = fLowerScroller->Frame();
|
const BRect &lowerFrame = fLowerScrollArrow->Frame();
|
||||||
const BRect &upperFrame = fUpperScroller->Frame();
|
const BRect &upperFrame = fUpperScrollArrow->Frame();
|
||||||
|
|
||||||
int32 delta = 0;
|
int32 delta = 0;
|
||||||
if (fLowerScroller->IsEnabled() && lowerFrame.Contains(cursor))
|
if (fLowerScrollArrow->IsEnabled() && lowerFrame.Contains(cursor))
|
||||||
delta = 1;
|
delta = 1;
|
||||||
else if (fUpperScroller->IsEnabled() && upperFrame.Contains(cursor))
|
else if (fUpperScrollArrow->IsEnabled() && upperFrame.Contains(cursor))
|
||||||
delta = -1;
|
delta = -1;
|
||||||
|
|
||||||
if (delta == 0)
|
if (delta == 0)
|
||||||
@@ -358,43 +408,9 @@ BMenuScrollView::_Scroll(const BPoint& where)
|
|||||||
|
|
||||||
float smallStep;
|
float smallStep;
|
||||||
GetSteps(&smallStep, NULL);
|
GetSteps(&smallStep, NULL);
|
||||||
_ScrollBy(smallStep * delta);
|
ScrollBy(smallStep * delta);
|
||||||
|
|
||||||
snooze(5000);
|
snooze(5000);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BMenuScrollView::_ScrollBy(const float& step)
|
|
||||||
{
|
|
||||||
if (step > 0) {
|
|
||||||
if (fValue == 0)
|
|
||||||
fUpperScroller->SetEnabled(true);
|
|
||||||
|
|
||||||
if (fValue + step >= fLimit) {
|
|
||||||
// If we reached the limit, only scroll to the end
|
|
||||||
fMenu->ScrollBy(0, fLimit - fValue);
|
|
||||||
fValue = fLimit;
|
|
||||||
fLowerScroller->SetEnabled(false);
|
|
||||||
} else {
|
|
||||||
fMenu->ScrollBy(0, step);
|
|
||||||
fValue += step;
|
|
||||||
}
|
|
||||||
fMenu->Invalidate();
|
|
||||||
} else if (step < 0) {
|
|
||||||
if (fValue == fLimit)
|
|
||||||
fLowerScroller->SetEnabled(true);
|
|
||||||
|
|
||||||
if (fValue + step <= 0) {
|
|
||||||
fMenu->ScrollBy(0, -fValue);
|
|
||||||
fValue = 0;
|
|
||||||
fUpperScroller->SetEnabled(false);
|
|
||||||
} else {
|
|
||||||
fMenu->ScrollBy(0, step);
|
|
||||||
fValue += step;
|
|
||||||
}
|
|
||||||
fMenu->Invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011, Haiku, Inc.
|
* Copyright 2012, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -7,22 +7,22 @@
|
|||||||
* Stefano Ceccherini (stefano.ceccherini@gmail.com)
|
* Stefano Ceccherini (stefano.ceccherini@gmail.com)
|
||||||
* John Scipione (jscipione@gmail.com)
|
* John Scipione (jscipione@gmail.com)
|
||||||
*/
|
*/
|
||||||
#ifndef MENU_SCROLL_VIEW_H
|
#ifndef SCROLL_ARROW_VIEW_H
|
||||||
#define MENU_SCROLL_VIEW_H
|
#define SCROLL_ARROW_VIEW_H
|
||||||
|
|
||||||
|
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
class BLayout;
|
class BLayout;
|
||||||
class BMenu;
|
class BMenu;
|
||||||
class BMenuScroller;
|
class ScrollArrow;
|
||||||
class BPoint;
|
class BPoint;
|
||||||
|
|
||||||
|
|
||||||
class BMenuScrollView : public BView {
|
class TScrollArrowView : public BView {
|
||||||
public:
|
public:
|
||||||
BMenuScrollView(BRect frame, BMenu* menu);
|
TScrollArrowView(BRect frame, BMenu* menu);
|
||||||
virtual ~BMenuScrollView();
|
virtual ~TScrollArrowView();
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void DetachedFromWindow();
|
virtual void DetachedFromWindow();
|
||||||
@@ -35,16 +35,15 @@ public:
|
|||||||
void GetSteps(float* _smallStep, float* _largeStep) const;
|
void GetSteps(float* _smallStep, float* _largeStep) const;
|
||||||
|
|
||||||
bool CheckForScrolling(const BPoint& cursor);
|
bool CheckForScrolling(const BPoint& cursor);
|
||||||
bool TryScrollBy(const float& step);
|
void ScrollBy(const float& step);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool _Scroll(const BPoint& cursor);
|
bool _Scroll(const BPoint& cursor);
|
||||||
void _ScrollBy(const float& step);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BMenu* fMenu;
|
BMenu* fMenu;
|
||||||
BMenuScroller* fUpperScroller;
|
ScrollArrow* fUpperScrollArrow;
|
||||||
BMenuScroller* fLowerScroller;
|
ScrollArrow* fLowerScrollArrow;
|
||||||
|
|
||||||
float fScrollStep;
|
float fScrollStep;
|
||||||
float fValue;
|
float fValue;
|
||||||
@@ -52,4 +51,4 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // MENU_SCROLL_VIEW_H
|
#endif // SCROLL_ARROW_VIEW_H
|
||||||
@@ -82,7 +82,6 @@ MergeObject <libbe>interface_kit.o :
|
|||||||
MenuField.cpp
|
MenuField.cpp
|
||||||
MenuItem.cpp
|
MenuItem.cpp
|
||||||
MenuPrivate.cpp
|
MenuPrivate.cpp
|
||||||
MenuScrollView.cpp
|
|
||||||
MenuWindow.cpp
|
MenuWindow.cpp
|
||||||
OptionControl.cpp
|
OptionControl.cpp
|
||||||
OptionPopUp.cpp
|
OptionPopUp.cpp
|
||||||
|
|||||||
Reference in New Issue
Block a user