本文整理汇总了C++中Flags::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ Flags::remove方法的具体用法?C++ Flags::remove怎么用?C++ Flags::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Flags
的用法示例。
在下文中一共展示了Flags::remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(Flags, remove) {
{
Flags flags = ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_R | ModifierFlag::COMMAND_R;
Flags removed = ModifierFlag::CONTROL_R | ModifierFlag::COMMAND_R;
EXPECT_EQ(removed, flags.remove(ModifierFlag::SHIFT_L));
}
{
Flags flags = ModifierFlag::SHIFT_L | ModifierFlag::SHIFT_R | ModifierFlag::CURSOR | ModifierFlag::EXTRA2 | ModifierFlag::NONE;
Flags removed = ModifierFlag::SHIFT_R | ModifierFlag::CURSOR | ModifierFlag::EXTRA2 | ModifierFlag::NONE;
EXPECT_EQ(removed, flags.remove(ModifierFlag::SHIFT_L));
removed = ModifierFlag::SHIFT_R | ModifierFlag::NONE;
EXPECT_EQ(removed, flags.remove(ModifierFlag::CURSOR | ModifierFlag::EXTRA2));
removed = 0;
EXPECT_EQ(removed, flags.remove(ModifierFlag::SHIFT_R | ModifierFlag::NONE));
removed = 0;
EXPECT_EQ(removed, flags.remove(ModifierFlag::OPTION_L | ModifierFlag::COMMAND_R));
}
{
// chain
Flags flags = ModifierFlag::SHIFT_L | ModifierFlag::SHIFT_R | ModifierFlag::CONTROL_R | ModifierFlag::COMMAND_R;
Flags removed = ModifierFlag::CONTROL_R | ModifierFlag::COMMAND_R;
EXPECT_EQ(removed, flags.remove(ModifierFlag::SHIFT_L).remove(ModifierFlag::SHIFT_R));
}
}
示例2: ptr
bool
KeyToKey::remap(RemapParams& remapParams)
{
if (remapParams.isremapped) return false;
if (! fromkeychecker_.isFromKey(remapParams.params.ex_iskeydown, remapParams.params.key, FlagStatus::makeFlags(), fromKey_.key, fromKey_.flags)) return false;
remapParams.isremapped = true;
// ------------------------------------------------------------
// handle EventType & Modifiers
// Let's consider the following setting.
// __KeyToKey__ KeyCode::SHIFT_R, ModifierFlag::SHIFT_R | ModifierFlag::NONE, KeyCode::A, ModifierFlag::SHIFT_R
// In this setting, we need decrease SHIFT_R only once.
// So, we transform values of fromKey_.
//
// [before]
// fromKey_.key : KeyCode::SHIFT_R
// fromKey_.flags : ModifierFlag::SHIFT_R | ModifierFlag::NONE
//
// [after]
// fromKey_.key : KeyCode::SHIFT_R
// fromKey_.flags : ModifierFlag::NONE
//
// Note: we need to apply this transformation after calling fromkeychecker_.isFromKey.
Flags fromFlags = fromKey_.flags;
fromFlags.remove(fromKey_.key.getModifierFlag());
if (remapParams.params.ex_iskeydown) {
retractInput();
} else {
restoreInput();
}
// ----------------------------------------
// Handle beforeKeys_
if (remapParams.params.ex_iskeydown) {
FlagStatus::temporary_decrease(fromFlags);
for (size_t i = 0; i < beforeKeys_.size(); ++i) {
FlagStatus::temporary_increase(beforeKeys_[i].flags);
Flags f = FlagStatus::makeFlags();
KeyboardType keyboardType = remapParams.params.keyboardType;
EventOutputQueue::FireKey::fire_downup(f, beforeKeys_[i].key, keyboardType);
FlagStatus::temporary_decrease(beforeKeys_[i].flags);
}
FlagStatus::temporary_increase(fromFlags);
}
// ----------------------------------------
// Handle toKeys_
switch (toKeys_.size()) {
case 0:
break;
case 1:
{
EventType newEventType = remapParams.params.ex_iskeydown ? EventType::DOWN : EventType::UP;
KeyCode toKey = toKeys_[0].key;
ModifierFlag toModifierFlag = toKey.getModifierFlag();
if (toModifierFlag == ModifierFlag::NONE && ! VirtualKey::isKeyLikeModifier(toKey)) {
// toKey
FlagStatus::temporary_decrease(fromFlags);
FlagStatus::temporary_increase(toKeys_[0].flags);
} else {
// toModifier or VirtualKey::isKeyLikeModifier
if (toModifierFlag != ModifierFlag::NONE) {
newEventType = EventType::MODIFY;
}
if (remapParams.params.ex_iskeydown) {
FlagStatus::increase(toKeys_[0].flags | toModifierFlag);
FlagStatus::decrease(fromFlags);
} else {
FlagStatus::decrease(toKeys_[0].flags | toModifierFlag);
FlagStatus::increase(fromFlags);
}
}
// ----------------------------------------
Params_KeyboardEventCallBack::auto_ptr ptr(Params_KeyboardEventCallBack::alloc(newEventType,
FlagStatus::makeFlags(),
toKey,
remapParams.params.keyboardType,
remapParams.params.repeat));
if (! ptr) return false;
Params_KeyboardEventCallBack& params = *ptr;
if (remapParams.params.ex_iskeydown && ! isRepeatEnabled_) {
KeyboardRepeat::cancel();
} else {
KeyboardRepeat::set(params);
}
EventOutputQueue::FireKey::fire(params);
//.........这里部分代码省略.........