本文整理汇总了C++中InputState::mouseWheelMove方法的典型用法代码示例。如果您正苦于以下问题:C++ InputState::mouseWheelMove方法的具体用法?C++ InputState::mouseWheelMove怎么用?C++ InputState::mouseWheelMove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputState
的用法示例。
在下文中一共展示了InputState::mouseWheelMove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void View::update(const InputState &state) {
if(state.isKeyDown('g')) {
if(m_is_visible) {
if(m_cell_size == 3)
m_cell_size = 6;
else if(m_cell_size == 6)
m_cell_size = 9;
else {
m_cell_size = 1;
m_is_visible = false;
}
}
else {
m_cell_size = 3;
m_is_visible = true;
}
}
int height_change = state.mouseWheelMove() +
(state.isKeyDownAuto(InputKey::pagedown)? -1 : 0) +
(state.isKeyDownAuto(InputKey::pageup)? 1 : 0);
if(height_change)
m_height = clamp(m_height + height_change, 0, (int)Grid::max_height);
{
int actions[TileGroup::Group::side_count] = {
InputKey::kp_1,
InputKey::kp_2,
InputKey::kp_3,
InputKey::kp_6,
InputKey::kp_9,
InputKey::kp_8,
InputKey::kp_7,
InputKey::kp_4
};
for(int n = 0; n < arraySize(actions); n++)
if(state.isKeyDownAuto(actions[n]))
m_view_pos += worldToScreen(TileGroup::Group::s_side_offsets[n] * m_cell_size);
}
if((state.isKeyPressed(InputKey::lctrl) && state.isMouseButtonPressed(InputButton::left)) ||
state.isMouseButtonPressed(InputButton::middle))
m_view_pos -= state.mouseMove();
IRect rect = worldToScreen(IBox(int3(0, 0, 0), asXZY(m_tile_map.dimensions(), 256)));
m_view_pos = clamp(m_view_pos, rect.min, rect.max - m_view_size);
}
示例2: process
void Window::process(const InputState &state) {
Window *popup = nullptr;
m_is_focused = true;
for(int n = 0; n < (int)m_children.size(); n++) {
m_children[n]->m_is_focused = false;
m_children[n]->m_is_mouse_over = false;
if(m_children[n]->m_is_closing) {
PWindow window = m_children[n];
m_children.erase(m_children.begin() + n);
sendEvent(window.get(), Event::window_closed, m_children[n]->m_closing_value);
n--;
}
else if(m_children[n]->m_is_popup)
popup = m_children[n].get();
}
if(popup) {
popup->process(state);
return;
}
int2 mouse_pos = state.mousePos();
int2 local_mouse_pos = mouse_pos - m_clipped_rect.min;
int finished_dragging = 0;
bool escape = state.isKeyDown(InputKey::esc);
InputButton button_map[3] = { InputButton::left, InputButton::right, InputButton::middle };
if(m_dragging_mode) {
if(!state.isMouseButtonPressed(button_map[m_dragging_mode - 1]) || escape)
finished_dragging = escape? -1 : 1;
}
else {
for(int k = 0; k < 3; k++) {
if(state.isMouseButtonDown(button_map[k])) {
m_dragging_mode = k + 1;
m_drag_start = local_mouse_pos;
break;
}
}
}
int2 focus_point = m_dragging_mode? m_drag_start : local_mouse_pos;
bool is_handled = false;
for(int n = (int)m_children.size() - 1; n >= 0; n--) {
Window *child = m_children[n].get();
if(child->isVisible() && m_has_hard_focus == child->m_has_hard_focus) {
if(m_has_hard_focus || child->rect().isInside(focus_point)) {
child->m_is_mouse_over = child->clippedRect().isInside(mouse_pos);
child->process(state);
is_handled = true;
break;
}
}
}
if(!is_handled) {
if(m_dragging_mode && !is_handled) {
if(m_has_inner_rect && m_dragging_mode - 1 == 2) {
setInnerRect(m_inner_rect + state.mouseMove());
is_handled = true;
}
if(!is_handled)
is_handled = onMouseDrag(state, m_drag_start, local_mouse_pos, m_dragging_mode - 1, finished_dragging);
if(!is_handled)
is_handled = onMouseClick(state, local_mouse_pos, m_dragging_mode - 1, finished_dragging);
}
if(!is_handled) {
if(m_has_inner_rect) {
int wheel = state.mouseWheelMove();
int2 vector(0, 0);
if(wheel)
vector.y += wheel * rect().height() / 8;
if(state.isKeyDownAuto(InputKey::pageup, 2))
vector.y += rect().height();
if(state.isKeyDownAuto(InputKey::pagedown, 2))
vector.y -= rect().height();
setInnerRect(m_inner_rect + vector);
}
onInput(state);
}
}
if(escape && (!m_parent || m_is_popup) && !m_dragging_mode) // sending Event::escape only from main window
sendEvent(this, Event::escape); //TODO: send only to focused windows
if(finished_dragging)
m_dragging_mode = 0;
}