Changes the menu key bitmap from CTL to CTRL and SHFT to SHIFT.

This is coming from but does not close #7967

Adds a new (currently unused) Menu key bitmap.

Instead of having a single AltAsCommandKey() method the menus now
show the correct bitmap when you switch between your control,
windows/option, and alt/command keys. This is really not flushed
out yet since it only works when you switch those keys and not
other combinations like say switching the control and caps lock
keys but it is a step in the right direction.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43205 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
John Scipione 2011-11-07 01:46:42 +00:00
parent 3b8c2d3aad
commit 8abe72fb66
4 changed files with 236 additions and 124 deletions

View File

@ -243,7 +243,14 @@ private:
void _SetIgnoreHidden(bool on);
void _SetStickyMode(bool on);
bool _IsStickyMode() const;
void _GetIsAltCommandKey(bool &value) const;
// Methods to get the current modifier keycode
void _GetShiftKey(uint32 &value) const;
void _GetControlKey(uint32 &value) const;
void _GetCommandKey(uint32 &value) const;
void _GetOptionKey(uint32 &value) const;
void _GetMenuKey(uint32 &value) const;
void _CalcTriggers();
bool _ChooseTrigger(const char* title, int32& index,
uint32& trigger,
@ -260,7 +267,14 @@ private:
void _QuitTracking(bool onlyThis = true);
static menu_info sMenuInfo;
static bool sAltAsCommandKey;
// Variables to keep track of what code is currently assigned to
// each modifier key
static uint32 sShiftKey;
static uint32 sControlKey;
static uint32 sOptionKey;
static uint32 sCommandKey;
static uint32 sMenuKey;
BMenuItem* fChosenItem;
BList fItems;

View File

@ -34,39 +34,39 @@ public:
menu_layout Layout() const;
void ItemMarked(BMenuItem *item);
void CacheFontInfo();
void ItemMarked(BMenuItem *item);
void CacheFontInfo();
float FontHeight() const;
float Ascent() const;
BRect Padding() const;
void GetItemMargins(float *, float *, float *, float *) const;
float FontHeight() const;
float Ascent() const;
BRect Padding() const;
void GetItemMargins(float *, float *, float *, float *) const;
static bool IsAltCommandKey();
int State(BMenuItem **item = NULL) const;
int State(BMenuItem **item = NULL) const;
void Install(BWindow *window);
void Uninstall();
void SetSuper(BMenu *menu);
void SetSuperItem(BMenuItem *item);
void InvokeItem(BMenuItem *item, bool now = false);
void QuitTracking(bool thisMenuOnly = true);
void Install(BWindow *window);
void Uninstall();
void SetSuper(BMenu *menu);
void SetSuperItem(BMenuItem *item);
void InvokeItem(BMenuItem *item, bool now = false);
void QuitTracking(bool thisMenuOnly = true);
static status_t CreateBitmaps();
static void DeleteBitmaps();
static const BBitmap *MenuItemCommand();
static const BBitmap *MenuItemControl();
static const BBitmap *MenuItemOption();
static const BBitmap *MenuItemShift();
static const BBitmap *MenuItemShift();
static const BBitmap *MenuItemControl();
static const BBitmap *MenuItemOption();
static const BBitmap *MenuItemCommand();
static const BBitmap *MenuItemMenu();
private:
BMenu *fMenu;
BMenu *fMenu;
static BBitmap *sMenuItemAlt;
static BBitmap *sMenuItemShift;
static BBitmap *sMenuItemControl;
static BBitmap *sMenuItemOption;
static BBitmap *sMenuItemShift;
static BBitmap *sMenuItemAlt;
static BBitmap *sMenuItemMenu;
};

View File

@ -96,8 +96,12 @@ public:
menu_info BMenu::sMenuInfo;
bool BMenu::sAltAsCommandKey;
uint32 BMenu::sShiftKey;
uint32 BMenu::sControlKey;
uint32 BMenu::sOptionKey;
uint32 BMenu::sCommandKey;
uint32 BMenu::sMenuKey;
static property_info sPropList[] = {
{ "Enabled", { B_GET_PROPERTY, 0 },
@ -381,8 +385,12 @@ BMenu::AttachedToWindow()
{
BView::AttachedToWindow();
_GetIsAltCommandKey(sAltAsCommandKey);
_GetShiftKey(sShiftKey);
_GetControlKey(sControlKey);
_GetCommandKey(sCommandKey);
_GetOptionKey(sOptionKey);
_GetMenuKey(sMenuKey);
fAttachAborted = _AddDynamicItems();
if (!fAttachAborted) {
@ -2678,25 +2686,72 @@ BMenu::_IsStickyMode() const
void
BMenu::_GetIsAltCommandKey(bool &value) const
BMenu::_GetShiftKey(uint32 &value) const
{
// TODO: Move into init_interface_kit().
// Currently we can't do that, as get_key_map() blocks forever
// Currently we can't do that, as get_modifier_key() blocks forever
// when called on input_server initialization, since it tries
// to send a synchronous message to itself (input_server is
// a BApplication)
bool altAsCommand = true;
key_map* keys = NULL;
char* chars = NULL;
get_key_map(&keys, &chars);
if (keys == NULL || keys->left_command_key != 0x5d
|| keys->left_control_key != 0x5c)
altAsCommand = false;
free(chars);
free(keys);
if (get_modifier_key(B_LEFT_SHIFT_KEY, &value) != B_OK)
value = 0x4b;
}
value = altAsCommand;
void
BMenu::_GetControlKey(uint32 &value) const
{
// TODO: Move into init_interface_kit().
// Currently we can't do that, as get_modifier_key() blocks forever
// when called on input_server initialization, since it tries
// to send a synchronous message to itself (input_server is
// a BApplication)
if (get_modifier_key(B_LEFT_CONTROL_KEY, &value) != B_OK)
value = 0x5c;
}
void
BMenu::_GetCommandKey(uint32 &value) const
{
// TODO: Move into init_interface_kit().
// Currently we can't do that, as get_modifier_key() blocks forever
// when called on input_server initialization, since it tries
// to send a synchronous message to itself (input_server is
// a BApplication)
if (get_modifier_key(B_LEFT_COMMAND_KEY, &value) != B_OK)
value = 0x66;
}
void
BMenu::_GetOptionKey(uint32 &value) const
{
// TODO: Move into init_interface_kit().
// Currently we can't do that, as get_modifier_key() blocks forever
// when called on input_server initialization, since it tries
// to send a synchronous message to itself (input_server is
// a BApplication)
if (get_modifier_key(B_LEFT_OPTION_KEY, &value) != B_OK)
value = 0x5d;
}
void
BMenu::_GetMenuKey(uint32 &value) const
{
// TODO: Move into init_interface_kit().
// Currently we can't do that, as get_modifier_key() blocks forever
// when called on input_server initialization, since it tries
// to send a synchronous message to itself (input_server is
// a BApplication)
if (get_modifier_key(B_MENU_KEY, &value) != B_OK)
value = 0x68;
}

View File

@ -11,15 +11,46 @@
#include <Bitmap.h>
#include <Menu.h>
const unsigned char kShiftBits[] = {
0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x14,
0x1d,0x1a,0x1a,0x1a,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,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x14,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14
};
const unsigned char kOptBits[] = {
0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x14,
0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x13,0x04,0x04,0x13,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x13,0x04,0x04,0x13,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x04,0x04,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x13,0x04,0x04,0x13,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x1a,0x04,0x04,0x04,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x13,0x04,0x04,0x13,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
0x1d,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x14,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14
@ -41,42 +72,29 @@ const unsigned char kAltBits[] = {
};
const unsigned char kOptBits[] = {
0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x14,
0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x13,0x04,0x04,0x13,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x1a,0x04,0x04,0x04,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x13,0x04,0x04,0x13,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
0x1d,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x14,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14
const unsigned char kMenuBits[] = {
0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x14,
0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x04,0x04,0x1a,0x04,0x04,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x04,0x04,0x04,0x04,0x04,0x1a,0x04,0x04,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x04,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x1a,0x04,0x04,0x04,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x1a,0x04,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x04,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
0x1d,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x14,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14
};
const unsigned char kShiftBits[] = {
0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x14,
0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x17,0x04,0x04,0x17,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x04,0x17,0x17,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x04,0x04,0x1a,0x04,0x04,0x04,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x17,0x04,0x04,0x17,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x04,0x04,0x04,0x1a,0x04,0x04,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x04,0x17,0x17,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x17,0x04,0x04,0x17,0x1a,0x04,0x1a,0x04,0x1a,0x04,0x1a,0x1a,0x1a,0x1a,0x04,0x1a,0x1a,0x17,0x14,
0x1d,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x17,0x14,
0x1d,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x14,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14
};
namespace BPrivate {
BBitmap* MenuPrivate::sMenuItemAlt;
BBitmap* MenuPrivate::sMenuItemShift;
BBitmap* MenuPrivate::sMenuItemControl;
BBitmap* MenuPrivate::sMenuItemOption;
BBitmap* MenuPrivate::sMenuItemShift;
BBitmap* MenuPrivate::sMenuItemAlt;
BBitmap* MenuPrivate::sMenuItemMenu;
MenuPrivate::MenuPrivate(BMenu *menu)
@ -136,14 +154,6 @@ MenuPrivate::GetItemMargins(float *left, float *top,
}
/* static */
bool
MenuPrivate::IsAltCommandKey()
{
return BMenu::sAltAsCommandKey;
}
int
MenuPrivate::State(BMenuItem **item) const
{
@ -198,24 +208,27 @@ status_t
MenuPrivate::CreateBitmaps()
{
BRect smallRect(0, 0, 16, 10);
BRect largeRect(0, 0, 21, 10);
try {
sMenuItemShift = new BBitmap(BRect(0, 0, 23, 10), B_CMAP8);
sMenuItemControl = new BBitmap(BRect(0, 0, 21, 10), B_CMAP8);
sMenuItemOption = new BBitmap(smallRect, B_CMAP8);
sMenuItemAlt = new BBitmap(smallRect, B_CMAP8);
sMenuItemControl = new BBitmap(smallRect, B_CMAP8);
sMenuItemOption = new BBitmap(smallRect, B_CMAP8);
sMenuItemShift = new BBitmap(largeRect, B_CMAP8);
sMenuItemMenu = new BBitmap(BRect(0, 0, 22, 10), B_CMAP8);
} catch (...) {
return B_NO_MEMORY;
}
sMenuItemAlt->ImportBits(kAltBits, sizeof(kAltBits),
17, 0, B_CMAP8);
sMenuItemShift->ImportBits(kShiftBits, sizeof(kShiftBits),
24, 0, B_CMAP8);
sMenuItemControl->ImportBits(kCtrlBits, sizeof(kCtrlBits),
17, 0, B_CMAP8);
22, 0, B_CMAP8);
sMenuItemOption->ImportBits(kOptBits, sizeof(kOptBits),
17, 0, B_CMAP8);
sMenuItemShift->ImportBits(kShiftBits, sizeof(kShiftBits),
22, 0, B_CMAP8);
sMenuItemAlt->ImportBits(kAltBits, sizeof(kAltBits),
17, 0, B_CMAP8);
sMenuItemMenu->ImportBits(kMenuBits, sizeof(kMenuBits),
23, 0, B_CMAP8);
return B_OK;
}
@ -225,49 +238,79 @@ MenuPrivate::CreateBitmaps()
void
MenuPrivate::DeleteBitmaps()
{
delete sMenuItemAlt;
delete sMenuItemShift;
delete sMenuItemControl;
delete sMenuItemOption;
delete sMenuItemShift;
delete sMenuItemAlt;
delete sMenuItemMenu;
}
/* static */
const BBitmap *
MenuPrivate::MenuItemCommand()
{
if (BMenu::sAltAsCommandKey)
return sMenuItemAlt;
return sMenuItemControl;
}
/* static */
const BBitmap *
MenuPrivate::MenuItemControl()
{
if (BMenu::sAltAsCommandKey)
return sMenuItemControl;
return sMenuItemAlt;
}
/* static */
const BBitmap *
MenuPrivate::MenuItemOption()
{
return sMenuItemOption;
}
/* static */
const BBitmap *
const BBitmap*
MenuPrivate::MenuItemShift()
{
return sMenuItemShift;
}
/* static */
const BBitmap*
MenuPrivate::MenuItemControl()
{
switch (BMenu::sControlKey) {
case 0x5d:
case 0x5f:
return sMenuItemAlt;
case 0x66:
case 0x67:
return sMenuItemOption;
}
return sMenuItemControl;
}
/* static */
const BBitmap*
MenuPrivate::MenuItemOption()
{
switch (BMenu::sOptionKey) {
case 0x5c:
case 0x60:
return sMenuItemControl;
case 0x66:
case 0x67:
return sMenuItemOption;
}
return sMenuItemAlt;
}
/* static */
const BBitmap*
MenuPrivate::MenuItemCommand()
{
switch (BMenu::sCommandKey) {
case 0x5c:
case 0x60:
return sMenuItemControl;
case 0x66:
case 0x67:
return sMenuItemOption;
}
return sMenuItemAlt;
}
/* static */
const BBitmap*
MenuPrivate::MenuItemMenu()
{
return sMenuItemMenu;
}
} // namespace BPrivate