aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Body.cpp15
-rw-r--r--src/Text.cpp38
2 files changed, 35 insertions, 18 deletions
diff --git a/src/Body.cpp b/src/Body.cpp
index 803cece..ffafb90 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -141,6 +141,7 @@ namespace QuickMedia {
thumbnail_max_size.y = 141;
sf::Vector2f loading_icon_size(loading_icon.getTexture()->getSize().x, loading_icon.getTexture()->getSize().y);
loading_icon.setOrigin(loading_icon_size.x * 0.5f, loading_icon_size.y * 0.5f);
+ render_selected_item_bg = !is_touch_enabled();
}
Body::~Body() {
@@ -398,31 +399,37 @@ namespace QuickMedia {
bool Body::on_event(const sf::RenderWindow &window, const sf::Event &event, bool keyboard_navigation) {
if(keyboard_navigation && event.type == sf::Event::KeyPressed && !event.key.alt) {
if(event.key.code == sf::Keyboard::Up || (event.key.control && event.key.code == sf::Keyboard::K)) {
+ render_selected_item_bg = true;
bool top_reached = select_previous_item();
if(!top_reached && on_top_reached)
on_top_reached();
return true;
} else if(event.key.code == sf::Keyboard::Down || (event.key.control && event.key.code == sf::Keyboard::J)) {
+ render_selected_item_bg = true;
bool bottom_reached = select_next_item();
if(!bottom_reached && on_bottom_reached)
on_bottom_reached();
return true;
} else if(event.key.code == sf::Keyboard::Home) {
+ render_selected_item_bg = true;
select_first_item();
if(on_top_reached)
on_top_reached();
return true;
} else if(event.key.code == sf::Keyboard::End) {
+ render_selected_item_bg = true;
select_last_item();
if(on_bottom_reached)
on_bottom_reached();
return true;
} else if(event.key.code == sf::Keyboard::PageUp) {
+ render_selected_item_bg = true;
bool top_reached = select_previous_page();
if(!top_reached && on_top_reached)
on_top_reached();
return true;
} else if(event.key.code == sf::Keyboard::PageDown) {
+ render_selected_item_bg = true;
bool bottom_reached = select_next_page();
if(!bottom_reached && on_bottom_reached)
on_bottom_reached();
@@ -445,6 +452,7 @@ namespace QuickMedia {
mouse_click_pos = mouse_pos;
mouse_press_pixels_moved_abs = 0.0;
has_scrolled_with_input = true;
+ render_selected_item_bg = false;
return true;
} else if(event.type == sf::Event::MouseButtonReleased && event.mouseButton.button == sf::Mouse::Left && mouse_left_pressed) {
mouse_left_pressed = false;
@@ -456,6 +464,7 @@ namespace QuickMedia {
mouse_press_pixels_moved_abs += std::sqrt(mouse_pos_diff.x*mouse_pos_diff.x + mouse_pos_diff.y*mouse_pos_diff.y);
mouse_pos_raw.x = event.mouseMove.x;
mouse_pos_raw.y = event.mouseMove.y;
+ render_selected_item_bg = false;
return true;
}
@@ -1093,7 +1102,7 @@ namespace QuickMedia {
void Body::draw_item(sf::RenderWindow &window, BodyItem *item, const sf::Vector2f &pos, const sf::Vector2f &size, const float item_height, const int item_index, const Json::Value &content_progress, bool include_embedded_item, bool merge_with_previous) {
sf::Vector2i thumbnail_size = get_item_thumbnail_size(item);
std::shared_ptr<ThumbnailData> item_thumbnail;
- if(draw_thumbnails && !item->thumbnail_url.empty())
+ if(draw_thumbnails && !merge_with_previous && !item->thumbnail_url.empty())
item_thumbnail = AsyncImageLoader::get_instance().get_thumbnail(item->thumbnail_url, item->thumbnail_is_local, thumbnail_size);
if(body_item_render_callback && include_embedded_item)
@@ -1116,7 +1125,7 @@ namespace QuickMedia {
//item_separator.setPosition(item_pos + sf::Vector2f(10.0f, std::floor(item_height + spacing_y * 0.5f)));
//window.draw(item_separator);
- if(item_index == selected_item) {
+ if(render_selected_item_bg && item_index == selected_item) {
item_background.set_position(item_pos);
item_background.set_size(sf::Vector2f(size.x, item_height));
item_background.draw(window);
@@ -1134,7 +1143,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(thumbnail_mask_shader && item->thumbnail_mask_type == ThumbnailMaskType::CIRCLE) {
+ if(!is_touch_enabled() && 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/Text.cpp b/src/Text.cpp
index 2940520..23dfb5b 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -49,10 +49,9 @@ namespace QuickMedia
vertices[0].setPrimitiveType(sf::PrimitiveType::Triangles);
vertices[1].setPrimitiveType(sf::PrimitiveType::Triangles);
vertices[2].setPrimitiveType(sf::PrimitiveType::Triangles);
- /*for(int i = 0; i < 3; ++i) {
+ for(int i = 0; i < 3; ++i) {
vertex_buffers[i] = sf::VertexBuffer(sf::PrimitiveType::Triangles, sf::VertexBuffer::Static);
- vertex_buffers[i].create(0);
- }*/
+ }
setString(std::move(_str));
}
@@ -346,9 +345,10 @@ namespace QuickMedia
dirty = false;
vertices_linear.clear();
- vertices[0].clear();
- vertices[1].clear();
- vertices[2].clear();
+ for(int i = 0; i < 3; ++i) {
+ vertices[i].clear();
+ vertices[i].resize(0);
+ }
boundingBox = sf::FloatRect();
sf::Font *latin_font;
@@ -584,13 +584,21 @@ namespace QuickMedia
}
boundingBox.height = num_lines * line_height;
- /*for(int i = 0; i < 3; ++i) {
+ // TODO: Clear |vertices| somehow even with editable text
+ for(int i = 0; i < 3; ++i) {
+ vertex_buffers[i].create(vertices[i].getVertexCount());
vertex_buffers[i].update(&vertices[i][0], vertices[i].getVertexCount(), 0);
- }*/
+ }
//url_ranges.clear();
- if(!editable)
+ if(!editable) {
+ for(int i = 0; i < 3; ++i) {
+ vertices[i].clear();
+ vertices[i].resize(0);
+ }
vertices_linear.clear();
+ vertices_linear.resize(0);
+ }
}
void Text::updateCaret()
@@ -895,23 +903,23 @@ namespace QuickMedia
const FontLoader::FontType font_types[] = { latin_font_type, FontLoader::FontType::CJK };
for(size_t i = 0; i < 2; ++i) {
- if(vertices[i].getVertexCount() == 0)
+ if(vertex_buffers[i].getVertexCount() == 0)
continue;
sf::Font *font = FontLoader::get_font(font_types[i]);
sf::RenderStates states;
states.transform.translate(pos);
states.texture = &font->getTexture(characterSize);
- //target.draw(vertex_buffers[i], states);
- target.draw(vertices[i], states);
+ target.draw(vertex_buffers[i], states);
+ //target.draw(vertices[i], states);
}
- if(vertices[2].getVertexCount() > 0) {
+ if(vertex_buffers[2].getVertexCount() > 0) {
sf::RenderStates states;
states.transform.translate(pos);
states.texture = TextureLoader::get_texture("images/emoji.png");
- //target.draw(vertex_buffers[2], states);
- target.draw(vertices[2], states);
+ target.draw(vertex_buffers[2], states);
+ //target.draw(vertices[2], states);
}
if(!editable) return true;