diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Body.cpp | 32 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 16 |
2 files changed, 22 insertions, 26 deletions
diff --git a/src/Body.cpp b/src/Body.cpp index 859b20f..3169b6c 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -446,11 +446,12 @@ namespace QuickMedia { mouse_pos_raw.x = event.mouseButton.x; mouse_pos_raw.y = event.mouseButton.y; mouse_pos = sf::Vector2f(mouse_pos_raw.x, mouse_pos_raw.y); - prev_mouse_pos = mouse_pos; + prev_mouse_pos_raw = mouse_pos_raw; mouse_click_pos = mouse_pos; mouse_press_pixels_moved_abs = 0.0; has_scrolled_with_input = true; render_selected_item_bg = false; + click_counts = std::abs(mouse_scroll_accel.y) < 5.0f; return true; } else if(event.type == sf::Event::MouseButtonReleased && event.mouseButton.button == sf::Mouse::Left && mouse_left_pressed) { mouse_left_pressed = false; @@ -538,21 +539,15 @@ namespace QuickMedia { mouse_pos.x += (mouse_pos_diff.x * std::min(1.0f, frame_time * move_speed)); mouse_pos.y += (mouse_pos_diff.y * std::min(1.0f, frame_time * move_speed)); - sf::Vector2f mouse_smooth_diff(mouse_pos.x - prev_mouse_pos.x, mouse_pos.y - prev_mouse_pos.y); - prev_mouse_pos = mouse_pos; - - if(mouse_left_pressed && (scroll_past_first || scroll_past_last)) { - mouse_scroll_accel.x = 0.0f; - mouse_scroll_accel.y = 0.0f; - mouse_pos.x = mouse_pos_raw.x; - mouse_pos.y = mouse_pos_raw.y; - } + sf::Vector2f mouse_pos_raw_diff(mouse_pos_raw.x - prev_mouse_pos_raw.x, mouse_pos_raw.y - prev_mouse_pos_raw.y); + prev_mouse_pos_raw = mouse_pos_raw; if(items_cut_off) { if(mouse_left_pressed) { - selected_scrolled += mouse_smooth_diff.y; - page_scroll += mouse_smooth_diff.y; - mouse_scroll_accel = mouse_smooth_diff; + selected_scrolled += mouse_pos_raw_diff.y; + page_scroll += mouse_pos_raw_diff.y; + mouse_scroll_accel = sf::Vector2f(mouse_pos_raw_diff.x, mouse_pos_raw_diff.y); + mouse_scroll_accel *= (float)((double)frame_time * 288.0); } else { selected_scrolled += mouse_scroll_accel.y; page_scroll += mouse_scroll_accel.y; @@ -565,7 +560,7 @@ namespace QuickMedia { keep_selected_inside_body = true; } - if(mouse_scroll_accel.y > 0.1 && first_fully_visible_item != -1) { + if(mouse_scroll_accel.y > 0.1f && first_fully_visible_item != -1) { selected_item = first_fully_visible_item; clamp_selection(); // TODO: Cache this @@ -580,7 +575,7 @@ namespace QuickMedia { if(first_visible_item_n == first_fully_visible_item) on_top_reached(); } - } else if(mouse_scroll_accel.y < -0.1 && last_fully_visible_item != -1) { + } else if(mouse_scroll_accel.y < -0.1f && last_fully_visible_item != -1) { selected_item = last_fully_visible_item; clamp_selection(); // TODO: Cache this @@ -1119,10 +1114,9 @@ namespace QuickMedia { item_pos.x = std::floor(pos.x); item_pos.y = std::floor(pos.y); - if(body_item_select_callback && mouse_left_clicked && !clicked_body_item) { + if(body_item_select_callback && mouse_left_clicked && !clicked_body_item && click_counts && std::abs(mouse_scroll_accel.y) < 5.0f) { sf::FloatRect item_box(pos + body_pos, sf::Vector2f(size.x, item_height)); - // TODO: Scale mouse_press_pixels_moved_abs with monitor PPI instead of using get_ui_scale() - if(item_box.contains(mouse_click_pos) && item_box.contains(mouse_release_pos) && mouse_press_pixels_moved_abs <= 50.0 * get_ui_scale()) { + if(item_box.contains(mouse_click_pos) && item_box.contains(mouse_release_pos) && mouse_press_pixels_moved_abs <= 25.0) { clicked_body_item = items[item_index]; set_selected_item(item_index, false); } @@ -1151,7 +1145,7 @@ namespace QuickMedia { auto image_scale = get_ratio(image_size_f, new_image_size); image.setScale(image_scale); image.setPosition(item_pos + sf::Vector2f(image_padding_x, padding_y)); - if(!is_touch_enabled() && thumbnail_mask_shader && item->thumbnail_mask_type == ThumbnailMaskType::CIRCLE) { + if(thumbnail_mask_shader && item->thumbnail_mask_type == ThumbnailMaskType::CIRCLE) { thumbnail_mask_shader->setUniform("resolution", new_image_size); window.draw(image, thumbnail_mask_shader); } else { diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 8de42a8..498de29 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -623,14 +623,16 @@ namespace QuickMedia { set_resource_loader_root_path(resources_root.c_str()); - if(!circle_mask_shader.loadFromFile(resources_root + "shaders/circle_mask.glsl", sf::Shader::Type::Fragment)) { - fprintf(stderr, "Failed to load %s/shaders/circle_mask.glsl\n", resources_root.c_str()); - abort(); - } + if(!is_touch_enabled()) { + if(!circle_mask_shader.loadFromFile(resources_root + "shaders/circle_mask.glsl", sf::Shader::Type::Fragment)) { + fprintf(stderr, "Failed to load %s/shaders/circle_mask.glsl\n", resources_root.c_str()); + abort(); + } - if(!rounded_rectangle_shader.loadFromFile(resources_root + "shaders/rounded_rectangle.glsl", sf::Shader::Type::Fragment)) { - fprintf(stderr, "Failed to load %s/shaders/rounded_rectangle.glsl\n", resources_root.c_str()); - abort(); + if(!rounded_rectangle_shader.loadFromFile(resources_root + "shaders/rounded_rectangle.glsl", sf::Shader::Type::Fragment)) { + fprintf(stderr, "Failed to load %s/shaders/rounded_rectangle.glsl\n", resources_root.c_str()); + abort(); + } } if(!loading_icon.loadFromFile(resources_root + "images/loading_icon.png")) { |