Menu settings are now handled by the app_server. As a result, changing them does something, although they aren't saved to disk yet. 'click_to_open' is not checked anymore, because it was useless anyway, I'll remove it from the Menu preflet too.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17174 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2006-04-19 20:04:19 +00:00
parent 77214f9012
commit b03deb09db
5 changed files with 36 additions and 56 deletions
+1 -21
View File
@@ -785,26 +785,6 @@ shift_color(rgb_color color, float shift)
} }
static status_t
load_menu_settings(menu_info &into)
{
// TODO: Load settings from the settings file,
// and only if it fails, fallback to the defaults
// TODO: shouldn't the server handle the details? It could broadcast
// change messages to the applications, which could also relayout
// there menus and menu bars then (as soon as we have a layout management)
into.font_size = be_plain_font->Size();
be_plain_font->GetFamilyAndStyle(&into.f_family, &into.f_style);
into.background_color = ui_color(B_MENU_BACKGROUND_COLOR);
into.separator = 0;
into.click_to_open = true;
into.triggers_always_shown = false;
return B_OK;
}
extern "C" status_t extern "C" status_t
_init_interface_kit_() _init_interface_kit_()
{ {
@@ -818,7 +798,7 @@ _init_interface_kit_()
_init_global_fonts_(); _init_global_fonts_();
_menu_info_ptr_ = &BMenu::sMenuInfo; _menu_info_ptr_ = &BMenu::sMenuInfo;
status_t status = load_menu_settings(BMenu::sMenuInfo); status_t status = get_menu_info(&BMenu::sMenuInfo);
general_info.background_color = ui_color(B_PANEL_BACKGROUND_COLOR); general_info.background_color = ui_color(B_PANEL_BACKGROUND_COLOR);
general_info.mark_color.set_to(0, 0, 0); general_info.mark_color.set_to(0, 0, 0);
+22 -21
View File
@@ -20,9 +20,11 @@
#include <Screen.h> #include <Screen.h>
#include <Window.h> #include <Window.h>
#include <AppServerLink.h>
#include <BMCPrivate.h> #include <BMCPrivate.h>
#include <MenuPrivate.h> #include <MenuPrivate.h>
#include <MenuWindow.h> #include <MenuWindow.h>
#include <ServerProtocol.h>
class _ExtraMenuData_ { class _ExtraMenuData_ {
@@ -973,8 +975,7 @@ BMenu::Track(bool sticky, BRect *clickToOpenRect)
} }
// If sticky is false, pass 0 to the tracking function // If sticky is false, pass 0 to the tracking function
// so the menu will stay in nonsticky mode, regardless // so the menu will stay in nonsticky mode
// of the "IsStickyPrefOn()" value
const bigtime_t trackTime = sticky ? system_time() : 0; const bigtime_t trackTime = sticky ? system_time() : 0;
int action; int action;
BMenuItem *menuItem = _track(&action, trackTime); BMenuItem *menuItem = _track(&action, trackTime);
@@ -1215,8 +1216,8 @@ BMenu::_track(int *action, bigtime_t trackTime, long start)
localAction = MENU_ACT_CLOSE; localAction = MENU_ACT_CLOSE;
break; break;
} else if (buttons == 0 && !IsStickyMode()) { } else if (buttons == 0 && !IsStickyMode()) {
if (IsStickyPrefOn() && (system_time() < trackTime + 1000000 if (system_time() < trackTime + 1000000
|| (fExtraRect != NULL && fExtraRect->Contains(location)))) || (fExtraRect != NULL && fExtraRect->Contains(location)))
SetStickyMode(true); SetStickyMode(true);
else { else {
localAction = MENU_ACT_CLOSE; localAction = MENU_ACT_CLOSE;
@@ -1896,7 +1897,7 @@ BMenu::UpdateWindowViewSize(bool upWind)
bool bool
BMenu::IsStickyPrefOn() BMenu::IsStickyPrefOn()
{ {
return sMenuInfo.click_to_open; return true;
} }
@@ -1991,29 +1992,24 @@ BMenu::DoCreateMsg(BMenuItem *ti, BMenu *tm, BMessage *m,
} }
// TODO: Maybe the following two methods would fit better into InterfaceDefs.cpp
// In R5, they do all the work client side, we let the app_server handle the details.
status_t status_t
set_menu_info(menu_info *info) set_menu_info(menu_info *info)
{ {
if (!info) if (!info)
return B_BAD_VALUE; return B_BAD_VALUE;
BPath path; BPrivate::AppServerLink link;
link.StartMessage(AS_SET_MENU_INFO);
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) link.Attach<menu_info>(*info);
return B_OK;
path.Append("menu_settings");
BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE);
if (file.InitCheck() != B_OK)
return B_OK;
file.Write(info, sizeof(menu_info));
status_t status = B_ERROR;
if (link.FlushWithReply(status) == B_OK && status == B_OK)
BMenu::sMenuInfo = *info; BMenu::sMenuInfo = *info;
// Update also the local copy, in case anyone relies on it
return B_OK; return status;
} }
@@ -2023,7 +2019,12 @@ get_menu_info(menu_info *info)
if (!info) if (!info)
return B_BAD_VALUE; return B_BAD_VALUE;
*info = BMenu::sMenuInfo; BPrivate::AppServerLink link;
link.StartMessage(AS_GET_MENU_INFO);
return B_OK; status_t status = B_ERROR;
if (link.FlushWithReply(status) == B_OK && status == B_OK)
link.Read<menu_info>(info);
return status;
} }
+1 -5
View File
@@ -7,8 +7,6 @@
* Stefano Ceccherini (burton666@libero.it) * Stefano Ceccherini (burton666@libero.it)
*/ */
// TODO: Finish this class
#include <Application.h> #include <Application.h>
#include <Autolock.h> #include <Autolock.h>
#include <MenuBar.h> #include <MenuBar.h>
@@ -443,10 +441,8 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
if (fSelected != NULL && fSelected->Submenu() == NULL) { if (fSelected != NULL && fSelected->Submenu() == NULL) {
resultItem = fSelected; resultItem = fSelected;
break; break;
} else if (IsStickyPrefOn()) } else
SetStickyMode(true); SetStickyMode(true);
else
break;
} }
if (snoozeAmount > 0) if (snoozeAmount > 0)
+2 -1
View File
@@ -29,7 +29,8 @@ BStringView::BStringView(BRect frame, const char* name, const char* text,
BStringView::BStringView(BMessage* data) BStringView::BStringView(BMessage* data)
: BView(data) : BView(data),
fText(NULL)
{ {
int32 align; int32 align;
if (data->FindInt32("_align", &align) == B_OK) if (data->FindInt32("_align", &align) == B_OK)
+9 -7
View File
@@ -52,14 +52,16 @@ DesktopSettings::Private::_SetDefaults()
fScrollBarInfo.min_knob_size = 15; fScrollBarInfo.min_knob_size = 15;
// init menu info // init menu info
fMenuInfo.font_size = 12.0; strlcpy(fMenuInfo.f_family, fPlainFont.Family(), B_FONT_FAMILY_LENGTH);
// TODO: ... strlcpy(fMenuInfo.f_style, fPlainFont.Style(), B_FONT_STYLE_LENGTH);
// fMenuInfo.f_family; fMenuInfo.font_size = fPlainFont.Size();
// fMenuInfo.f_style; // TODO:
// fMenuInfo.background_color = gColorSet->menu_background; fMenuInfo.background_color.set_to(216, 216, 216); //gColorSet->menu_background;
// look of the separator (R5: (0, 1, 2), default ?)
// look of the separator (R5: (0, 1, 2), default 0)
// TODO: we could just choose a nice one and remove the others
fMenuInfo.separator = 0; fMenuInfo.separator = 0;
fMenuInfo.click_to_open = true; fMenuInfo.click_to_open = true; // always true
fMenuInfo.triggers_always_shown = false; fMenuInfo.triggers_always_shown = false;
fWorkspacesCount = 4; fWorkspacesCount = 4;