[gegl] lua: implement interactive rating stars in viewer mode



commit c598fe42115358fe8c8bd5bb04b492fc82465bbd
Author: Øyvind Kolås <pippin gimp org>
Date:   Thu Apr 11 00:29:38 2019 +0200

    lua: implement interactive rating stars in viewer mode

 bin/lua/viewer.lua | 38 ++++++++++++++++++++++++++++++++++----
 bin/ui-core.c      |  1 +
 2 files changed, 35 insertions(+), 4 deletions(-)
---
diff --git a/bin/lua/viewer.lua b/bin/lua/viewer.lua
index a27b0eaa2..cae2bffbe 100644
--- a/bin/lua/viewer.lua
+++ b/bin/lua/viewer.lua
@@ -297,6 +297,9 @@ if o.is_video ~= 0 then
 
     cr:set_source_rgba(1,1,1,.5)
     cr:fill()
+
+
+
   end
 
   cr:rectangle(height * .1 , height * .9, width - height * .2, height *.1)
@@ -370,6 +373,9 @@ if path:find(".pdf$") or path:find('.PDF$') then
   mrg:add_binding("page-down", NULL, "next page",
     function(e) pdf_next_page() e:stop_propagate() end)
 
+
+
+
 end
 
 
@@ -406,11 +412,35 @@ if o.commandline[0] == 0 then
     function() ffi.C.argvs_eval ("star 0") end)
 end
 
-local stars = o:get_key_int(o.path, "stars")
+if o.show_controls ~= 0 then
 
-if stars >= 0 then
-  mrg:print('' .. stars)
+  local stars = o:get_key_int(o.path, "stars")
+
+  if stars < 0 then stars = 0 end
+
+  --if stars >= 0 then
+  if true then
+    mrg:start('div.viewerstars')
+    mrg:set_xy(mrg:height()*.15 + 2,mrg:em())
+    for i=1,stars do
+      mrg:text_listen(Mrg.PRESS, function(e)
+          ffi.C.argvs_eval('star ' .. i)
+          print('star ' .. i)
+      end)
+      mrg:print('★')
+      mrg:text_listen_done()
+    end
+    mrg:set_style('color:gray;')
+    for i=stars+1,5 do
+      mrg:text_listen(Mrg.PRESS, function(e)
+          ffi.C.argvs_eval('star ' .. i)
+          print('star ' .. i)
+      end)
+      mrg:print('★')
+      mrg:text_listen_done()
+    end
+    mrg:close()
+  end
 end
 
-
 cr:restore()
diff --git a/bin/ui-core.c b/bin/ui-core.c
index 7cddb3fc9..c37e0c72d 100644
--- a/bin/ui-core.c
+++ b/bin/ui-core.c
@@ -31,6 +31,7 @@
 
 const char *css =
 "div.collstars {color: yellow; font-size: 1.2em; background: transparent;};"
+"div.viewerstars {color: yellow; font-size: 3.8vh; background: transparent;};"
 "div.lui { font-size: 2.0vh; color: white; padding-left:1em; padding-bottom: 1em; position: absolute; top: 
0; right: 1em; width:20em; background-color:rgba(1,0,0,0.0);}\n"
 "div.properties { color: blue; padding-left:1em; padding-bottom: 1em; position: absolute; top: 0; right: 
1em; width:20em; background-color:rgba(1,0,0,0.75);}\n"
 "div.property   { color: white; margin-top: -.5em; background:transparent;}\n"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]