| 1539 | state.mb_ev.button_code = button; |
| 1540 | } |
| 1541 | void glfw_scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { |
| 1542 | (void)window; |
| 1543 | // Setting the scroll values |
| 1544 | state.input.mouse.xscroll_delta = xoffset; |
| 1545 | state.input.mouse.yscroll_delta = yoffset; |
| 1546 | |
| 1547 | // Calling user defined callbacks |
| 1548 | for(uint32_t i = 0; i< state.input.scroll_cb_count; i++) { |
| 1549 | state.input.scroll_cbs[i](window, xoffset, yoffset); |
| 1550 | } |
| 1551 | // Populating the scroll event |
| 1552 | state.scr_ev.happened = true; |
| 1553 | state.scr_ev.xoffset = xoffset; |
| 1554 | state.scr_ev.yoffset = yoffset; |
| 1555 | |
| 1556 | |
| 1557 | // Scrolling the current div |
| 1558 | LfDiv* selected_div = &state.selected_div; |
| 1559 | if(!selected_div->scrollable) return; |
| 1560 | if((state.grabbed_div.id != -1 && selected_div->id != state.grabbed_div.id)) return; |
| 1561 | |
| 1562 | if(yoffset < 0.0f) { |
| 1563 | if(selected_div->total_area.y > (selected_div->aabb.size.y + selected_div->aabb.pos.y)) { |
| 1564 | if(state.theme.div_smooth_scroll) { |
| 1565 | *state.scroll_velocity_ptr -= state.theme.div_scroll_acceleration; |
| 1566 | state.div_velocity_accelerating = true; |
| 1567 | } else { |
| 1568 | *state.scroll_ptr -= state.theme.div_scroll_amount_px; |
| 1569 | } |
| 1570 | } |
| 1571 | } else if (yoffset > 0.0f) { |
| 1572 | if(*state.scroll_ptr) { |
| 1573 | if(state.theme.div_smooth_scroll) { |
| 1574 | *state.scroll_velocity_ptr += state.theme.div_scroll_acceleration; |
| 1575 | state.div_velocity_accelerating = false; |
| 1576 | } else { |
| 1577 | *state.scroll_ptr += state.theme.div_scroll_amount_px; |
| 1578 | } |
| 1579 | } |
| 1580 | } |
| 1581 | if(state.theme.div_smooth_scroll) |
| 1582 | *state.scroll_velocity_ptr = MIN(MAX(*state.scroll_velocity_ptr, -state.theme.div_scroll_max_velocity), state.theme.div_scroll_max_velocity); |
| 1583 | } |
| 1584 | void glfw_cursor_callback(GLFWwindow* window, double xpos, double ypos) { |
| 1585 | (void)window; |
| 1586 | LfMouse* mouse = &state.input.mouse; |
nothing calls this directly
no outgoing calls
no test coverage detected