Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rounded slider #2365

Closed
leiserfg opened this issue Oct 2, 2015 · 7 comments
Closed

Rounded slider #2365

leiserfg opened this issue Oct 2, 2015 · 7 comments
Assignees

Comments

@leiserfg
Copy link

leiserfg commented Oct 2, 2015

I made this change to make the OSD look better (from my point of view) could replace the default slider or officially become a new one?

--- /tmp/osd.lua
+++ /home/leiserfg/.config/mpv/scripts/myosd.lua
@@ -537,10 +537,19 @@
                 if (slider_lo.stype == "bar") then
                     elem_ass:rect_cw(foH, foV, xp, elem_geo.h - foV)
                 elseif (slider_lo.stype == "slider") then
-                    elem_ass:move_to(xp, foV)
-                    elem_ass:line_to(xp+(innerH/2), (innerH/2)+foV)
-                    elem_ass:line_to(xp, (innerH)+foV)
-                    elem_ass:line_to(xp-(innerH/2), (innerH/2)+foV)
+                    elem_ass:rect_cw(xp, (9*innerH/20)+foV, elem_geo.w, (11*innerH/20)+foV)
+                    
+                    elem_ass:rect_cw(foH, (3*innerH/8)+foV, xp, (5*innerH/8)+foV)
+
+                       elem_ass:round_rect_cw(
+                            xp - innerH/2, 
+                            foV , 
+                            xp + innerH/2,
+                            foV + innerH,
+                            innerH/2.0)
+
+
+
                 end
             end
@ChrisK2
Copy link
Member

ChrisK2 commented Oct 2, 2015

I like how it looks. We can add it as another slider-design, but not as default, since rounded rectangles are rather expensive to draw and the slider has to be redrawn on every update.

Also the endpoint doesn't seem to be correct yet:
screen shot 2015-10-02 at 11 38 27

We also don't need the box around this slider, and no "inner spacing", so the slider can be drawn at full width/height of the element.

@leiserfg
Copy link
Author

leiserfg commented Oct 2, 2015

The slider has not box around, it is from the layout, I use the bottombar.
screenshot from 2015-10-02 09-10-33

@ChrisK2
Copy link
Member

ChrisK2 commented Oct 2, 2015

It does, the other layout just sets it to 0 thickness.

Edit: Actually, since the "knob" should go outside of the line at the end points, we still need to keep the box, just draw it with 0 thickness, otherwise the slider will start to move around around the endpoints because the canvas size changes.

@leiserfg
Copy link
Author

leiserfg commented Oct 2, 2015

I'll fix that this weekend and write this slider with another name.

@leiserfg
Copy link
Author

This is the new slider. I can't remove the rectangular area without change the loyouts.

--- /tmp/osc.lua
+++ /home/leiserfg/.config/mpv/scripts/osc.lua
@@ -361,7 +361,7 @@
             local foV = slider_lo.border + slider_lo.gap

             -- calculate positions of min and max points
-            if (slider_lo.stype == "slider") then
+            if (slider_lo.stype == "slider" or slider_lo.stype == "knob") then
                 element.slider.min.ele_pos = elem_geo.h / 2
                 element.slider.max.ele_pos = elem_geo.w - (elem_geo.h / 2)

@@ -541,6 +541,17 @@
                     elem_ass:line_to(xp+(innerH/2), (innerH/2)+foV)
                     elem_ass:line_to(xp, (innerH)+foV)
                     elem_ass:line_to(xp-(innerH/2), (innerH/2)+foV)
+       elseif (slider_lo.stype == "knob") then
+       elem_ass:rect_cw(xp, (9*innerH/20)+foV, elem_geo.w - foH, (11*innerH/20)+foV)
+                    
+                    elem_ass:rect_cw(foH, (3*innerH/8)+foV, xp, (5*innerH/8)+foV)
+
+                       elem_ass:round_rect_cw(
+                            xp - innerH/2, 
+                            foV , 
+                            xp + innerH/2,
+                            foV + innerH,
+                            innerH/2.0)
                 end
             end

@@ -1275,7 +1286,9 @@
     end

     if user_opts.seekbarstyle ~= "slider" and
-       user_opts.seekbarstyle ~= "bar" then
+       user_opts.seekbarstyle ~= "bar" and
+       user_opts.seekbarstyle ~= "knob" then   
+
         msg.warn("Invalid setting \"" .. user_opts.seekbarstyle
             .. "\" for seekbarstyle")
         user_opts.seekbarstyle = "slider"

@ChrisK2 ChrisK2 self-assigned this Oct 13, 2015
@ghost
Copy link

ghost commented Oct 20, 2015

Whatever happened to this?

(Also, should be a pull request.)

@ChrisK2
Copy link
Member

ChrisK2 commented Oct 20, 2015

I'll take a look, when I remember to. But probably still needs some more tweaks.

wiiaboo added a commit to wiiaboo/mpv that referenced this issue Nov 7, 2016
wiiaboo added a commit to wiiaboo/mpv that referenced this issue Nov 7, 2016
@wiiaboo wiiaboo closed this as completed in adf6563 Nov 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants