• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Vector_ModifierFlag类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Vector_ModifierFlag的典型用法代码示例。如果您正苦于以下问题:C++ Vector_ModifierFlag类的具体用法?C++ Vector_ModifierFlag怎么用?C++ Vector_ModifierFlag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Vector_ModifierFlag类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1:

  bool
  FlagStatus::isOn(const Vector_ModifierFlag& modifierFlags) const
  {
    bool strict = false;

    for (size_t i = 0; i < modifierFlags.size(); ++i) {
      if (modifierFlags[i] == ModifierFlag::ZERO) continue;

      if (modifierFlags[i] == ModifierFlag::NONE) {
        strict = true;
      } else {
        if (! isOn(modifierFlags[i])) return false;
      }
    }

    // If modifierFlags contains ModifierFlag::NONE,
    // return false when unspecified modifierflag is pressed.
    if (strict) {
      for (size_t i = 0; i < item_.size(); ++i) {
        if (item_[i].sum(true) > 0 &&
            ! modifierFlags.is_include(item_[i].flag_)) {
          return false;
        }
      }
    }

    return true;
  }
开发者ID:Brijen,项目名称:Karabiner,代码行数:28,代码来源:FlagStatus.cpp


示例2: TEST

TEST(FlagStatus, subtract) {
  FlagStatus flagStatus1;
  FlagStatus flagStatus2;

  flagStatus1.increase(ModifierFlag::CONTROL_L);
  flagStatus1.increase(ModifierFlag::OPTION_L);
  flagStatus1.increase(ModifierFlag::SHIFT_L);
  flagStatus1.increase(ModifierFlag::SHIFT_L);
  flagStatus1.decrease(ModifierFlag::COMMAND_R);

  flagStatus2.increase(ModifierFlag::CONTROL_L);
  flagStatus2.increase(ModifierFlag::FN);

  Vector_ModifierFlag v;
  flagStatus1.subtract(flagStatus2, v);
  EXPECT_EQ(3, v.size());
  EXPECT_EQ(ModifierFlag::OPTION_L, v[0]);
  EXPECT_EQ(ModifierFlag::SHIFT_L,  v[1]);
  EXPECT_EQ(ModifierFlag::SHIFT_L,  v[2]);

  flagStatus2.subtract(flagStatus1, v);
  EXPECT_EQ(2, v.size());
  EXPECT_EQ(ModifierFlag::COMMAND_R, v[0]);
  EXPECT_EQ(ModifierFlag::FN,        v[1]);
}
开发者ID:bohlander,项目名称:KeyRemap4MacBook,代码行数:25,代码来源:test.cpp


示例3: subtract

void FlagStatus::subtract(const FlagStatus& other, Vector_ModifierFlag& modifierFlags) const {
  modifierFlags.clear();

  if (item_.size() == other.item_.size()) {
    for (size_t i = 0; i < item_.size(); ++i) {
      int sum1 = item_[i].sum(true);
      int sum2 = other.item_[i].sum(true);
      if (sum1 > sum2) {
        for (int j = 0; j < sum1 - sum2; ++j) {
          modifierFlags.push_back(item_[i].flag_);
        }
      }
    }
  }
}
开发者ID:Beej126,项目名称:Karabiner,代码行数:15,代码来源:FlagStatus.cpp


示例4: isStuck

bool FlagStatus::isStuck(const Vector_ModifierFlag& modifierFlags) const {
  for (size_t i = 0; i < item_.size(); ++i) {
    if (item_[i].flag_ == ModifierFlag::ZERO) continue;
    if (item_[i].flag_ == ModifierFlag::NONE) continue;

    if (modifierFlags.is_include(item_[i].flag_) &&
        item_[i].sticky_count_ <= 0) {
      return false;
    }
  }
  return true;
}
开发者ID:Beej126,项目名称:Karabiner,代码行数:12,代码来源:FlagStatus.cpp


示例5: switch

    void
    DependingPressingPeriodKeyToKey::dokeyup(void)
    {
      switch (periodtype_) {
        case PeriodType::SHORT_PERIOD:
        {
          periodtype_ = PeriodType::NONE;
          keytokey_[KeyToKeyType::SHORT_PERIOD].call_remap_with_VK_PSEUDO_KEY(EventType::UP);
          break;
        }

        case PeriodType::LONG_PERIOD:
        {
          periodtype_ = PeriodType::NONE;
          keytokey_[KeyToKeyType::LONG_PERIOD].call_remap_with_VK_PSEUDO_KEY(EventType::UP);

          // ----------------------------------------
          // handle PRESSING_TARGET_KEY_ONLY
          if (periodMS_.enabled(PeriodMS::Type::PRESSING_TARGET_KEY_ONLY)) {
            if (! eventWatcherTarget_.isAnyEventHappen() &&
                ic_.getmillisec() < periodMS_.get(PeriodMS::Type::PRESSING_TARGET_KEY_ONLY)) {
              // ----------------------------------------
              // Restore FlagStatus at key down.
              Vector_ModifierFlag added;
              Vector_ModifierFlag removed;
              FlagStatus::globalFlagStatus().subtract(flagStatusWhenKeyPressed_, added);
              flagStatusWhenKeyPressed_.subtract(FlagStatus::globalFlagStatus(), removed);

              for (size_t i = 0; i < added.size(); ++i) {
                FlagStatus::globalFlagStatus().decrease(added[i]);
              }
              for (size_t i = 0; i < removed.size(); ++i) {
                FlagStatus::globalFlagStatus().increase(removed[i]);
              }

              // ----------------------------------------
              keytokey_[KeyToKeyType::PRESSING_TARGET_KEY_ONLY].call_remap_with_VK_PSEUDO_KEY(EventType::DOWN);
              keytokey_[KeyToKeyType::PRESSING_TARGET_KEY_ONLY].call_remap_with_VK_PSEUDO_KEY(EventType::UP);

              // ----------------------------------------
              // Restore current FlagStatus.
              for (size_t i = 0; i < added.size(); ++i) {
                FlagStatus::globalFlagStatus().increase(added[i]);
              }
              for (size_t i = 0; i < removed.size(); ++i) {
                FlagStatus::globalFlagStatus().decrease(removed[i]);
              }
            }
          }

          break;
        }

        case PeriodType::LONG_LONG_PERIOD:
        {
          periodtype_ = PeriodType::NONE;
          keytokey_[KeyToKeyType::LONG_LONG_PERIOD].call_remap_with_VK_PSEUDO_KEY(EventType::UP);
          break;
        }

        case PeriodType::NONE:
          // do nothing
          break;
      }

      eventWatcherTarget_.unobserve();
    }
开发者ID:cokerxi,项目名称:Karabiner,代码行数:67,代码来源:DependingPressingPeriodKeyToKey.cpp


示例6: TEST

TEST(Generic, changePressingState) {
  {
    FromEvent fe(KeyCode::RETURN);
    EXPECT_EQ(false, fe.isPressing());

    // ----------------------------------------
    // Without Flags
    // (For example, "change return to tab".)
    {
      FlagStatus currentFlags;
      Vector_ModifierFlag fromFlags;

      EXPECT_EQ(true, fe.changePressingState(*down_return, currentFlags, fromFlags));
      EXPECT_EQ(true, fe.isPressing());

      EXPECT_EQ(true, fe.changePressingState(*up_return, currentFlags, fromFlags));
      EXPECT_EQ(false, fe.isPressing());

      // Another event does not modify state
      EXPECT_EQ(false, fe.changePressingState(*down_shift, currentFlags, fromFlags));
      EXPECT_EQ(false, fe.isPressing());
      EXPECT_EQ(false, fe.changePressingState(*up_shift, currentFlags, fromFlags));
      EXPECT_EQ(false, fe.isPressing());
    }

    // ----------------------------------------
    // Set currentFlags
    // (For example, "change return to tab".)
    {
      Flags f(ModifierFlag::SHIFT_L);
      FlagStatus currentFlags(f);
      Vector_ModifierFlag fromFlags;

      EXPECT_EQ(true, fe.changePressingState(*down_return, currentFlags, fromFlags));
      EXPECT_EQ(true, fe.isPressing());

      EXPECT_EQ(true, fe.changePressingState(*up_return, currentFlags, fromFlags));
      EXPECT_EQ(false, fe.isPressing());
    }

    // ----------------------------------------
    // Set fromFlags
    // (For example, "change shift-return to tab".)
    {
      FlagStatus currentFlags;
      Vector_ModifierFlag fromFlags;
      fromFlags.push_back(ModifierFlag::SHIFT_L);

      // Does not change state if currentFlags lacks flags.
      EXPECT_EQ(false, fe.changePressingState(*down_return, currentFlags, fromFlags));
      EXPECT_EQ(false, fe.isPressing());

      EXPECT_EQ(false, fe.changePressingState(*up_return, currentFlags, fromFlags));
      EXPECT_EQ(false, fe.isPressing());
    }
    {
      Flags f(ModifierFlag::SHIFT_L);
      FlagStatus currentFlags(f);
      Vector_ModifierFlag fromFlags;
      fromFlags.push_back(ModifierFlag::SHIFT_L);

      EXPECT_EQ(true, fe.changePressingState(*down_return, currentFlags, fromFlags));
      EXPECT_EQ(true, fe.isPressing());

      EXPECT_EQ(true, fe.changePressingState(*up_return, currentFlags, fromFlags));
      EXPECT_EQ(false, fe.isPressing());
    }
    {
      Flags f(ModifierFlag::SHIFT_L);
      FlagStatus currentFlags(f);
      Vector_ModifierFlag fromFlags;
      fromFlags.push_back(ModifierFlag::SHIFT_L);

      EXPECT_EQ(true, fe.changePressingState(*down_return, currentFlags, fromFlags));
      EXPECT_EQ(true, fe.isPressing());

      // Change state even if currentFlags lacks flags when key is pressing.
      // This behavior is necessary for this case.
      // - shift down
      // - return down (shift-return is pressed.)
      // - shift up
      // - return up (shift-return is released.)
      currentFlags.reset();
      EXPECT_EQ(true, fe.changePressingState(*up_return, currentFlags, fromFlags));
      EXPECT_EQ(false, fe.isPressing());
      // return false if call changePressingState once again.
      EXPECT_EQ(false, fe.changePressingState(*up_return, currentFlags, fromFlags));
    }
  }
  {
    FromEvent fe(KeyCode::SPACE);
    FlagStatus currentFlags;
    Vector_ModifierFlag fromFlags;
    EXPECT_EQ(false, fe.changePressingState(*down_return, currentFlags, fromFlags));
    EXPECT_EQ(false, fe.changePressingState(*up_return, currentFlags, fromFlags));
  }
  {
    FromEvent fe(KeyCode::SHIFT_L);
    Flags f(ModifierFlag::SHIFT_L);
    FlagStatus currentFlags(f);
//.........这里部分代码省略.........
开发者ID:arturo-escalante,项目名称:Karabiner,代码行数:101,代码来源:test.cpp


示例7: TEST

TEST(FlagStatus, isOn) {
  {
    FlagStatus flagStatus;

    {
      Vector_ModifierFlag modifierFlags;
      EXPECT_TRUE(flagStatus.isOn(modifierFlags));
    }
    {
      Vector_ModifierFlag modifierFlags;
      modifierFlags.push_back(ModifierFlag(ModifierFlag::ZERO));
      EXPECT_TRUE(flagStatus.isOn(modifierFlags));
    }
    {
      Vector_ModifierFlag modifierFlags;
      modifierFlags.push_back(ModifierFlag::NONE);
      EXPECT_TRUE(flagStatus.isOn(modifierFlags));
    }
    {
      Vector_ModifierFlag modifierFlags;
      modifierFlags.push_back(ModifierFlag::NONE);
      modifierFlags.push_back(ModifierFlag::ZERO);
      EXPECT_TRUE(flagStatus.isOn(modifierFlags));
    }
  }

  {
    FlagStatus flagStatus;
    flagStatus.increase(ModifierFlag::SHIFT_L);

    {
      Vector_ModifierFlag modifierFlags;
      modifierFlags.push_back(ModifierFlag::SHIFT_L);
      EXPECT_TRUE(flagStatus.isOn(modifierFlags));
    }
    {
      Vector_ModifierFlag modifierFlags;
      modifierFlags.push_back(ModifierFlag::SHIFT_L);
      modifierFlags.push_back(ModifierFlag::NONE);
      EXPECT_TRUE(flagStatus.isOn(modifierFlags));
    }
    {
      Vector_ModifierFlag modifierFlags;
      modifierFlags.push_back(ModifierFlag::SHIFT_R);
      EXPECT_FALSE(flagStatus.isOn(modifierFlags));
    }
    {
      Vector_ModifierFlag modifierFlags;
      modifierFlags.push_back(ModifierFlag::SHIFT_L);
      modifierFlags.push_back(ModifierFlag::ZERO);
      EXPECT_TRUE(flagStatus.isOn(modifierFlags));
    }
  }

  {
    FlagStatus flagStatus;
    flagStatus.increase(ModifierFlag::SHIFT_L);
    flagStatus.increase(ModifierFlag::ZERO);

    {
      Vector_ModifierFlag modifierFlags;
      modifierFlags.push_back(ModifierFlag::SHIFT_L);
      EXPECT_TRUE(flagStatus.isOn(modifierFlags));
    }
    {
      Vector_ModifierFlag modifierFlags;
      modifierFlags.push_back(ModifierFlag::SHIFT_L);
      modifierFlags.push_back(ModifierFlag::NONE);
      EXPECT_TRUE(flagStatus.isOn(modifierFlags));
    }
    {
      Vector_ModifierFlag modifierFlags;
      modifierFlags.push_back(ModifierFlag::SHIFT_R);
      EXPECT_FALSE(flagStatus.isOn(modifierFlags));
    }
    {
      Vector_ModifierFlag modifierFlags;
      modifierFlags.push_back(ModifierFlag::SHIFT_L);
      modifierFlags.push_back(ModifierFlag::ZERO);
      EXPECT_TRUE(flagStatus.isOn(modifierFlags));
    }
    {
      Vector_ModifierFlag modifierFlags;
      modifierFlags.push_back(ModifierFlag::SHIFT_L);
      modifierFlags.push_back(ModifierFlag::ZERO);
      modifierFlags.push_back(ModifierFlag::NONE);
      EXPECT_TRUE(flagStatus.isOn(modifierFlags));
    }
  }

  {
    FlagStatus flagStatus;
    flagStatus.increase(ModifierFlag::SHIFT_L);
    flagStatus.increase(ModifierFlag::CONTROL_R);
    flagStatus.increase(ModifierFlag::COMMAND_R);

    {
      Vector_ModifierFlag modifierFlags;
      modifierFlags.push_back(ModifierFlag::SHIFT_L);
      EXPECT_TRUE(flagStatus.isOn(modifierFlags));
//.........这里部分代码省略.........
开发者ID:kurobeniq,项目名称:KeyRemap4MacBook,代码行数:101,代码来源:test.cpp



注:本文中的Vector_ModifierFlag类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Vector_double类代码示例发布时间:2022-05-31
下一篇:
C++ Vector_3类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap