aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--TODO3
-rw-r--r--include/RoundedRectangle.hpp2
-rw-r--r--shaders/rounded_rectangle.glsl2
-rw-r--r--shaders/rounded_rectangle_mask.glsl2
-rw-r--r--src/QuickMedia.cpp27
-rw-r--r--src/RoundedRectangle.cpp74
7 files changed, 69 insertions, 43 deletions
diff --git a/README.md b/README.md
index f4e1b0b..0a356ad 100644
--- a/README.md
+++ b/README.md
@@ -111,7 +111,7 @@ Type text and then wait and QuickMedia will automatically search.\
`Ctrl+S`: Save the image/video attached to the selected post.\
### File save controls
`Tab`: Switch between navigating the file manager and file name.\
-`Ctrl+Enter`/`Click on save`: Download the file.\
+`Ctrl+Enter`/`Click on save`: Save the file.\
`Esc`/`Click on cancel`: Cancel download.\
## Matrix text commands
`/upload`: Bring up the file manager and select a file to upload to the room, `Esc` to cancel.\
diff --git a/TODO b/TODO
index 8a2485d..f8677fb 100644
--- a/TODO
+++ b/TODO
@@ -165,4 +165,5 @@ Improve live stream startup time by downloading the video formats in parts inste
Add youtube chapters.
Faster seeking for long youtube videos.
Disable drop shadow on pinephone.
---resume-playback doesn't seem to work with the new youtube code. Or maybe --save-position-on-quit fails? \ No newline at end of file
+--resume-playback doesn't seem to work with the new youtube code. Or maybe --save-position-on-quit fails?
+Create drop shadow with shader instead of quads. \ No newline at end of file
diff --git a/include/RoundedRectangle.hpp b/include/RoundedRectangle.hpp
index 3652b03..2ebd915 100644
--- a/include/RoundedRectangle.hpp
+++ b/include/RoundedRectangle.hpp
@@ -27,7 +27,7 @@ namespace QuickMedia {
sf::Vector2f pos;
sf::Vector2f size;
sf::Vertex vertices[4];
- sf::Vertex drop_shadow_vertices[16];
+ sf::Vertex drop_shadow_vertices[32];
sf::Shader *rounded_rectangle_shader;
sf::Vector2f band_pos;
sf::Vector2f band_size;
diff --git a/shaders/rounded_rectangle.glsl b/shaders/rounded_rectangle.glsl
index d06a4ba..956e28e 100644
--- a/shaders/rounded_rectangle.glsl
+++ b/shaders/rounded_rectangle.glsl
@@ -5,7 +5,7 @@ uniform vec4 band_color;
uniform vec2 resolution;
float rounded_rect(vec2 coord, vec2 size, float r) {
- return length(max(abs(coord) - size, 0.0)) - r;
+ return smoothstep(0.0, 2.0, length(max(abs(coord) - size, 0.0)) - r);
}
void main() {
diff --git a/shaders/rounded_rectangle_mask.glsl b/shaders/rounded_rectangle_mask.glsl
index f6ff1a1..a4546e3 100644
--- a/shaders/rounded_rectangle_mask.glsl
+++ b/shaders/rounded_rectangle_mask.glsl
@@ -3,7 +3,7 @@ uniform float radius;
uniform vec2 resolution;
float rounded_rect(vec2 coord, vec2 size, float r) {
- return length(max(abs(coord) - size, 0.0)) - r;
+ return smoothstep(0.0, 2.0, length(max(abs(coord) - size, 0.0)) - r);
}
void main() {
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 5dd1ebb..2e2ad6d 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -611,8 +611,8 @@ namespace QuickMedia {
sf::Vector2i focused_monitor_center = get_focused_monitor_center(disp, monitor_size);
if(strcmp(plugin_name, "download") == 0) {
- window_size.x = std::min(1080, monitor_size.x);
- window_size.y = std::min(720, monitor_size.y);
+ window_size.x = std::min(900, monitor_size.x);
+ window_size.y = std::min(900, monitor_size.y);
}
x11_window = XCreateWindow(disp, parent_window ? parent_window : DefaultRootWindow(disp),
@@ -1771,7 +1771,7 @@ namespace QuickMedia {
page_stack.push(current_page);
current_page = PageType::VIDEO_CONTENT;
int selected_index = tabs[selected_tab].body->get_selected_item();
- video_content_page(tabs[selected_tab].page.get(), static_cast<VideoPage*>(new_tabs[0].page.get()), selected_item->get_title(), false, tabs[selected_tab].body->items, selected_index, &tab_associated_data[selected_tab].fetched_page, tab_associated_data[selected_tab].update_search_text);
+ video_content_page(tabs[selected_tab].page.get(), static_cast<VideoPage*>(new_tabs[0].page.get()), "", false, tabs[selected_tab].body->items, selected_index, &tab_associated_data[selected_tab].fetched_page, tab_associated_data[selected_tab].update_search_text);
} else if(new_tabs.size() == 1 && new_tabs[0].page->get_type() == PageTypez::CHAT) {
MatrixChatPage *tmp_matrix_chat_page = static_cast<MatrixChatPage*>(new_tabs[0].page.get());
MatrixRoomsPage *rooms_page = tmp_matrix_chat_page->rooms_page;
@@ -2765,7 +2765,6 @@ namespace QuickMedia {
break;
} else if(update_err == VideoPlayer::Error::EXITED && video_player->exit_status == 0 && (!is_matrix || is_youtube)) {
std::string new_video_url;
- std::string new_video_title;
if(video_tasks.valid()) {
TaskResult task_result = run_task_with_loading_screen([&video_tasks, &related_videos]() {
@@ -2788,11 +2787,10 @@ namespace QuickMedia {
}
// Find video that hasn't been played before in this video session
- auto find_next_video = [this, &related_videos, &video_page, &new_video_url, &new_video_title]() {
+ auto find_next_video = [this, &related_videos, &video_page, &new_video_url]() {
for(auto it = related_videos.begin(), end = related_videos.end(); it != end; ++it) {
if(!(*it)->url.empty() && watched_videos.find((*it)->url) == watched_videos.end() && !video_page->video_should_be_skipped((*it)->url)) {
new_video_url = (*it)->url;
- new_video_title = (*it)->get_title();
related_videos.erase(it);
break;
}
@@ -2847,7 +2845,6 @@ namespace QuickMedia {
return;
}
- video_title = std::move(new_video_title);
load_video_error_check(false);
} else if(update_err != VideoPlayer::Error::OK) {
show_notification("QuickMedia", "Failed to play the video (error code " + std::to_string((int)update_err) + ")", Urgency::CRITICAL);
@@ -3635,7 +3632,7 @@ namespace QuickMedia {
thread_page->set_url(selected_item->url);
BodyItems next_items;
// TODO: Use real title
- video_content_page(thread_page, thread_page, selected_item->get_title(), true, thread_body->items, thread_body->get_selected_item());
+ video_content_page(thread_page, thread_page, "", true, thread_body->items, thread_body->get_selected_item());
redraw = true;
} else {
BodyItem *selected_item = thread_body->get_selected();
@@ -5172,8 +5169,7 @@ namespace QuickMedia {
no_video = is_audio;
video_page->set_url(selected->url);
BodyItems next_items;
- // TODO: Add title
- video_content_page(matrix_chat_page, video_page.get(), "", message_type == MessageType::VIDEO || message_type == MessageType::AUDIO, next_items, 0);
+ video_content_page(matrix_chat_page, video_page.get(), selected_item_message->body, message_type == MessageType::VIDEO || message_type == MessageType::AUDIO, next_items, 0);
no_video = prev_no_video;
redraw = true;
avatar_applied = false;
@@ -6764,6 +6760,11 @@ namespace QuickMedia {
sf::RectangleShape bottom_panel_background;
bottom_panel_background.setFillColor(sf::Color(33, 37, 44));
+ const sf::Color color(0, 0, 0, 50);
+ const float gradient_height = 5.0f;
+
+ sf::Vertex gradient_points[4];
+
auto save_file = [this, &file_name_entry, &file_manager_page]() -> std::string {
auto u8 = file_name_entry.get_text().toUtf8();
std::string *filename = (std::string*)&u8;
@@ -6865,6 +6866,11 @@ namespace QuickMedia {
file_name_entry.set_max_width(std::floor(cancel_button.get_position().x - bottom_panel_spacing - file_name_label.getLocalBounds().width - bottom_panel_spacing - bottom_panel_spacing));
bottom_panel_background.setPosition(0.0f, window_size.y - std::floor(bottom_panel_padding * 2.0f + file_name_entry.get_height()));
bottom_panel_background.setSize(sf::Vector2f(window_size.x, std::floor(bottom_panel_padding * 2.0f + file_name_entry.get_height())));
+
+ gradient_points[0] = sf::Vertex(bottom_panel_background.getPosition() + sf::Vector2f(0.0f, -gradient_height), sf::Color(color.r, color.g, color.b, 0));
+ gradient_points[1] = sf::Vertex(bottom_panel_background.getPosition() + sf::Vector2f(bottom_panel_background.getSize().x, -gradient_height), sf::Color(color.r, color.g, color.b, 0));
+ gradient_points[2] = sf::Vertex(bottom_panel_background.getPosition() + sf::Vector2f(bottom_panel_background.getSize().x, 0.0f), color);
+ gradient_points[3] = sf::Vertex(bottom_panel_background.getPosition() + sf::Vector2f(0.0f, 0.0f), color);
}
window.clear(back_color);
@@ -6875,6 +6881,7 @@ namespace QuickMedia {
file_manager_body->draw(window, body_pos, body_size - sf::Vector2f(0.0f, bottom_panel_background.getSize().y));
window.draw(bottom_panel_background);
+ window.draw(gradient_points, 4, sf::Quads);
window.draw(file_name_label);
cancel_button.draw(window);
save_button.draw(window);
diff --git a/src/RoundedRectangle.cpp b/src/RoundedRectangle.cpp
index 33d7d64..f9b79c4 100644
--- a/src/RoundedRectangle.cpp
+++ b/src/RoundedRectangle.cpp
@@ -16,29 +16,21 @@ namespace QuickMedia {
const sf::Color shadow_color(0, 0, 0, 50);
- // Top
- drop_shadow_vertices[0].color = sf::Color(shadow_color.r, shadow_color.g, shadow_color.b, 0);
- drop_shadow_vertices[1].color = sf::Color(shadow_color.r, shadow_color.g, shadow_color.b, 0);
- drop_shadow_vertices[2].color = shadow_color;
- drop_shadow_vertices[3].color = shadow_color;
-
- // Bottom
- drop_shadow_vertices[4].color = shadow_color;
- drop_shadow_vertices[5].color = shadow_color;
- drop_shadow_vertices[6].color = sf::Color(shadow_color.r, shadow_color.g, shadow_color.b, 0);
- drop_shadow_vertices[7].color = sf::Color(shadow_color.r, shadow_color.g, shadow_color.b, 0);
-
- // Left
- drop_shadow_vertices[8].color = sf::Color(shadow_color.r, shadow_color.g, shadow_color.b, 0);
- drop_shadow_vertices[9].color = sf::Color(shadow_color.r, shadow_color.g, shadow_color.b, 0);
- drop_shadow_vertices[10].color = shadow_color;
- drop_shadow_vertices[11].color = shadow_color;
-
- // Right
- drop_shadow_vertices[12].color = sf::Color(shadow_color.r, shadow_color.g, shadow_color.b, 0);
- drop_shadow_vertices[13].color = sf::Color(shadow_color.r, shadow_color.g, shadow_color.b, 0);
- drop_shadow_vertices[14].color = shadow_color;
- drop_shadow_vertices[15].color = shadow_color;
+ // Sides
+ for(size_t i = 0; i < 16; i += 4) {
+ drop_shadow_vertices[i + 0].color = sf::Color(shadow_color.r, shadow_color.g, shadow_color.b, 0);
+ drop_shadow_vertices[i + 1].color = sf::Color(shadow_color.r, shadow_color.g, shadow_color.b, 0);
+ drop_shadow_vertices[i + 2].color = shadow_color;
+ drop_shadow_vertices[i + 3].color = shadow_color;
+ }
+
+ // Corners
+ for(size_t i = 16; i < 32; i += 4) {
+ drop_shadow_vertices[i + 0].color = sf::Color(shadow_color.r, shadow_color.g, shadow_color.b, 0);
+ drop_shadow_vertices[i + 1].color = sf::Color(shadow_color.r, shadow_color.g, shadow_color.b, 0);
+ drop_shadow_vertices[i + 2].color = sf::Color(shadow_color.r, shadow_color.g, shadow_color.b, 0);
+ drop_shadow_vertices[i + 3].color = sf::Color(shadow_color.r, shadow_color.g, shadow_color.b, 100);
+ }
}
void RoundedRectangle::set_position(sf::Vector2f pos) {
@@ -57,10 +49,10 @@ namespace QuickMedia {
drop_shadow_vertices[3].position = pos + sf::Vector2f(radius*0.5f, 0.0f);
// Bottom
- drop_shadow_vertices[4].position = pos + sf::Vector2f(radius*0.5f, size.y);
- drop_shadow_vertices[5].position = pos + size - sf::Vector2f(radius*0.5f, 0.0f);
- drop_shadow_vertices[6].position = pos + size - sf::Vector2f(radius*0.5f, 0.0f) + sf::Vector2f(0.0f, shadow_radius);
- drop_shadow_vertices[7].position = pos + sf::Vector2f(radius*0.5f, size.y) + sf::Vector2f(0.0f, shadow_radius);
+ drop_shadow_vertices[4].position = pos + sf::Vector2f(size.x - radius*0.5f, size.y + shadow_radius);
+ drop_shadow_vertices[5].position = pos + sf::Vector2f(radius*0.5f, size.y + shadow_radius);
+ drop_shadow_vertices[6].position = pos + sf::Vector2f(radius*0.5f, size.y);
+ drop_shadow_vertices[7].position = pos + sf::Vector2f(size.x - radius*0.5f, size.y);
// Left
drop_shadow_vertices[8].position = pos + sf::Vector2f(-shadow_radius, size.y - radius*0.5f);
@@ -73,6 +65,32 @@ namespace QuickMedia {
drop_shadow_vertices[13].position = pos + sf::Vector2f(size.x + shadow_radius, size.y - radius*0.5f);
drop_shadow_vertices[14].position = pos + sf::Vector2f(size.x, size.y - radius*0.5f);
drop_shadow_vertices[15].position = pos + sf::Vector2f(size.x, radius*0.5f);
+
+ const float overshoot = 1.7f;
+
+ // Top left
+ drop_shadow_vertices[16].position = pos + sf::Vector2f(-shadow_radius, radius*0.5f);
+ drop_shadow_vertices[17].position = pos + sf::Vector2f(-shadow_radius*overshoot, -shadow_radius*overshoot);
+ drop_shadow_vertices[18].position = pos + sf::Vector2f(radius*0.5f, -shadow_radius);
+ drop_shadow_vertices[19].position = pos + sf::Vector2f(radius*0.5f, radius*0.5f);
+
+ // Top right
+ drop_shadow_vertices[20].position = pos + sf::Vector2f(size.x - radius*0.5f, -shadow_radius);
+ drop_shadow_vertices[21].position = pos + sf::Vector2f(size.x + shadow_radius*overshoot, -shadow_radius*overshoot);
+ drop_shadow_vertices[22].position = pos + sf::Vector2f(size.x + shadow_radius, radius*0.5f);
+ drop_shadow_vertices[23].position = pos + sf::Vector2f(size.x - radius*0.5f, radius*0.5f);
+
+ // Bottom right
+ drop_shadow_vertices[24].position = pos + sf::Vector2f(size.x + shadow_radius, size.y - radius*0.5f);
+ drop_shadow_vertices[25].position = pos + sf::Vector2f(size.x + shadow_radius*overshoot, size.y + shadow_radius*overshoot);
+ drop_shadow_vertices[26].position = pos + sf::Vector2f(size.x - radius*0.5f, size.y + shadow_radius);
+ drop_shadow_vertices[27].position = pos + sf::Vector2f(size.x - radius*0.5f, size.y - radius*0.5f);
+
+ // Bottom left
+ drop_shadow_vertices[28].position = pos + sf::Vector2f(radius*0.5f, size.y + shadow_radius);
+ drop_shadow_vertices[29].position = pos + sf::Vector2f(-shadow_radius*overshoot, size.y + shadow_radius*overshoot);
+ drop_shadow_vertices[30].position = pos + sf::Vector2f(-shadow_radius, size.y - radius*0.5f);
+ drop_shadow_vertices[31].position = pos + sf::Vector2f(radius*0.5f, size.y - radius*0.5f);
}
void RoundedRectangle::set_size(sf::Vector2f size) {
@@ -104,7 +122,7 @@ namespace QuickMedia {
void RoundedRectangle::draw(sf::RenderTarget &target) {
if(drop_shadow_enabled)
- target.draw(drop_shadow_vertices, 16, sf::Quads);
+ target.draw(drop_shadow_vertices, 32, sf::Quads);
// TODO: Remove these for optimizations. Also do the same in other places where setUniform is called
rounded_rectangle_shader->setUniform("radius", radius);