本文整理汇总了C++中Flags::add方法的典型用法代码示例。如果您正苦于以下问题:C++ Flags::add方法的具体用法?C++ Flags::add怎么用?C++ Flags::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Flags
的用法示例。
在下文中一共展示了Flags::add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
KeyCode::reverseNormalizeKey(KeyCode& key, Flags& flags, EventType eventType, KeyboardType keyboardType)
{
if (! Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_disable_numpad_hack)) {
for (unsigned int i = 0; i < sizeof(fnkeyhack) / sizeof(fnkeyhack[0]); ++i) {
if (fnkeyhack[i].reverse(key, flags, eventType)) break;
}
}
if (keyboardType == KeyboardType::POWERBOOK ||
keyboardType == KeyboardType::POWERBOOK_G4 ||
keyboardType == KeyboardType::POWERBOOK_G4_TI) {
if (key == KeyCode::ENTER) { key = KeyCode::ENTER_POWERBOOK; }
}
// ------------------------------------------------------------
// Don't add ModifierFlag::FN automatically for F-keys, PageUp/PageDown/Home/End and Forward Delete.
//
// PageUp/PageDown/Home/End and Forward Delete are entered by fn+arrow, fn+delete normally,
// And, from Cocoa Application, F-keys and PageUp,... keys have Fn modifier
// even if Fn key is not pressed actually.
// So, it's natural adding ModifierFlag::FN to these keys.
// However, there is a reason we must not add ModifierFlag::FN to there keys.
//
// Mission Control may have "fn" as shortcut key.
// If we add ModifierFlag::FN here,
// "XXX to PageUp" launches Mission Control because Mission Control recognizes fn key was pressed.
//
// It's not intended behavior from users.
// Therefore, we don't add ModifierFlag::FN for these keys.
// ------------------------------------------------------------
// set ModifierFlag::KEYPAD, ModifierFlag::CURSOR
flags.stripCURSOR().stripKEYPAD();
// Note: KEYPAD_CLEAR, KEYPAD_COMMA have no ModifierFlag::KEYPAD bit.
if (key == KeyCode::KEYPAD_0 || key == KeyCode::KEYPAD_1 || key == KeyCode::KEYPAD_2 ||
key == KeyCode::KEYPAD_3 || key == KeyCode::KEYPAD_4 || key == KeyCode::KEYPAD_5 ||
key == KeyCode::KEYPAD_6 || key == KeyCode::KEYPAD_7 || key == KeyCode::KEYPAD_8 ||
key == KeyCode::KEYPAD_9 ||
key == KeyCode::KEYPAD_DOT ||
key == KeyCode::KEYPAD_MULTIPLY ||
key == KeyCode::KEYPAD_PLUS ||
key == KeyCode::KEYPAD_SLASH ||
key == KeyCode::KEYPAD_MINUS ||
key == KeyCode::KEYPAD_EQUAL) {
flags.add(ModifierFlag::KEYPAD);
}
if (key == KeyCode::CURSOR_UP ||
key == KeyCode::CURSOR_DOWN ||
key == KeyCode::CURSOR_LEFT ||
key == KeyCode::CURSOR_RIGHT) {
flags.add(ModifierFlag::CURSOR);
}
}
示例2:
TEST(Flags, add) {
Flags mask = ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_R | ModifierFlag::COMMAND_R;
Flags flags = mask;
EXPECT_EQ(mask, flags.stripFN());
flags.add(ModifierFlag::OPTION_L);
EXPECT_EQ(mask | ModifierFlag::OPTION_L, flags);
flags.add(ModifierFlag::NONE);
EXPECT_EQ(mask | ModifierFlag::OPTION_L | ModifierFlag::NONE, flags);
}
示例3:
void
FlagStatus::updateStatusMessage(void)
{
#ifndef FLAGSTATUS_TEST
Flags f = FlagStatus::getLockedFlags();
if (Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_show_sticky_modifier_status)) {
f.add(FlagStatus::getStickyFlags());
}
if (f != statusMessageFlags_) {
int index = BRIDGE_USERCLIENT_STATUS_MESSAGE_MODIFIER;
CommonData::clear_statusmessage(index);
if (f.isOn(ModifierFlag::FN)) { CommonData::append_statusmessage(index, "FN "); }
if (f.isOn(ModifierFlag::COMMAND_L) || f.isOn(ModifierFlag::COMMAND_R)) { CommonData::append_statusmessage(index, "Cmd "); }
if (f.isOn(ModifierFlag::CONTROL_L) || f.isOn(ModifierFlag::CONTROL_R)) { CommonData::append_statusmessage(index, "Ctrl "); }
if (f.isOn(ModifierFlag::OPTION_L) || f.isOn(ModifierFlag::OPTION_R)) { CommonData::append_statusmessage(index, "Opt "); }
if (f.isOn(ModifierFlag::SHIFT_L) || f.isOn(ModifierFlag::SHIFT_R)) { CommonData::append_statusmessage(index, "Shift "); }
if (f.isOn(ModifierFlag::EXTRA1)) { CommonData::append_statusmessage(index, "Ex1 "); }
if (f.isOn(ModifierFlag::EXTRA2)) { CommonData::append_statusmessage(index, "Ex2 "); }
if (f.isOn(ModifierFlag::EXTRA3)) { CommonData::append_statusmessage(index, "Ex3 "); }
if (f.isOn(ModifierFlag::EXTRA4)) { CommonData::append_statusmessage(index, "Ex4 "); }
if (f.isOn(ModifierFlag::EXTRA5)) { CommonData::append_statusmessage(index, "Ex5 "); }
CommonData::send_notification_statusmessage(index);
}
statusMessageFlags_ = f;
#endif
}
示例4:
Flags
FlagStatus::makeFlags(void)
{
Flags flags;
for (int i = 0; item_[i].flag_ != ModifierFlag::NONE; ++i) {
flags.add(item_[i].makeFlag());
}
return flags;
}
示例5: makeFlags
Flags FlagStatus::makeFlags(void) const {
Flags flags;
for (size_t i = 0; i < item_.size(); ++i) {
if (item_[i].sum(false) > 0) {
flags.add(item_[i].flag_);
}
}
return flags;
}
示例6: Flags
TEST(KeyCode, reverseNormalizeKey) {
std::vector<NormalizeItem> vec;
// ENTER_POWERBOOK
vec.push_back(NormalizeItem(KeyCode::ENTER_POWERBOOK, ModifierFlag::SHIFT_L,
KeyCode::ENTER_POWERBOOK, ModifierFlag::SHIFT_L, KeyboardType::POWERBOOK));
// ENTER_POWERBOOK(+FN)
vec.push_back(NormalizeItem(KeyCode::ENTER_POWERBOOK, ModifierFlag::SHIFT_L | ModifierFlag::FN,
KeyCode::ENTER_POWERBOOK, ModifierFlag::SHIFT_L | ModifierFlag::FN, KeyboardType::POWERBOOK));
// ----------------------------------------
// normal key (without FN)
vec.push_back(NormalizeItem(KeyCode::A, ModifierFlag::SHIFT_L,
KeyCode::A, ModifierFlag::SHIFT_L, KeyboardType::MACBOOK));
// KEYPAD (without FN)
for (size_t i = 0; i < sizeof(keypads) / sizeof(keypads[0]); ++i) {
KeyCode key = keypads[i][0];
Flags fromFlags = ModifierFlag::SHIFT_L;
Flags toFlags = fromFlags;
if (key != KeyCode::KEYPAD_CLEAR && key != KeyCode::KEYPAD_COMMA) toFlags.add(ModifierFlag::KEYPAD);
vec.push_back(NormalizeItem(key, fromFlags,
key, toFlags, KeyboardType::MACBOOK));
}
// PAGEUP (without FN)
for (size_t i = 0; i < sizeof(cursors) / sizeof(cursors[0]); ++i) {
vec.push_back(NormalizeItem(cursors[i][0], ModifierFlag::SHIFT_L,
cursors[i][0], ModifierFlag::SHIFT_L, KeyboardType::MACBOOK));
}
// ENTER (without FN)
vec.push_back(NormalizeItem(KeyCode::ENTER, ModifierFlag::SHIFT_L,
KeyCode::ENTER, ModifierFlag::SHIFT_L, KeyboardType::MACBOOK));
// FORWARD_DELETE (without FN)
vec.push_back(NormalizeItem(KeyCode::FORWARD_DELETE, ModifierFlag::SHIFT_L,
KeyCode::FORWARD_DELETE, ModifierFlag::SHIFT_L, KeyboardType::MACBOOK));
// CURSOR (without FN)
for (size_t i = 0; i < sizeof(cursors) / sizeof(cursors[0]); ++i) {
vec.push_back(NormalizeItem(cursors[i][1], ModifierFlag::CURSOR,
cursors[i][1], ModifierFlag::CURSOR, KeyboardType::MACBOOK));
}
// ----------------------------------------
// normal key(+FN)
vec.push_back(NormalizeItem(KeyCode::A, ModifierFlag::SHIFT_L | ModifierFlag::FN,
KeyCode::A, ModifierFlag::SHIFT_L | ModifierFlag::FN, KeyboardType::MACBOOK));
// KEYPAD(+FN)
for (size_t i = 0; i < sizeof(keypads) / sizeof(keypads[0]); ++i) {
KeyCode key = keypads[i][0];
Flags fromFlags = ModifierFlag::SHIFT_L | ModifierFlag::FN;
Flags toFlags = fromFlags;
if (key != KeyCode::KEYPAD_CLEAR && key != KeyCode::KEYPAD_COMMA) toFlags.add(ModifierFlag::KEYPAD);
vec.push_back(NormalizeItem(key, fromFlags,
key, toFlags, KeyboardType::MACBOOK));
}
// PAGEUP(+FN)
for (size_t i = 0; i < sizeof(cursors) / sizeof(cursors[0]); ++i) {
vec.push_back(NormalizeItem(cursors[i][0], ModifierFlag::SHIFT_L | ModifierFlag::FN,
cursors[i][0], ModifierFlag::SHIFT_L | ModifierFlag::FN, KeyboardType::MACBOOK));
}
// ENTER(+FN)
vec.push_back(NormalizeItem(KeyCode::ENTER, ModifierFlag::SHIFT_L | ModifierFlag::FN,
KeyCode::ENTER, ModifierFlag::SHIFT_L | ModifierFlag::FN, KeyboardType::MACBOOK));
// FORWARD_DELETE(+FN)
vec.push_back(NormalizeItem(KeyCode::FORWARD_DELETE, ModifierFlag::SHIFT_L | ModifierFlag::FN,
KeyCode::FORWARD_DELETE, ModifierFlag::SHIFT_L | ModifierFlag::FN, KeyboardType::MACBOOK));
// ----------------------------------------
for (std::vector<NormalizeItem>::iterator it = vec.begin(); it != vec.end(); ++it) {
KeyCode key;
// Down
key = it->fromKeyCode;
KeyCode::normalizeKey(key, it->fromFlags, EventType::DOWN, it->keyboardType);
KeyCode::reverseNormalizeKey(key, it->fromFlags, EventType::DOWN, it->keyboardType);
EXPECT_EQ(it->toKeyCode, key);
EXPECT_EQ(it->fromFlags, it->toFlags);
// Up
key = it->fromKeyCode;
KeyCode::normalizeKey(key, it->fromFlags, EventType::UP, it->keyboardType);
KeyCode::reverseNormalizeKey(key, it->fromFlags, EventType::UP, it->keyboardType);
EXPECT_EQ(it->toKeyCode, key);
EXPECT_EQ(it->fromFlags, it->toFlags);
}
// ======================================================================
// Test case for the following key sequence.
// (1) FN Down
// (2) Right-Arrow Down
//.........这里部分代码省略.........