* Applied a patch of x-ist that implements auto hide functionality with minor
coding style changes by myself. * Thanks, and sorry for the long delay! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42383 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -206,6 +206,7 @@ TBarApp::SaveSettings()
|
||||
storedSettings.AddBool("superExpando", fSettings.superExpando);
|
||||
storedSettings.AddBool("expandNewTeams", fSettings.expandNewTeams);
|
||||
storedSettings.AddBool("autoRaise", fSettings.autoRaise);
|
||||
storedSettings.AddBool("autoHide", fSettings.autoHide);
|
||||
storedSettings.AddBool("recentAppsEnabled",
|
||||
fSettings.recentAppsEnabled);
|
||||
storedSettings.AddBool("recentDocsEnabled",
|
||||
@@ -241,6 +242,7 @@ TBarApp::InitSettings()
|
||||
settings.superExpando = false;
|
||||
settings.expandNewTeams = false;
|
||||
settings.autoRaise = false;
|
||||
settings.autoHide = false;
|
||||
settings.recentAppsEnabled = true;
|
||||
settings.recentDocsEnabled = true;
|
||||
settings.recentFoldersEnabled = true;
|
||||
@@ -290,6 +292,7 @@ TBarApp::InitSettings()
|
||||
storedSettings.FindBool("superExpando", &settings.superExpando);
|
||||
storedSettings.FindBool("expandNewTeams", &settings.expandNewTeams);
|
||||
storedSettings.FindBool("autoRaise", &settings.autoRaise);
|
||||
storedSettings.FindBool("autoHide", &settings.autoHide);
|
||||
storedSettings.FindBool("recentAppsEnabled",
|
||||
&settings.recentAppsEnabled);
|
||||
storedSettings.FindBool("recentDocsEnabled",
|
||||
@@ -408,19 +411,29 @@ TBarApp::MessageReceived(BMessage* message)
|
||||
|
||||
case kAlwaysTop:
|
||||
fSettings.alwaysOnTop = !fSettings.alwaysOnTop;
|
||||
|
||||
fBarWindow->SetFeel(fSettings.alwaysOnTop ?
|
||||
B_FLOATING_ALL_WINDOW_FEEL : B_NORMAL_WINDOW_FEEL);
|
||||
fPreferencesWindow->PostMessage(kStateChanged);
|
||||
break;
|
||||
|
||||
case kAutoRaise:
|
||||
fSettings.autoRaise = !fSettings.autoRaise;
|
||||
fSettings.autoRaise = fSettings.alwaysOnTop ? false :
|
||||
!fSettings.autoRaise;
|
||||
|
||||
fBarWindow->Lock();
|
||||
BarView()->UpdateAutoRaise();
|
||||
BarView()->UpdateEventMask();
|
||||
fBarWindow->Unlock();
|
||||
break;
|
||||
|
||||
case kAutoHide:
|
||||
fSettings.autoHide = !fSettings.autoHide;
|
||||
|
||||
fBarWindow->Lock();
|
||||
BarView()->UpdateEventMask();
|
||||
BarView()->HideDeskbar(fSettings.autoHide);
|
||||
fBarWindow->Unlock();
|
||||
break;
|
||||
|
||||
case kTrackerFirst:
|
||||
fSettings.trackerAlwaysFirst = !fSettings.trackerAlwaysFirst;
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ const uint32 kSortRunningApps = 'SAps';
|
||||
const uint32 kSuperExpando = 'SprE';
|
||||
const uint32 kExpandNewTeams = 'ExTm';
|
||||
const uint32 kAutoRaise = 'AtRs';
|
||||
const uint32 kAutoHide = 'AtHd';
|
||||
const uint32 kRestartTracker = 'Trak';
|
||||
|
||||
// from roster_private.h
|
||||
@@ -110,6 +111,7 @@ struct desk_settings {
|
||||
bool superExpando;
|
||||
bool expandNewTeams;
|
||||
bool autoRaise;
|
||||
bool autoHide;
|
||||
bool recentAppsEnabled;
|
||||
bool recentDocsEnabled;
|
||||
bool recentFoldersEnabled;
|
||||
|
||||
+133
-29
@@ -110,7 +110,7 @@ TBarView::AttachedToWindow()
|
||||
SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR));
|
||||
SetFont(be_plain_font);
|
||||
|
||||
UpdateAutoRaise();
|
||||
UpdateEventMask();
|
||||
UpdatePlacement();
|
||||
|
||||
fTrackingHookData.fTrackingHook = MenuTrackingHook;
|
||||
@@ -183,16 +183,79 @@ TBarView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
|
||||
if (Window() == NULL || EventMask() == 0)
|
||||
return;
|
||||
|
||||
// Auto-Raise
|
||||
desk_settings* settings = ((TBarApp*)be_app)->Settings();
|
||||
bool alwaysOnTop = settings->alwaysOnTop;
|
||||
bool autoRaise = settings->autoRaise;
|
||||
bool autoHide = settings->autoHide;
|
||||
|
||||
if (!autoRaise && !autoHide)
|
||||
return;
|
||||
|
||||
if (DragRegion()->IsDragging())
|
||||
return;
|
||||
|
||||
bool isTopMost = Window()->Feel() == B_FLOATING_ALL_WINDOW_FEEL;
|
||||
|
||||
// Auto-Raise
|
||||
where = ConvertToScreen(where);
|
||||
BScreen screen(Window());
|
||||
BRect frame = screen.Frame();
|
||||
if (where.x == frame.left || where.x == frame.right
|
||||
|| where.y == frame.top || where.y == frame.bottom) {
|
||||
// cursor is on screen edge
|
||||
if (Window()->Frame().Contains(where))
|
||||
Window()->Activate();
|
||||
BRect screenFrame = screen.Frame();
|
||||
if ((where.x == screenFrame.left || where.x == screenFrame.right
|
||||
|| where.y == screenFrame.top || where.y == screenFrame.bottom)
|
||||
&& Window()->Frame().Contains(where)) {
|
||||
// cursor is on a screen edge within the window frame
|
||||
|
||||
if (!alwaysOnTop && autoRaise && !isTopMost)
|
||||
RaiseDeskbar(true);
|
||||
|
||||
if (autoHide && IsHidden())
|
||||
HideDeskbar(false);
|
||||
} else {
|
||||
// cursor is not on screen edge
|
||||
BRect preventHideArea = Window()->Frame().InsetByCopy(
|
||||
-kMaxPreventHidingDist, -kMaxPreventHidingDist);
|
||||
|
||||
if (preventHideArea.Contains(where))
|
||||
return;
|
||||
|
||||
// cursor to bar distance above threshold
|
||||
if (!alwaysOnTop && autoRaise && isTopMost)
|
||||
RaiseDeskbar(false);
|
||||
|
||||
if (autoHide && !IsHidden())
|
||||
HideDeskbar(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarView::MouseDown(BPoint where)
|
||||
{
|
||||
where = ConvertToScreen(where);
|
||||
|
||||
if (Window()->Frame().Contains(where)) {
|
||||
Window()->Activate();
|
||||
|
||||
if ((modifiers() & (B_CONTROL_KEY | B_COMMAND_KEY | B_OPTION_KEY
|
||||
| B_SHIFT_KEY)) == (B_CONTROL_KEY | B_COMMAND_KEY)) {
|
||||
// The window key was pressed - enter dragging code
|
||||
DragRegion()->MouseDown(
|
||||
DragRegion()->DragRegion().LeftTop());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// hide deskbar if required
|
||||
desk_settings* settings = ((TBarApp*)be_app)->Settings();
|
||||
bool alwaysOnTop = settings->alwaysOnTop;
|
||||
bool autoRaise = settings->autoRaise;
|
||||
bool autoHide = settings->autoHide;
|
||||
bool isTopMost = Window()->Feel() == B_FLOATING_ALL_WINDOW_FEEL;
|
||||
|
||||
if (!alwaysOnTop && autoRaise && isTopMost)
|
||||
RaiseDeskbar(false);
|
||||
|
||||
if (autoHide && !IsHidden())
|
||||
HideDeskbar(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,25 +397,39 @@ TBarView::GetPreferredWindowSize(BRect screenFrame, float* width, float* height)
|
||||
{
|
||||
float windowHeight = 0;
|
||||
float windowWidth = sMinimumWindowWidth;
|
||||
if (fState == kFullState) {
|
||||
windowHeight = screenFrame.bottom;
|
||||
windowWidth = fBarMenuBar->Frame().Width();
|
||||
} else if (fState == kExpandoState) {
|
||||
if (fVertical) {
|
||||
// top left or right
|
||||
windowHeight = fExpando->Frame().bottom;
|
||||
bool calcHiddenSize = ((TBarApp*)be_app)->Settings()->autoHide
|
||||
&& IsHidden() && !DragRegion()->IsDragging();
|
||||
|
||||
if (!calcHiddenSize) {
|
||||
if (fState == kFullState) {
|
||||
windowHeight = screenFrame.bottom;
|
||||
windowWidth = fBarMenuBar->Frame().Width();
|
||||
} else if (fState == kExpandoState) {
|
||||
if (fVertical)
|
||||
// top left or right
|
||||
windowHeight = fExpando->Frame().bottom;
|
||||
else {
|
||||
// top or bottom, full
|
||||
fExpando->CheckItemSizes(0);
|
||||
windowHeight = kHModeHeight;
|
||||
windowWidth = screenFrame.Width();
|
||||
}
|
||||
} else {
|
||||
// top or bottom, full
|
||||
fExpando->CheckItemSizes(0);
|
||||
windowHeight = kHModeHeight;
|
||||
windowWidth = screenFrame.Width();
|
||||
// four corners
|
||||
if (fTrayLocation != 0)
|
||||
windowHeight = fDragRegion->Frame().bottom;
|
||||
else
|
||||
windowHeight = fBarMenuBar->Frame().bottom;
|
||||
}
|
||||
} else {
|
||||
// four corners
|
||||
if (fTrayLocation != 0)
|
||||
windowHeight = fDragRegion->Frame().bottom;
|
||||
else
|
||||
windowHeight = fBarMenuBar->Frame().bottom;
|
||||
windowHeight = kHModeHiddenHeight;
|
||||
|
||||
if (fState == kExpandoState && !fVertical) {
|
||||
// top or bottom, full
|
||||
fExpando->CheckItemSizes(0);
|
||||
windowWidth = screenFrame.Width();
|
||||
} else
|
||||
windowWidth = kHModeHiddenHeight;
|
||||
}
|
||||
|
||||
*width = windowWidth;
|
||||
@@ -408,15 +485,14 @@ TBarView::SaveSettings()
|
||||
settings->showTime = ShowingClock();
|
||||
|
||||
fReplicantTray->RememberClockSettings();
|
||||
settings->alwaysOnTop
|
||||
= (Window()->Feel() & B_FLOATING_ALL_WINDOW_FEEL) != 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarView::UpdateAutoRaise()
|
||||
TBarView::UpdateEventMask()
|
||||
{
|
||||
if (((TBarApp*)be_app)->Settings()->autoRaise)
|
||||
if (((TBarApp*)be_app)->Settings()->autoRaise
|
||||
|| ((TBarApp*)be_app)->Settings()->autoHide)
|
||||
SetEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
|
||||
else
|
||||
SetEventMask(0);
|
||||
@@ -443,7 +519,7 @@ TBarView::ChangeState(int32 state, bool vertical, bool left, bool top)
|
||||
fTop = top;
|
||||
|
||||
// Send a message to the preferences window to let it know to enable
|
||||
// or disabled preference items
|
||||
// or disable preference items
|
||||
if (stateChanged || vertSwap)
|
||||
be_app->PostMessage(kStateChanged);
|
||||
|
||||
@@ -507,6 +583,34 @@ TBarView::ChangeState(int32 state, bool vertical, bool left, bool top)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarView::RaiseDeskbar(bool raise)
|
||||
{
|
||||
if (raise)
|
||||
Window()->SetFeel(B_FLOATING_ALL_WINDOW_FEEL);
|
||||
else
|
||||
Window()->SetFeel(B_NORMAL_WINDOW_FEEL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarView::HideDeskbar(bool hide)
|
||||
{
|
||||
BScreen screen(Window());
|
||||
BRect screenFrame = screen.Frame();
|
||||
|
||||
if (hide) {
|
||||
Hide();
|
||||
PositionWindow(screenFrame);
|
||||
SizeWindow(screenFrame);
|
||||
} else {
|
||||
Show();
|
||||
SizeWindow(screenFrame);
|
||||
PositionWindow(screenFrame);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// window placement functions
|
||||
|
||||
bool
|
||||
|
||||
@@ -57,6 +57,8 @@ const float kMiniHeight = 46.0f;
|
||||
const float kHModeHeight = 21.0f;
|
||||
const float kMenuBarHeight = 21.0f;
|
||||
const float kStatusHeight = 22.0f;
|
||||
const float kHModeHiddenHeight = 1.0f;
|
||||
const float kMaxPreventHidingDist = 80.0f;
|
||||
|
||||
class BShelf;
|
||||
class TBarMenuBar;
|
||||
@@ -78,11 +80,14 @@ class TBarView : public BView {
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void MouseMoved(BPoint where, uint32 transit,
|
||||
const BMessage* dragMessage);
|
||||
virtual void MouseDown(BPoint where);
|
||||
|
||||
void SaveSettings();
|
||||
void UpdateAutoRaise();
|
||||
void UpdateEventMask();
|
||||
void UpdatePlacement();
|
||||
void ChangeState(int32 state, bool vertical, bool left, bool top);
|
||||
void RaiseDeskbar(bool raise);
|
||||
void HideDeskbar(bool hide);
|
||||
|
||||
bool Vertical() const;
|
||||
bool Left() const;
|
||||
@@ -136,7 +141,7 @@ class TBarView : public BView {
|
||||
TExpandoMenuBar* ExpandoMenuBar() const;
|
||||
TBarMenuBar* BarMenuBar() const;
|
||||
TDragRegion* DragRegion() const { return fDragRegion; }
|
||||
|
||||
|
||||
private:
|
||||
friend class TBeMenu;
|
||||
friend class PreferencesWindow;
|
||||
|
||||
@@ -105,29 +105,6 @@ TBarWindow::TBarWindow()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::DispatchMessage(BMessage* message, BHandler* handler)
|
||||
{
|
||||
// Activate the window when you click on it (ie. on the tray area,
|
||||
// the menu part will do this automatically)
|
||||
if (message->what == B_MOUSE_DOWN) {
|
||||
if (!((TBarApp*)be_app)->Settings()->autoRaise)
|
||||
Activate(true);
|
||||
|
||||
if (_IsFocusMessage(message)
|
||||
&& (modifiers() & (B_CONTROL_KEY | B_COMMAND_KEY | B_OPTION_KEY
|
||||
| B_SHIFT_KEY)) == (B_CONTROL_KEY | B_COMMAND_KEY)) {
|
||||
// The window key was pressed - enter dragging code
|
||||
fBarView->DragRegion()->MouseDown(
|
||||
fBarView->DragRegion()->DragRegion().LeftTop());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BWindow::DispatchMessage(message, handler);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarWindow::MenusBeginning()
|
||||
{
|
||||
@@ -182,7 +159,7 @@ TBarWindow::MenusEnded()
|
||||
sBeMenu->UnlockLooper();
|
||||
}
|
||||
|
||||
fBarView->UpdateAutoRaise();
|
||||
fBarView->UpdateEventMask();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -54,8 +54,6 @@ public:
|
||||
virtual void WorkspaceActivated(int32 workspace,
|
||||
bool activate);
|
||||
virtual void ScreenChanged(BRect size, color_space depth);
|
||||
virtual void DispatchMessage(BMessage* message,
|
||||
BHandler* handler);
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void Minimize(bool minimize);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009 Haiku, Inc.
|
||||
* Copyright 2009-2011 Haiku, Inc.
|
||||
* All Rights Reserved. Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@@ -62,6 +62,8 @@ PreferencesWindow::PreferencesWindow(BRect frame)
|
||||
new BMessage(kAlwaysTop));
|
||||
fWindowAutoRaise = new BCheckBox(B_TRANSLATE("Auto-raise"),
|
||||
new BMessage(kAutoRaise));
|
||||
fWindowAutoHide = new BCheckBox(B_TRANSLATE("Auto-hide"),
|
||||
new BMessage(kAutoHide));
|
||||
|
||||
BTextView* docTextView = fMenuRecentDocumentCount->TextView();
|
||||
BTextView* appTextView = fMenuRecentApplicationCount->TextView();
|
||||
@@ -122,6 +124,7 @@ PreferencesWindow::PreferencesWindow(BRect frame)
|
||||
|
||||
fWindowAlwaysOnTop->SetValue(appSettings->alwaysOnTop);
|
||||
fWindowAutoRaise->SetValue(appSettings->autoRaise);
|
||||
fWindowAutoHide->SetValue(appSettings->autoHide);
|
||||
|
||||
_EnableDisableDependentItems();
|
||||
|
||||
@@ -134,6 +137,7 @@ PreferencesWindow::PreferencesWindow(BRect frame)
|
||||
|
||||
fWindowAlwaysOnTop->SetTarget(be_app);
|
||||
fWindowAutoRaise->SetTarget(be_app);
|
||||
fWindowAutoHide->SetTarget(be_app);
|
||||
|
||||
// Layout
|
||||
fMenuBox = new BBox("fMenuBox");
|
||||
@@ -196,6 +200,7 @@ PreferencesWindow::PreferencesWindow(BRect frame)
|
||||
.AddGroup(B_VERTICAL, 1)
|
||||
.Add(fWindowAlwaysOnTop)
|
||||
.Add(fWindowAutoRaise)
|
||||
.Add(fWindowAutoHide)
|
||||
.AddGlue()
|
||||
.SetInsets(10, 10, 10, 10)
|
||||
.End()
|
||||
@@ -301,6 +306,11 @@ PreferencesWindow::_EnableDisableDependentItems()
|
||||
fMenuRecentFolderCount->SetEnabled(true);
|
||||
else
|
||||
fMenuRecentFolderCount->SetEnabled(false);
|
||||
|
||||
if (fWindowAlwaysOnTop->Value() == B_CONTROL_ON)
|
||||
fWindowAutoRaise->SetEnabled(false);
|
||||
else
|
||||
fWindowAutoRaise->SetEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -310,4 +320,3 @@ PreferencesWindow::WindowActivated(bool active)
|
||||
if (!active && IsMinimized())
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ private:
|
||||
|
||||
BCheckBox* fWindowAlwaysOnTop;
|
||||
BCheckBox* fWindowAutoRaise;
|
||||
BCheckBox* fWindowAutoHide;
|
||||
};
|
||||
|
||||
#endif // _PREFERENCES_WINDOW_H
|
||||
|
||||
@@ -197,6 +197,8 @@ public:
|
||||
|
||||
int32 DragRegionLocation() const;
|
||||
void SetDragRegionLocation(int32);
|
||||
|
||||
bool IsDragging() {return IsTracking();}
|
||||
|
||||
private:
|
||||
TBarView* fBarView;
|
||||
|
||||
Reference in New Issue
Block a user