Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package lite-xl-widgets for openSUSE:Factory 
checked in at 2023-01-07 17:19:45
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/lite-xl-widgets (Old)
 and      /work/SRC/openSUSE:Factory/.lite-xl-widgets.new.1563 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "lite-xl-widgets"

Sat Jan  7 17:19:45 2023 rev:3 rq:1056727 version:git20221227.a632bfd

Changes:
--------
--- /work/SRC/openSUSE:Factory/lite-xl-widgets/lite-xl-widgets.changes  
2022-11-04 17:42:09.183063477 +0100
+++ 
/work/SRC/openSUSE:Factory/.lite-xl-widgets.new.1563/lite-xl-widgets.changes    
    2023-01-07 17:23:08.135380576 +0100
@@ -1,0 +2,14 @@
+Sat Dec 31 00:48:36 UTC 2022 - [email protected]
+
+- Update to version git20221227.a632bfd:
+  * selectbox: enabled hide/show animation
+  * foldingbook: always update containers width
+  * checkbox: animate background color on click
+  * foldingbook: use new animation system for un/collapse
+  * added basic animation system and queue
+  * properly re-update widget on show and other fixes
+  * fonts: cache rebuild clear previous fonts
+  * minor annotation changes
+  * Added support for new force_scrollbar_status
+
+-------------------------------------------------------------------

Old:
----
  lite-xl-widgets-git20221023.648c067.tar.gz

New:
----
  lite-xl-widgets-git20221227.a632bfd.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ lite-xl-widgets.spec ++++++
--- /var/tmp/diff_new_pack.2oxu99/_old  2023-01-07 17:23:08.627383510 +0100
+++ /var/tmp/diff_new_pack.2oxu99/_new  2023-01-07 17:23:08.631383534 +0100
@@ -17,7 +17,7 @@
 
 %define programname lite-xl
 Name:           lite-xl-widgets
-Version:        git20221023.648c067
+Version:        git20221227.a632bfd
 Release:        0
 Summary:        Widgets for %{programname}
 License:        MIT

++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.2oxu99/_old  2023-01-07 17:23:08.679383821 +0100
+++ /var/tmp/diff_new_pack.2oxu99/_new  2023-01-07 17:23:08.679383821 +0100
@@ -1,6 +1,6 @@
 <servicedata>
 <service name="tar_scm">
                 <param 
name="url">https://github.com/lite-xl/lite-xl-widgets</param>
-              <param 
name="changesrevision">648c06723180c90194cba39c51e21bc05a707b2b</param></service></servicedata>
+              <param 
name="changesrevision">a632bfdf7c66bacc272fe2c962621cd9860058e1</param></service></servicedata>
 (No newline at EOF)
 

++++++ lite-xl-widgets-git20221023.648c067.tar.gz -> 
lite-xl-widgets-git20221227.a632bfd.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lite-xl-widgets-git20221023.648c067/button.lua 
new/lite-xl-widgets-git20221227.a632bfd/button.lua
--- old/lite-xl-widgets-git20221023.648c067/button.lua  2022-10-23 
06:34:26.000000000 +0200
+++ new/lite-xl-widgets-git20221227.a632bfd/button.lua  2022-12-27 
16:34:54.000000000 +0100
@@ -52,7 +52,7 @@
 end
 
 ---Set the icon drawn alongside the button text.
----@param code string
+---@param code? string
 ---@param color? renderer.color
 ---@param hover_color? renderer.color
 function Button:set_icon(code, color, hover_color)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lite-xl-widgets-git20221023.648c067/checkbox.lua 
new/lite-xl-widgets-git20221227.a632bfd/checkbox.lua
--- old/lite-xl-widgets-git20221023.648c067/checkbox.lua        2022-10-23 
06:34:26.000000000 +0200
+++ new/lite-xl-widgets-git20221227.a632bfd/checkbox.lua        2022-12-27 
16:34:54.000000000 +0100
@@ -19,6 +19,8 @@
   self.type_name = "widget.checkbox"
   self.checked = false
   self:set_label(label or "")
+  self.animating = false
+  self.animating_color = style.caret
 end
 
 ---Set the checkbox label and recalculates the widget size.
@@ -67,6 +69,23 @@
   self.checked = not self.checked
   self:on_checked(self.checked)
   self:on_change(self.checked)
+
+  self.animating = true
+  self.animating_color = {table.unpack(style.caret)}
+  local target_color = {table.unpack(style.caret)}
+
+  if self.checked then
+    self.animating_color[4] = 0
+    target_color[4] = 255
+  else
+    self.animating_color[4] = 255
+    target_color[4] = 0
+  end
+  self:animate(self.animating_color, {table.unpack(target_color)}, {
+    on_complete = function()
+      self.animating = false
+    end
+  })
 end
 
 function CheckBox:get_box_rect()
@@ -101,7 +120,9 @@
     self.hover_back or self.background_color or style.background
   )
 
-  if self.checked then
+  if self.animating then
+    renderer.draw_rect(bx + 2, by + 2, bw-4, bh-4, self.animating_color)
+  elseif self.checked then
     renderer.draw_rect(bx + 2, by + 2, bw-4, bh-4, style.caret)
   end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lite-xl-widgets-git20221023.648c067/dialog.lua 
new/lite-xl-widgets-git20221227.a632bfd/dialog.lua
--- old/lite-xl-widgets-git20221023.648c067/dialog.lua  2022-10-23 
06:34:26.000000000 +0200
+++ new/lite-xl-widgets-git20221227.a632bfd/dialog.lua  2022-12-27 
16:34:54.000000000 +0100
@@ -11,9 +11,9 @@
 local Label = require "widget.label"
 
 ---@class widget.dialog : widget
----@field private title widget.label
----@field private close widget.button
----@field private panel widget
+---@field protected title widget.label
+---@field protected close widget.button
+---@field protected panel widget
 local Dialog = Widget:extend()
 
 ---Constructor
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lite-xl-widgets-git20221023.648c067/filepicker.lua 
new/lite-xl-widgets-git20221227.a632bfd/filepicker.lua
--- old/lite-xl-widgets-git20221023.648c067/filepicker.lua      2022-10-23 
06:34:26.000000000 +0200
+++ new/lite-xl-widgets-git20221227.a632bfd/filepicker.lua      2022-12-27 
16:34:54.000000000 +0100
@@ -127,7 +127,12 @@
 
   self.button:set_position(self.file:get_right(), 0)
 
-  self.size.y = self.button:get_height()
+  self.size.y = math.max(
+    self.file:get_height(),
+    self.button:get_height()
+    -- something is off on calculation since adding border width should not
+    -- be needed to display whole rendered control at all...
+  ) + self.button.border.width
 end
 
 ---Add a lua pattern to the filters list
@@ -142,7 +147,7 @@
 end
 
 ---Set the operation mode for the file picker.
----@param mode widget.filepicker.modes | string
+---@param mode widget.filepicker.modes | string | integer
 function FilePicker:set_mode(mode)
   if type(mode) == "string" then
     ---@type integer
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lite-xl-widgets-git20221023.648c067/foldingbook.lua 
new/lite-xl-widgets-git20221227.a632bfd/foldingbook.lua
--- old/lite-xl-widgets-git20221023.648c067/foldingbook.lua     2022-10-23 
06:34:26.000000000 +0200
+++ new/lite-xl-widgets-git20221227.a632bfd/foldingbook.lua     2022-12-27 
16:34:54.000000000 +0100
@@ -155,7 +155,7 @@
     local cw, ch = 0, 0
 
     if prev_pane then
-      if prev_pane.expanded then
+      if prev_pane and prev_pane.container:is_visible() then
         ty = prev_pane.container:get_bottom() + 2
       else
         ty = prev_pane.tab:get_bottom() + 2
@@ -172,16 +172,23 @@
 
     pane.container.border.color = style.divider
 
-    if pane.expanded then
+    if pane.expanded and not pane.container.hiding then
       pane.container:set_position(cx, cy)
-      pane.container:set_size(cw, ch)
+      pane.container:set_size(cw)
       if not pane.container.visible then
-        pane.container:show()
+        pane.container:set_size(cw, ch)
+        pane.container:show_animated(true)
         pane.tab:set_icon("-")
+        pane.container.hiding = false
       end
-    elseif pane.container.visible then
+    elseif pane.container.visible and not pane.container.hiding then
       pane.tab:set_icon("+")
-      pane.container:hide()
+      pane.container.hiding = true
+      pane.container:hide_animated(true, false, {
+        on_complete = function()
+          pane.container.hiding = false
+        end
+      })
     end
 
     prev_pane = pane
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lite-xl-widgets-git20221023.648c067/fontdialog.lua 
new/lite-xl-widgets-git20221227.a632bfd/fontdialog.lua
--- old/lite-xl-widgets-git20221023.648c067/fontdialog.lua      2022-10-23 
06:34:26.000000000 +0200
+++ new/lite-xl-widgets-git20221227.a632bfd/fontdialog.lua      2022-12-27 
16:34:54.000000000 +0100
@@ -5,7 +5,6 @@
 --
 
 local core = require "core"
-local command = require "core.command"
 local style = require "core.style"
 local Button = require "widget.button"
 local CheckBox = require "widget.checkbox"
@@ -17,7 +16,11 @@
 local MessageBox = require "widget.messagebox"
 local Fonts = require "widget.fonts"
 
+---@class widget.fontdialog.fontoptions : renderer.fontoptions
+---@field size number
+
 ---@class widget.fontdialog : widget.dialog
+---@field super widget.dialog
 ---@field fontdata widget.fontslist.font
 ---@field preview widget.label
 ---@field font_size widget.numberbox
@@ -37,7 +40,7 @@
 
 ---Constructor
 ---@param font? widget.fontslist.font
----@param options? renderer.fontoptions
+---@param options? widget.fontdialog.fontoptions
 function FontDialog:new(font, options)
   FontDialog.super.new(self, "Font Selector")
 
@@ -190,7 +193,7 @@
   return self.fontdata
 end
 
----@param options renderer.fontoptions
+---@param options widget.fontdialog.fontoptions
 function FontDialog:set_options(options)
   if options.size then
     self.font_size:set_value(tonumber(options.size) or 15)
@@ -233,7 +236,7 @@
   end
 end
 
----@return renderer.fontoptions
+---@return widget.fontdialog.fontoptions
 function FontDialog:get_options()
   return {
     size = self.font_size:get_value(),
@@ -249,7 +252,7 @@
 
 ---Called when the user clicks on save
 ---@param font widget.fontslist.font
----@param options renderer.fontoptions
+---@param options widget.fontdialog.fontoptions
 function FontDialog:on_save(font, options) end
 
 function FontDialog:update()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lite-xl-widgets-git20221023.648c067/fonts/cache.lua 
new/lite-xl-widgets-git20221227.a632bfd/fonts/cache.lua
--- old/lite-xl-widgets-git20221023.648c067/fonts/cache.lua     2022-10-23 
06:34:26.000000000 +0200
+++ new/lite-xl-widgets-git20221227.a632bfd/fonts/cache.lua     2022-12-27 
16:34:54.000000000 +0100
@@ -50,11 +50,21 @@
   end
 end
 
+---Check if the cache is already building.
+---@return boolean building
+function FontCache:is_building()
+  if self.building or self.searching_monospaced then
+    return true
+  end
+  return false
+end
+
 ---Build the font cache and save it.
+---@return boolean started False if cache is already been built
 function FontCache:build()
-  if self.building or self.searching_monospaced then
+  if self:is_building() then
     core.log_quiet("The font cache is already been generated, please wait.")
-    return
+    return false
   end
 
   self.found = 0
@@ -79,12 +89,16 @@
     )
     self:verify_monospaced()
   end)
+
+  return true
 end
 
 ---Clear current font cache and rebuild it.
+---@return boolean started False if cache is already been built
 function FontCache:rebuild()
-  if self.building or self.searching_monospaced then
+  if self:is_building() then
     core.log_quiet("The font cache is already been generated, please wait.")
+    return false
   end
 
   local fontcache_file = USERDIR .. "/font_cache.lua"
@@ -95,7 +109,12 @@
     os.remove(fontcache_file)
   end
 
-  self:build()
+  self.fonts = {}
+  self.loaded_fonts = {}
+  self.found = 0
+  self.found_monospaced = 0
+
+  return self:build()
 end
 
 ---Scan a directory for valid font files and load them into the cache.
@@ -114,7 +133,8 @@
         local read, errmsg = self.fontinfo:read(font_path)
 
         if read then
-          local font_data, errmsg = self.fontinfo:get_data()
+          local font_data
+          font_data, errmsg = self.fontinfo:get_data()
           if font_data then
             table.insert(self.fonts, font_data)
             self.found = self.found + 1
@@ -143,7 +163,7 @@
 
 ---Search and mark monospaced fonts on currently loaded cache and save it.
 function FontCache:verify_monospaced()
-  if self.building or self.searching_monospaced then
+  if self:is_building() then
     core.log_quiet("The monospaced verification is already running, please 
wait.")
     return
   end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lite-xl-widgets-git20221023.648c067/fonts/info.lua 
new/lite-xl-widgets-git20221227.a632bfd/fonts/info.lua
--- old/lite-xl-widgets-git20221023.648c067/fonts/info.lua      2022-10-23 
06:34:26.000000000 +0200
+++ new/lite-xl-widgets-git20221227.a632bfd/fonts/info.lua      2022-12-27 
16:34:54.000000000 +0100
@@ -31,6 +31,8 @@
 ---@field public license string
 ---@field public tfamily string
 ---@field public tsubfamily '"Regular"' | '"Bold"' | '"Italic"' | '"Bold 
Italic"'
+---@field public wwsfamily string
+---@field public wwssubfamily string
 ---@field public monospace boolean
 
 ---@class widget.fonts.info : core.object
@@ -76,7 +78,7 @@
 function FontCDATA:unum(b)
   local v, data = 0, self.data
   assert(#data >= self.position + b, 11)
-  for i = 1, b do
+  for _ = 1, b do
     self.position = self.position + 1
     v = v * 256 + data:byte(self.position)
   end
@@ -156,7 +158,8 @@
 
 ---@param offset integer
 ---@param len integer
----@return widget.fonts.cdata
+---@return widget.fonts.cdata?
+---@return string|nil errmsg
 function FontReader:cdata(offset, len)
   local data, errmsg = self:read(offset, len)
   if data then
@@ -246,7 +249,7 @@
   if not cd_d then
     return nil, "error reading names table"
   end
-  for i = 1, ntbl do
+  for _ = 1, ntbl do
     local t = {-- tag, csum, ofs, len
       cd_d:str(4), cd_d:ulong(), cd_d:ulong(), cd_d:ulong()
     }
@@ -376,6 +379,7 @@
   ---@type string?
   local errmsg
 
+  ---@diagnostic disable-next-line
   font, errmsg = renderer.font.get_metadata(font_path)
 
   if not font then
@@ -479,13 +483,14 @@
 ---Open a font file and read its metadata.
 ---@param font_path string
 ---@return widget.fonts.info?
----@return string errmsg
+---@return string|nil errmsg
 function FontInfo:read(font_path)
   self.data = {}
   self.path = font_path
 
   local read, errmsg
 
+  ---@diagnostic disable-next-line
   if type(renderer.font.get_metadata) == "function" then
     read, errmsg = fontinfo_read_native(self, font_path)
   else
@@ -509,7 +514,7 @@
 ---copyright and license information which can be long.
 ---@param idx? integer Optional position of the embedded font
 ---@return widget.fonts.data?
----@return string errmsg
+---@return string|nil errmsg
 function FontInfo:get_data(idx)
   idx = idx or 1
   local data = {}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lite-xl-widgets-git20221023.648c067/fonts/init.lua 
new/lite-xl-widgets-git20221227.a632bfd/fonts/init.lua
--- old/lite-xl-widgets-git20221023.648c067/fonts/init.lua      2022-10-23 
06:34:26.000000000 +0200
+++ new/lite-xl-widgets-git20221227.a632bfd/fonts/init.lua      2022-12-27 
16:34:54.000000000 +0100
@@ -7,10 +7,10 @@
 ---@class widget.fonts
 local Fonts = {}
 
----@type widget.fonts.cache
+---@type widget.fonts.cache | nil
 local fontcache = nil
 
----@type table<integer, string>
+---@type table<integer, string> | nil
 local fonts = nil
 
 ---Last time the status view item was rendered
@@ -25,11 +25,13 @@
 ---Generate the list of fonts displayed on the CommandView.
 ---@param monospaced? boolean Only display fonts detected as monospaced.
 local function generate_fonts(monospaced)
-  if fontcache.building then monospaced = false end
-  fonts = {}
-  for idx, f in ipairs(fontcache.fonts) do
-    if not monospaced or (monospaced and f.monospace) then
-      table.insert(fonts, f.fullname .. "||" .. idx)
+  if fontcache then
+    if fontcache.building then monospaced = false end
+    fonts = {}
+    for idx, f in ipairs(fontcache.fonts) do
+      if not monospaced or (monospaced and f.monospace) then
+        table.insert(fonts, f.fullname .. "||" .. idx)
+      end
     end
   end
 end
@@ -82,7 +84,7 @@
 
 ---Launch the commandview and let the user select a font.
 ---@param callback fun(name:string, path:string)
----@param monospaced? boolean
+---@param monospaced boolean
 function Fonts.show_picker(callback, monospaced)
   if not fontcache then fontcache = FontCache() end
 
@@ -163,10 +165,18 @@
   })
 end
 
+---Check if the font cache is been built.
+---@return boolean building
+function Fonts.cache_is_building()
+  if not fontcache then return false end
+  return fontcache:is_building()
+end
+
 ---Remove current fonts cache file and regenerates a fresh one.
+---@return boolean started False if cache is already been built
 function Fonts.clean_cache()
   if not fontcache then fontcache = FontCache() end
-  fontcache:rebuild()
+  return fontcache:rebuild()
 end
 
 core.status_view:add_item({
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lite-xl-widgets-git20221023.648c067/init.lua 
new/lite-xl-widgets-git20221227.a632bfd/init.lua
--- old/lite-xl-widgets-git20221023.648c067/init.lua    2022-10-23 
06:34:26.000000000 +0200
+++ new/lite-xl-widgets-git20221227.a632bfd/init.lua    2022-12-27 
16:34:54.000000000 +0100
@@ -10,12 +10,12 @@
 local keymap = require "core.keymap"
 local View = require "core.view"
 local RootView = require "core.rootview"
+local ScrollBar = require "widget.scrollbar"
 
 ---Represents the border of a widget.
 ---@class widget.border
 ---@field public width number
 ---@field public color renderer.color | nil
-local WidgetBorder = {}
 
 ---Represents the position of a widget.
 ---@class widget.position
@@ -25,19 +25,32 @@
 ---@field public ry number Relative Y
 ---@field public dx number Dragging initial x position
 ---@field public dy number Dragging initial y position
-local WidgetPosition = {}
+
+---@class widget.animation.options
+---Prevents duplicated animations from getting added.
+---@field name? string
+---Speed of the animation, defaults to 0.5
+---@field rate? number
+---Called each time the value of a property changes.
+---@field on_step? fun(target:table, property:string, value:number)
+---Called when the animation finishes.
+---@field on_complete? fun(widget:widget)
+
+---@class widget.animation
+---@field target table
+---@field properties table<string,number>
+---@field options? widget.animation.options
 
 ---Represents a reference to a font stored elsewhere.
 ---@class widget.fontreference
 ---@field public container table<string, renderer.font>
 ---@field public name string
-local WidgetFontReference = {}
 
 ---@alias widget.font widget.fontreference | renderer.font | string
 
 ---@alias widget.clicktype
----|>'"left"'
----| '"right"'
+---| "left"
+---| "right"
 
 ---@alias widget.styledtext table<integer, 
renderer.font|widget.fontreference|renderer.color|integer|string>
 
@@ -47,6 +60,7 @@
 ---@field public parent widget | nil
 ---@field public name string
 ---@field public position widget.position
+---Modifying this property directly is not advised, use set_size() instead.
 ---@field public size widget.position
 ---@field public childs table<integer,widget>
 ---@field public child_active widget | nil
@@ -54,26 +68,27 @@
 ---@field public border widget.border
 ---@field public clickable boolean
 ---@field public draggable boolean
----@fie;d public scrollable boolean
+---@field public scrollable boolean
 ---@field public font widget.font
 ---@field public foreground_color renderer.color
 ---@field public background_color renderer.color
 ---@field public render_background boolean
 ---@field public type_name string
----@field private visible boolean
----@field private has_focus boolean
----@field private dragged boolean
----@field private tooltip string
----@field private label string
----@field private input_text boolean
----@field private textview widget
----@field private next_zindex integer
----@field private mouse widget.position
----@field private prev_size widget.position
----@field private mouse_is_pressed boolean
----@field private mouse_is_hovering boolean
----@field private mouse_pressed_outside boolean
----@field private is_scrolling boolean
+---@field protected visible boolean
+---@field protected has_focus boolean
+---@field protected dragged boolean
+---@field protected tooltip string
+---@field protected label string | widget.styledtext
+---@field protected input_text boolean
+---@field protected textview widget
+---@field protected next_zindex integer
+---@field protected mouse widget.position
+---@field protected prev_size widget.position
+---@field protected mouse_is_pressed boolean
+---@field protected mouse_is_hovering boolean
+---@field protected mouse_pressed_outside boolean
+---@field protected is_scrolling boolean
+---@field protected animations widget.animation[]
 local Widget = View:extend()
 
 ---Indicates on a widget.styledtext that a new line follows.
@@ -95,6 +110,9 @@
 function Widget:new(parent, floating)
   Widget.super.new(self)
 
+  self.v_scrollbar = ScrollBar(self, {direction = "v", alignment = "e"})
+  self.h_scrollbar = ScrollBar(self, {direction = "h", alignment = "e"})
+
   self.type_name = "widget"
   self.parent = parent
   self.name = "---" -- defaults to the application name
@@ -134,6 +152,8 @@
   -- used to allow proper node resizing
   self.mouse_pressed_outside = false
 
+  self.animations = {}
+
   if parent then
     parent:add_child(self)
   elseif self.defer_draw then
@@ -185,6 +205,44 @@
     self.prev_size.y = 0
   end
   self.visible = true
+  -- re-triggers update to make sure everything was properly calculated
+  -- and redraw the interface once, maybe something else can be changed
+  -- to not require this action, but for now lets do this.
+  core.add_thread(function()
+    self:update()
+    core.redraw = true
+  end)
+end
+
+---Perform an animated show.
+---@param lock_x? boolean Do not resize width while animating
+---@param lock_y? boolean Do not resize height while animating
+---@param options? widget.animation.options
+function Widget:show_animated(lock_x, lock_y, options)
+  if not self.parent then
+    if self.size.x <= 0 or self.size.y <= 0 then
+      self.size.x = self.prev_size.x
+      self.size.y = self.prev_size.y
+    end
+    self.prev_size.x = 0
+    self.prev_size.y = 0
+  end
+
+  local target_x, target_y = math.floor(self.size.x), math.floor(self.size.y)
+  self.size.x = lock_x and target_x or 0
+  self.size.y = lock_y and target_y or 0
+  local properties = {}
+  if not lock_x then properties["x"] = target_x end
+  if not lock_y then properties["y"] = target_y end
+  options = options or {}
+  self:animate(self.size, properties, {
+    name = options.name or "show_animated",
+    rate = options.rate,
+    on_step = options.on_step,
+    on_complete = options.on_complete
+  })
+
+  self.visible = true
 end
 
 ---Hide the widget.
@@ -206,6 +264,32 @@
   end
 end
 
+---Perform an animated hide.
+---@param lock_x? boolean Do not resize width while animating
+---@param lock_y? boolean Do not resize height while animating
+---@param options? widget.animation.options
+function Widget:hide_animated(lock_x, lock_y, options)
+  local x, y = self.size.x, self.size.y
+  local target_x = lock_x and self.size.x or 0
+  local target_y = lock_y and self.size.y or 0
+  local properties = {}
+  if not lock_x then properties["x"] = target_x end
+  if not lock_y then properties["y"] = target_y end
+  options = options or {}
+  self:animate(self.size, properties, {
+    name = options.name or "hide_animated",
+    rate = options.rate,
+    on_step = options.on_step,
+    on_complete = function()
+      self.size.x, self.size.y = x, y
+      self:hide()
+      if options.on_complete then
+        options.on_complete(self)
+      end
+    end
+  })
+end
+
 ---When set to false the background rendering is disabled.
 ---@param enable? boolean | nil
 function Widget:toggle_background(enable)
@@ -217,11 +301,23 @@
 end
 
 ---Toggle visibility of widget.
-function Widget:toggle_visible()
+---@param animated? boolean
+---@param lock_x? boolean
+---@param lock_y? boolean
+---@param options? widget.animation.options
+function Widget:toggle_visible(animated, lock_x, lock_y, options)
   if not self.visible then
-    self:show()
+    if not animated then
+      self:show()
+    else
+      self:show_animated(lock_x, lock_y, options)
+    end
   else
-    self:hide()
+    if not animated then
+      self:hide()
+    else
+      self:hide_animated(lock_x, lock_y, options)
+    end
   end
 end
 
@@ -376,7 +472,11 @@
   if not self.visible then
     return false
   end
-  self.size[axis] = value
+  if axis == "x" then
+    self:set_size(value)
+  else
+    self:set_size(nil, value)
+  end
   return true
 end
 
@@ -580,7 +680,7 @@
 end
 
 ---A text label for the widget, not all widgets support this.
----@param text string
+---@param text string | widget.styledtext
 function Widget:set_label(text)
   self.label = text
 end
@@ -615,6 +715,8 @@
     return
   end
 
+  if child and child == self.child_active then return end
+
   local active_child = self.child_active
 
   if self.child_active then
@@ -1014,6 +1116,100 @@
   end
 end
 
+---Registers a new animation to be ran on the update cycle.
+---@param target? table If nil assumes properties belong to widget it self.
+---@param properties table<string,number>
+---@param options? widget.animation.options
+function Widget:animate(target, properties, options)
+  if not target then target = self end
+
+  -- if name is set then prevent adding if another one with the same
+  -- animation name is already running
+  if options and options.name then
+    for _, animation in ipairs(self.animations) do
+      if animation.options and animation.options.name == options.name then
+        return
+      end
+    end
+  end
+
+  table.insert(self.animations, {
+    target = target,
+    properties = properties,
+    options = options
+  })
+end
+
+---Runs all registered animations removing duplicated and finished ones.
+function Widget:run_animations()
+  if #self.animations > 0 then
+    ---@type table<widget.animation, widget.animation>
+    local duplicates = {}
+
+    local targets = {}
+    local deleted = 0
+    for i=1, #self.animations do
+      local animation = self.animations[i - deleted]
+
+      -- do not run animations that change same target to prevent conflicts.
+      if not targets[animation.target] then
+        local finished = true
+        local options = animation.options or {}
+        for name, value in pairs(animation.properties) do
+          if animation.target[name] ~= value then
+            self:move_towards(animation.target, name, value, options.rate)
+            if options.on_step then
+              options.on_step(animation.target, name, animation.target[name])
+            end
+            if animation.target[name] ~= value then
+              finished = false
+            end
+          end
+        end
+        if finished then
+          if options.on_complete then
+            options.on_complete(self)
+          end
+          table.remove(self.animations, i - deleted)
+          deleted = deleted + 1
+        end
+        targets[animation.target] = animation
+      -- only registers it as duplicated if the animation does needs to
+      -- perform any tasks on completion.
+      elseif not targets[animation.target].on_complete then
+        duplicates[targets[animation.target]] = animation
+      end
+    end
+
+    -- remove older duplcated animations that modify same target and properties
+    for duplicate, newer_animation in pairs(duplicates) do
+      local exact_properties = true
+      for name, _ in pairs(duplicate.properties) do
+        if not newer_animation.properties[name] then
+          exact_properties = false
+          break
+        end
+      end
+      if exact_properties then
+        for name, _ in pairs(newer_animation.properties) do
+          if not duplicate.properties[name] then
+            exact_properties = false
+            break
+          end
+        end
+      end
+      if exact_properties then
+        for i, animation in ipairs(self.animations) do
+          if animation == duplicate then
+            table.remove(self.animations, i)
+            break
+          end
+        end
+      end
+    end
+  end
+end
+
 ---If visible execute the widget calculations and returns true.
 ---@return boolean
 function Widget:update()
@@ -1024,6 +1220,9 @@
   -- call this to be able to properly scroll
   self:update_position()
 
+  -- run any pending animations
+  self:run_animations()
+
   for _, child in pairs(self.childs) do
     child:update()
   end
@@ -1124,17 +1323,19 @@
     local pressed = false
     for i=#floating_widgets, 1, -1 do
       local widget = floating_widgets[i]
-      widget.mouse_pressed_outside = not widget:mouse_on_top(x, y)
-      if
-        (not widget.defer_draw and not widget.child_active)
-        or
-        widget.mouse_pressed_outside
-        or
-        (pressed or not widget:on_mouse_pressed(button, x, y, clicks))
-      then
-        widget:swap_active_child()
-      else
-        pressed = true
+      if widget.visible then
+        widget.mouse_pressed_outside = not widget:mouse_on_top(x, y)
+        if
+          (not widget.defer_draw and not widget.child_active)
+          or
+          widget.mouse_pressed_outside
+          or
+          (pressed or not widget:on_mouse_pressed(button, x, y, clicks))
+        then
+          widget:swap_active_child()
+        else
+          pressed = true
+        end
       end
     end
     if not pressed then
@@ -1148,16 +1349,18 @@
     local released = false
     for i=#floating_widgets, 1, -1 do
       local widget = floating_widgets[i]
-      if
-        (not widget.defer_draw and not widget.child_active)
-        or
-        widget.mouse_pressed_outside
-        or
-        not widget:on_mouse_released(button, x, y)
-      then
-        widget.mouse_pressed_outside = false
-      else
-        released = true
+      if widget.visible then
+        if
+          (not widget.defer_draw and not widget.child_active)
+          or
+          widget.mouse_pressed_outside
+          or
+          not widget:on_mouse_released(button, x, y)
+        then
+          widget.mouse_pressed_outside = false
+        else
+          released = true
+        end
       end
     end
     if not released then
@@ -1170,30 +1373,32 @@
     if core.active_view ~= core.command_view then
       for i=#floating_widgets, 1, -1 do
         local widget = floating_widgets[i]
-        if
-          (not widget.defer_draw and not widget.child_active)
-          or
-          widget.mouse_pressed_outside
-          or
-          (moved or not widget:on_mouse_moved(x, y, dx, dy))
-        then
-            if
-              not widget.is_scrolling
-              and
-              not widget.child_active
-              and
-              widget.outside_view
-            then
-              core.set_active_view(widget.outside_view)
-              widget.outside_view = nil
+        if widget.visible then
+          if
+            (not widget.defer_draw and not widget.child_active)
+            or
+            widget.mouse_pressed_outside
+            or
+            (moved or not widget:on_mouse_moved(x, y, dx, dy))
+          then
+              if
+                not widget.is_scrolling
+                and
+                not widget.child_active
+                and
+                widget.outside_view
+              then
+                core.set_active_view(widget.outside_view)
+                widget.outside_view = nil
+              end
+          elseif not moved then
+            if not widget.child_active and widget.defer_draw then
+              if not widget.outside_view then
+                widget.outside_view = core.active_view
+              end
+              core.set_active_view(widget)
+              moved = true
             end
-        elseif not moved then
-          if not widget.child_active and widget.defer_draw then
-            if not widget.outside_view then
-              widget.outside_view = core.active_view
-            end
-            core.set_active_view(widget)
-            moved = true
           end
         end
       end
@@ -1206,7 +1411,9 @@
   function RootView:on_mouse_wheel(y, x)
     for i=#floating_widgets, 1, -1 do
       local widget = floating_widgets[i]
-      if widget.defer_draw and widget:on_mouse_wheel(y, x) then
+      if
+        widget.visible and widget.defer_draw and widget:on_mouse_wheel(y, x)
+      then
         return true
       end
     end
@@ -1216,7 +1423,11 @@
   function RootView:on_file_dropped(filename, x, y)
     for i=#floating_widgets, 1, -1 do
       local widget = floating_widgets[i]
-      if widget.defer_draw and widget:on_file_dropped(filename, x, y) then
+      if
+        widget.visible and widget.defer_draw
+        and
+        widget:on_file_dropped(filename, x, y)
+      then
         return true
       end
     end
@@ -1226,7 +1437,9 @@
   function RootView:on_text_input(text)
     for i=#floating_widgets, 1, -1 do
       local widget = floating_widgets[i]
-      if widget.defer_draw and widget:on_text_input(text) then
+      if
+        widget.visible and widget.defer_draw and widget:on_text_input(text)
+      then
         return true
       end
     end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lite-xl-widgets-git20221023.648c067/inputdialog.lua 
new/lite-xl-widgets-git20221227.a632bfd/inputdialog.lua
--- old/lite-xl-widgets-git20221023.648c067/inputdialog.lua     2022-10-23 
06:34:26.000000000 +0200
+++ new/lite-xl-widgets-git20221227.a632bfd/inputdialog.lua     2022-12-27 
16:34:54.000000000 +0100
@@ -11,6 +11,7 @@
 local TextBox = require "widget.textbox"
 
 ---@class widget.inputdialog : widget.dialog
+---@field super widget.dialog
 ---@field message widget.label
 ---@field text widget.textbox
 ---@field save widget.button
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lite-xl-widgets-git20221023.648c067/keybinddialog.lua 
new/lite-xl-widgets-git20221227.a632bfd/keybinddialog.lua
--- old/lite-xl-widgets-git20221023.648c067/keybinddialog.lua   2022-10-23 
06:34:26.000000000 +0200
+++ new/lite-xl-widgets-git20221227.a632bfd/keybinddialog.lua   2022-12-27 
16:34:54.000000000 +0100
@@ -17,6 +17,7 @@
 local current_dialog = nil
 
 ---@class widget.keybinddialog : widget.dialog
+---@field super widget.dialog
 ---@field selected integer
 ---@field shortcuts widget.listbox
 ---@field add widget.button
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lite-xl-widgets-git20221023.648c067/listbox.lua 
new/lite-xl-widgets-git20221227.a632bfd/listbox.lua
--- old/lite-xl-widgets-git20221023.648c067/listbox.lua 2022-10-23 
06:34:26.000000000 +0200
+++ new/lite-xl-widgets-git20221227.a632bfd/listbox.lua 2022-12-27 
16:34:54.000000000 +0100
@@ -22,7 +22,7 @@
 ---@alias widget.listbox.colpos table<integer,integer>
 
 ---@class widget.listbox : widget
----@field private rows widget.listbox.row[]
+---@field rows widget.listbox.row[]
 ---@field private row_data any
 ---@field private columns widget.listbox.column[]
 ---@field private positions widget.listbox.colpos[]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lite-xl-widgets-git20221023.648c067/messagebox.lua 
new/lite-xl-widgets-git20221227.a632bfd/messagebox.lua
--- old/lite-xl-widgets-git20221023.648c067/messagebox.lua      2022-10-23 
06:34:26.000000000 +0200
+++ new/lite-xl-widgets-git20221227.a632bfd/messagebox.lua      2022-12-27 
16:34:54.000000000 +0100
@@ -25,9 +25,9 @@
 MessageBox.ICON_WARNING = "!"
 
 ---@alias widget.messagebox.icontype
----|>"MessageBox.ICON_ERROR"
----| "MessageBox.ICON_INFO"
----| "MessageBox.ICON_WARNING"
+---|>`MessageBox.ICON_ERROR`
+---| `MessageBox.ICON_INFO`
+---| `MessageBox.ICON_WARNING`
 
 MessageBox.BUTTONS_OK = 1
 MessageBox.BUTTONS_OK_CANCEL = 2
@@ -35,17 +35,17 @@
 MessageBox.BUTTONS_YES_NO_CANCEL = 4
 
 ---@alias widget.messagebox.buttonstype
----|>"MessageBox.BUTTONS_OK"
----| "MessageBox.BUTTONS_OK_CANCEL"
----| "MessageBox.BUTTONS_YES_NO"
----| "MessageBox.BUTTONS_YES_NO_CANCEL"
+---|>`MessageBox.BUTTONS_OK`
+---| `MessageBox.BUTTONS_OK_CANCEL`
+---| `MessageBox.BUTTONS_YES_NO`
+---| `MessageBox.BUTTONS_YES_NO_CANCEL`
 
----@alias widget.messagebox.onclosehandler fun(self: widget.messagebox, 
button_id: integer, button: widget.button):void
+---@alias widget.messagebox.onclosehandler fun(self: widget.messagebox, 
button_id: integer, button: widget.button)
 
 ---Constructor
 ---@param parent widget
 ---@param title string
----@param message string
+---@param message string | widget.styledtext
 ---@param icon widget.messagebox.icontype
 ---@param icon_color renderer.color
 function MessageBox:new(parent, title, message, icon, icon_color)
@@ -65,14 +65,14 @@
 end
 
 ---Change the message box title.
----@param text string|widget.styledtext
+---@param text string | widget.styledtext
 function MessageBox:set_title(text)
   self.title:set_label(text)
 end
 
 ---Change the message box icon.
 ---@param icon widget.messagebox.icontype
----@param icon_color renderer.color
+---@param color? renderer.color
 function MessageBox:set_icon(icon, color)
   if not color then
     color = style.text
@@ -86,7 +86,7 @@
 end
 
 ---Change the message box message.
----@param text string|widget.styledtext
+---@param text string | widget.styledtext
 function MessageBox:set_message(text)
   self.message:set_label(text)
 end
@@ -104,8 +104,8 @@
   local button_id = #self.buttons
   local new_button = self.buttons[button_id]
   local on_click = new_button.on_click
-  new_button.on_click = function(this)
-    on_click(this)
+  new_button.on_click = function(this, ...)
+    on_click(this, ...)
     self:on_close(button_id, new_button)
   end
 end
@@ -165,9 +165,8 @@
 ---Called when the user clicks one of the buttons in the message box.
 ---@param button_id integer
 ---@param button widget.button
-function MessageBox:on_close(button_id, button)
-  self:hide()
-end
+---@diagnostic disable-next-line
+function MessageBox:on_close(button_id, button) self:hide() end
 
 function MessageBox:update()
   if not MessageBox.super.update(self) then return false end
@@ -277,12 +276,12 @@
 end
 
 ---Wrapper to easily show a message box.
----@param title string
----@param message string
+---@param title string | widget.styledtext
+---@param message string | widget.styledtext
 ---@param icon widget.messagebox.icontype
----@param icon_color renderer.color
----@param on_close widget.messagebox.onclosehandler
----@param buttons widget.messagebox.buttonstype
+---@param icon_color? renderer.color
+---@param on_close? widget.messagebox.onclosehandler
+---@param buttons? widget.messagebox.buttonstype
 function MessageBox.alert(title, message, icon, icon_color, on_close, buttons)
   buttons = buttons or MessageBox.BUTTONS_OK
   ---@type widget.messagebox
@@ -313,8 +312,8 @@
 end
 
 ---Wrapper to easily show a info message box.
----@param title string
----@param message string
+---@param title string | widget.styledtext
+---@param message string | widget.styledtext
 ---@param on_close? widget.messagebox.onclosehandler
 ---@param buttons? widget.messagebox.buttonstype
 function MessageBox.info(title, message, on_close, buttons)
@@ -322,8 +321,8 @@
 end
 
 ---Wrapper to easily show a warning message box.
----@param title string
----@param message string
+---@param title string | widget.styledtext
+---@param message string | widget.styledtext
 ---@param on_close? widget.messagebox.onclosehandler
 ---@param buttons? widget.messagebox.buttonstype
 function MessageBox.warning(title, message, on_close, buttons)
@@ -331,8 +330,8 @@
 end
 
 ---Wrapper to easily show an error message box.
----@param title string
----@param message string
+---@param title string | widget.styledtext
+---@param message string | widget.styledtext
 ---@param on_close? widget.messagebox.onclosehandler
 ---@param buttons? widget.messagebox.buttonstype
 function MessageBox.error(title, message, on_close, buttons)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lite-xl-widgets-git20221023.648c067/notebook.lua 
new/lite-xl-widgets-git20221227.a632bfd/notebook.lua
--- old/lite-xl-widgets-git20221023.648c067/notebook.lua        2022-10-23 
06:34:26.000000000 +0200
+++ new/lite-xl-widgets-git20221227.a632bfd/notebook.lua        2022-12-27 
16:34:54.000000000 +0100
@@ -34,6 +34,7 @@
 
 ---Called when a tab is clicked.
 ---@param pane widget.notebook.pane
+---@diagnostic disable-next-line
 function NoteBook:on_tab_click(pane) end
 
 ---Adds a new pane to the notebook and returns a container widget where
@@ -82,7 +83,7 @@
 ---@param name string
 ---@return widget.notebook.pane | nil
 function NoteBook:get_pane(name)
-  for pos, pane in pairs(self.panes) do
+  for _, pane in pairs(self.panes) do
     if pane.name == name then
       return pane
     end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lite-xl-widgets-git20221023.648c067/scrollbar.lua 
new/lite-xl-widgets-git20221227.a632bfd/scrollbar.lua
--- old/lite-xl-widgets-git20221023.648c067/scrollbar.lua       1970-01-01 
01:00:00.000000000 +0100
+++ new/lite-xl-widgets-git20221227.a632bfd/scrollbar.lua       2022-12-27 
16:34:54.000000000 +0100
@@ -0,0 +1,32 @@
+--
+-- Extends core.scrollbar to allow propagating force status to child elements.
+--
+
+---@type core.scrollbar
+local CoreScrollBar = require "core.scrollbar"
+
+---@class widget.scrollbar : core.scrollbar
+---@field super widget.scrollbar
+---@field widget_parent widget
+local ScrollBar = CoreScrollBar:extend()
+
+function ScrollBar:new(parent, options)
+  self.widget_parent = parent
+  ScrollBar.super.new(self, options)
+end
+
+function ScrollBar:set_forced_status(status)
+  ScrollBar.super.set_forced_status(self, status)
+  if self.widget_parent and self.widget_parent.childs then
+    for _, child in pairs(self.widget_parent.childs) do
+      if self.direction == "v" then
+        child.v_scrollbar:set_forced_status(status)
+      else
+        child.h_scrollbar:set_forced_status(status)
+      end
+    end
+  end
+end
+
+
+return ScrollBar
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lite-xl-widgets-git20221023.648c067/selectbox.lua 
new/lite-xl-widgets-git20221227.a632bfd/selectbox.lua
--- old/lite-xl-widgets-git20221023.648c067/selectbox.lua       2022-10-23 
06:34:26.000000000 +0200
+++ new/lite-xl-widgets-git20221227.a632bfd/selectbox.lua       2022-12-27 
16:34:54.000000000 +0100
@@ -42,7 +42,7 @@
       self:on_selected(idx-1, data)
       self:on_change(self.selected)
     end
-    self.list_container:hide()
+    self.list_container:hide_animated(true)
   end
 
   self:set_label(label or "select")
@@ -176,6 +176,7 @@
 ---Overwrite to listen to on_selected events.
 ---@param item_idx integer
 ---@param item_data widget.listbox.row
+---@diagnostic disable-next-line
 function SelectBox:on_selected(item_idx, item_data) end
 
 function SelectBox:on_mouse_enter(...)
@@ -196,7 +197,7 @@
 
     self.list_container.border.color = style.caret
 
-    self.list_container:toggle_visible()
+    self.list_container:toggle_visible(true, true)
 
     self.list:resize_to_parent()
   end
@@ -266,4 +267,3 @@
 
 
 return SelectBox
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lite-xl-widgets-git20221023.648c067/textbox.lua 
new/lite-xl-widgets-git20221227.a632bfd/textbox.lua
--- old/lite-xl-widgets-git20221023.648c067/textbox.lua 2022-10-23 
06:34:26.000000000 +0200
+++ new/lite-xl-widgets-git20221227.a632bfd/textbox.lua 2022-12-27 
16:34:54.000000000 +0100
@@ -259,6 +259,7 @@
 ---  line, col, text, undo_stack, time
 ---remove arguments (see Doc:raw_remove):
 ---  line1, col1, line2, col2, undo_stack, time
+---@diagnostic disable-next-line
 function TextBox:on_text_change(action, ...) end
 
 function TextBox:update()

++++++ lite-xl-widgets.obsinfo ++++++
--- /var/tmp/diff_new_pack.2oxu99/_old  2023-01-07 17:23:08.763384322 +0100
+++ /var/tmp/diff_new_pack.2oxu99/_new  2023-01-07 17:23:08.767384346 +0100
@@ -1,5 +1,5 @@
 name: lite-xl-widgets
-version: git20221023.648c067
-mtime: 1666499666
-commit: 648c06723180c90194cba39c51e21bc05a707b2b
+version: git20221227.a632bfd
+mtime: 1672155294
+commit: a632bfdf7c66bacc272fe2c962621cd9860058e1
 

Reply via email to