Skip to content

Commit

Permalink
Generate build for 1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jtackaberry committed Oct 9, 2023
1 parent c0407a1 commit 78cbffe
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 85 deletions.
75 changes: 9 additions & 66 deletions 1/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,18 @@
# 1.3.0 - 2022-11-20

## New Features

* Added a new experimental `xml` module, which can be used to parse a subset of XML. The API is in preview and is not considered stable. Feedback appreciated.
* `rtk.Slider`'s API has been promoted to stable (however vertical orientiation is not yet implemented)
* Added a new mode `auto` for `rtk.Viewport.vscrollbar` that will reserve space for the scrollbar if scrolling is required to see all content
* `rtk.Window` now supports relative values (i.e. between 0 and 1.0 inclusive) for `minw`, `minh`, `maxw`, and `maxh` attributes
* Implemented customizable widget "hot zones" controlled via the `rtk.Widget.hotzone` attribute, which allows adjusting the area around the widget's normal boundary where mouse interactions will register. This can be useful to allow a widget to be clickable even if the user inadvertently clicks within the margin or spacing in a box, for example, which in particular can improve UX on touch screens

# 1.4.0 - 2023-10-09

## Minor Enhancements

* Containers now receive `onkeypress` events when any descendant of the container is focused
* When `rtk.Viewport.vscrollbar` is set to `hover` (default) the scrollbar now becomes visible when the mouse enters anywhere within the viewport, rather than only when near the scrollbar gutter
* Improved `rtk.Window` autosizing (i.e. when width or height is not set) when the window contains "greedy" widgets that want to fill their parent containers as much as possible
* `rtk.Window:open()` now defaults to center alignment
* `rtk.Widget.onclick`, `rtk.Widget.ondoubleclick`, and `rtk.Widget.onlongpress` no longer require `rtk.Widget.autofocus` to be explicitly set or have a custom `rtk.Widget.onmousedown` handler to fire. They will be invoked on all widgets unless `rtk.Widget.onmousedown` explicitly returns false to disable this behavior
* `rtk.Widget.autofocus` now defaults to true if an `onclick` is set on the widget, but it can be explicitly set to `false` to never autofocus
* Allow newlines in `rtk.Application.status` text
* Expand the number of scenarios in which a full reflow is avoided when setting `rtk.Text.text`
* Icons created by `rtk.Image.icon()` are no longer automatically recolored when the image is found in an image path that was registered without an explicit icon style
* Allow passing the file extension to `rtk.Image.icon()`
* Added `rtk.Popup.onopen` and `rtk.Popup.onclose` event handlers
* Enhanced `rtk.Popup.autoclose` to be able to distinguish between clicks that occur outside the popup but still within the ReaScript window, or outside the window entirely
* Allow `rtk.Popup.overlay` to be themed
* Added support for alpha channels in named colors in the form `colorname#aa` where `colorname` is the name of the color and `aa` is the hex code of the alpha channel. For example, `bg='chartreuse#7f'`
* Implemented luma-adaptive color for `rtk.Text.color` which is now default. Unless the attribute is explicitly set, the text color will use `rtk.themes.text` from either the dark theme or the light theme, depending on the luminance of the background the text will be rendered over
* Improved luminance detection for adaptive coloring (for example `rtk.Entry.icon`) to take into account parent's background when the widget has a translucent background such that it that would blend with the parent's background color
* Avoid recalculating layout (full reflow) if `rtk.Widget.bg` or `rtk.Widget.ghost` are set as these do not affect geometry
* Added a new field `rtk.tick` that increments with each gfx update cycle, and add `rtk.Event.tick` to reflect the tick at which the event occurred
* Improved handling of the case where a widget defines `minw`/`minh` but the minimum size would exceed the allowed cell size in a box
* Optimized overhead of instantiating new widgets
* Improved logic for generating debug box overlay colors when setting `rtk.debug` to true. Previously `math.random()` was used with a fixed seed, which significantly weakened random number generation for other uses.
* The `rtk.Window.onclose()` event handler is now invoked on all script exit conditions if the window is open
* Minor documentation improvements


## Bug Fixes

* Fixed a bug where key press events could be missed/dropped if there were other non-keyboard events (such as mouse move events) that occurred during the same gfx update cycle
* Properly respect the `maxw` cell attribute for expanded cells in `rtk.HBox`
* Fixed a bug where the first expanded cell in a box would have a different size than other expanded cells when `rtk.Box.spacing` was non-zero
* Fixed 1px tall scrollbar bug when `rtk.Viewport.vscrollbar` was set to `always`
* Ensure `rtk.ImageBox` borders and background color is drawn even if `rtk.ImageBox.image` is nil
* Respect `rtk.ImageBox.bg`, if set, when determining which luma-adaptive image variant to use
* Fixed animating `rtk.Widget.w` and `rtk.Widget.h` to 0, or to `rtk.Attribute.NIL` (nil was already supported)
* Fixed animating `rtk.Widget.bg` to nil
* Fixed animating `rtk.Window.x` and `rtk.Window.y` with undocked windows
* Apply `rtk.scale.value` to `rtk.Widget.minw`, `minh`, `maxw`, and `maxh` when `rtk.Widget.scalability` allows it
* Fixed centered vertical alignment for `rtk.Button` when the button label wraps
* Removed allowing passing `rtk.Window.title` as the first positional value during initialization. In principle this is a breaking change however it never actually worked properly, so this just removes a broken feature.
* Fixed a bug where `rtk.Window.onclose` could fire multiple times when the window closes
* Fixed flickering when resizing an `rtk.Window` when the border attribute was set
* Fixed autosizing of `rtk.Window` when REAPER's native UI scaling was enabled
* Fixed a minor visual flicker that could occur when setting certain `rtk.Window` attributes
* `rtk.Window` padding is now accounted for by the resize grip when `rtk.Window.borderless` is true
* Fixed a bug where `rtk.Button` would not always respect the parent container's bounding box
* Fixed subtle misalignment of button labels on Mac
* Fixed the `rtk.Popup.opened` attribute which wasn't being properly updated to reflect current state
* Fixed a bug that calculates the popup width when `rtk.Popup.anchor` is defined and `rtk.scale.value` is > 1
* Fixed a bug where popups with `rtk.Popup.autoclose` enabled could inadvertently close when `rtk.touchscroll` was enabled
* Fixed a visual flicker that occurred when fading out an `rtk.Popup` at the same time as its `rtk.Popup.anchor` widget is hidden
* Fixed issue where the blinking cursor of `rtk.Entry` could be drawn outside its box
* Still allow scrolling `rtk.Viewport` even when `rtk.Viewport.vscrollbar` is set to `never`
* Fixed scroll offsets when `rtk.Viewport` has non-zero padding
* Fixed a bug where `rtk.FlowBox` would only ever use a single column if it contained any greedy children (e.g. those using relative dimensions, or belonging to a box container with `expand` or `fillw` cell attributes set)
* Fixed an edge case where `rtk.FlowBox` could layout with zero columns
* Fixed `rtk.Spacer` failing to take into account padding when calculating its size
* Perform a redraw when the mouse cursor leaves the `rtk.Window` to ensure widget draw functions that reference `rtk.Window.in_window` reflect the proper state visually
* Fixed a bug where `rtk.Widget.cursor` was not being respected when long-pressing over a widget with `rtk.touchscroll` enabled
* `rtk.Widget.onclick` no longer fires if `rtk.Widget.onlongpress` fires and its handler returns true to mark the event as handled
* Fixed incorrect rendering of `rtk.Entry` background when its parent container's background changes
* The `targetidx` parameter for `rtk.Container:reorder()` previously required offseting the index by 1 of the target was after the widget's current cell position, which is now fixed. Technically this is a breaking API change, but the previous semantics were extremely counterintuitive and this API was not widely used by scripts so this is being slipped in as a bug fix.
* Fixed millisecond precision in `rtk.log` timestamps
* Fixed some janky behavior that could occur during mouse cursor position restoration when `rtk.touchscroll` is enabled
* Fixed a crash caused by setting `rtk.Window.w` or `rtk.Window.h` attributes to nil (which denotes autosizing) within an event handler ([#20](https://github.com/jtackaberry/rtk/issues/20))
* Fixed a crash when calling `rtk.Image:blur()` before the image has been loaded
* Fixed stack overflow caused by passing a recursive table (i.e. a table which contains either a direct or indirect value of itself) to `table.tostring()`
* Fixed `halign` / `valign` parameters for `rtk.Window:open()` sometimes not being respected
* Ensured `rtk.Entry.caret` reflects the correct position before firing `rtk.Entry.onchange` ([#19](https://github.com/jtackaberry/rtk/issues/19))


43 changes: 25 additions & 18 deletions 1/rtk.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- This is generated code. See https://reapertoolkit.dev/ for more info.
-- version: 1.3.0
-- build: Sun Nov 20 21:44:10 UTC 2022
__RTK_VERSION='1.3.0'
-- version: 1.4.0
-- build: Mon Oct 9 17:45:25 UTC 2023
__RTK_VERSION='1.4.0'
rtk=(function()
__mod_rtk_core=(function()
__mod_rtk_log=(function()
Expand Down Expand Up @@ -199,7 +199,7 @@ end
function rtk.pushdest(dest)rtk._dest_stack[#rtk._dest_stack+1]=gfx.dest
gfx.dest=dest
end
function rtk.popdest(expect)gfx.dest=table.remove(rtk._dest_stack,#rtk._dest_stack)end
function rtk.popdest()gfx.dest=table.remove(rtk._dest_stack,#rtk._dest_stack)end
local function _handle_error(err)rtk._last_error=err
rtk._last_traceback=debug.traceback()end
function rtk.onerror(err,traceback)log.error("fatal: %s\n%s", err, traceback)log.flush()error(err)end
Expand Down Expand Up @@ -578,21 +578,22 @@ _,idx=s:find(sub,idx+1)c=c+1
end
return c
end
local _table_tostring=nil
local function val_to_str(v,seen)if "string" == type(v) then
v=string.gsub(v, "\n", "\\n")if string.match(string.gsub(v,"[^'\"]",""), '^"+$') then
return "'" .. v .. "'"end
return '"' .. string.gsub(v, '"', '\\"') .. '"'else
if type(v)=='table' and not v.__tostring then
return seen[tostring(v)] and '<recursed>' or table.tostring(v, seen)else
return seen[tostring(v)] and '<recursed>' or _table_tostring(v, seen)else
return tostring(v)end
return "table" == type(v) and table.tostring(v, seen) or tostring(v)end
return "table" == type(v) and _table_tostring(v, seen) or tostring(v)end
end
local function key_to_str(k,seen)if "string" == type(k) and string.match(k, "^[_%a][_%a%d]*$") then
return k
else
return "[" .. val_to_str(k, seen) .. "]"end
end
local function _table_tostring(tbl,seen)local result,done={},{}seen=seen or {}local id=tostring(tbl)seen[id]=1
_table_tostring=function(tbl,seen)local result,done={},{}seen=seen or {}local id=tostring(tbl)seen[id]=1
for k,v in ipairs(tbl)do
table.insert(result,val_to_str(v,seen))done[k]=true
end
Expand Down Expand Up @@ -1360,7 +1361,7 @@ self.id=nil
end
end
function rtk.Image:pushdest()assert(self.id, 'create() or load() must be called first')rtk.pushdest(self.id)end
function rtk.Image:popdest()assert(gfx.dest==self.id, 'rtk.Image.popdest() called on image that is not the current drawing target')rtk.popdest(self.id)end
function rtk.Image:popdest()assert(gfx.dest==self.id, 'rtk.Image.popdest() called on image that is not the current drawing target')rtk.popdest()end
function rtk.Image:clone()local newimg=rtk.Image(self.w,self.h)if self.id then
newimg:blit{src=self,sx=self.x,sy=self.y}end
newimg.density=self.density
Expand Down Expand Up @@ -1439,6 +1440,7 @@ end
function rtk.Image:rect(color,x,y,w,h,fill)self:pushdest()rtk.color.set(color)gfx.rect(x,y,w,h,fill)self:popdest()return self
end
function rtk.Image:blur(strength,x,y,w,h)if not self.w then
return self
end
self:pushdest()gfx.mode=6
x=x or 0
Expand Down Expand Up @@ -1748,7 +1750,7 @@ rtk.gfx.roundrect(pad+i,pad+i,self.w+tl+tr-i*2,self.h+tt+tb-i*2,self.elevation,0
self._image:popdest()self._needs_draw=false
end
if tr>0 then
self._image:blit{sx=pad+tl+self.w,sw=tr+pad,sh=h,dx=x+self.w,dy=y-tt-pad,alpha=alpha
self._image:blit{sx=pad+tl+self.w,sw=tr+pad,sh=nil,dx=x+self.w,dy=y-tt-pad,alpha=alpha
}end
if tb>0 then
self._image:blit{sy=pad+tt+self.h,sw=self.w+tl+pad,sh=tb+pad,dx=x-tl-pad,dy=y+self.h,alpha=alpha
Expand Down Expand Up @@ -2025,9 +2027,12 @@ return rtk._refs[key]
end
end
function rtk.Widget:_get_debug_color()if not self.debug_color then
local function hashint(i,seed)math.randomseed(i*(seed*53))return math.random(40,235)/255.0
local x=self.id:hash()*100
x=x ~(x<<13)x=x ~(x>>7)x=x ~(x<<17)local color=table.pack(rtk.color.rgba(x%16777216))local luma=rtk.color.luma(color)if luma<0.2 then
color=table.pack(rtk.color.mod(color,1,1,2.5))elseif luma>0.8 then
color=table.pack(rtk.color.mod(color,1,1,0.75))end
self.debug_color=color
end
local id=self.id:hash()self.debug_color={hashint(id,1),hashint(id,2),hashint(id,3),}end
return self.debug_color
end
function rtk.Widget:_draw_debug_box(offx,offy,event)local calc=self.calc
Expand Down Expand Up @@ -3429,7 +3434,7 @@ end
end
icon:popdest()rtk.Window.static._icon_resize_grip=icon
end
rtk.Window.register{x=rtk.Attribute{type='number',default=rtk.Attribute.NIL,reflow=rtk.Widget.REFLOW_NONE,redraw=false,window_sync=true,},y=rtk.Attribute{type='number',default=rtk.Attribute.NIL,reflow=rtk.Widget.REFLOW_NONE,redraw=false,window_sync=true,},w=rtk.Attribute{priority=true,type='number',window_sync=true,reflow_uses_exterior_value=true,animate=function(self,anim)return rtk.Widget.attributes.w.animate(self,anim,rtk.scale.framebuffer)end,calculate=function(self,attr,value,target)return value and value*rtk.scale.framebuffer
rtk.Window.register{x=rtk.Attribute{type='number',default=rtk.Attribute.NIL,reflow=rtk.Widget.REFLOW_NONE,redraw=false,window_sync=true,},y=rtk.Attribute{type='number',default=rtk.Attribute.NIL,reflow=rtk.Widget.REFLOW_NONE,redraw=false,window_sync=true,},w=rtk.Attribute{priority=true,type='number',window_sync=true,reflow_uses_exterior_value=true,animate=function(self,anim)return rtk.Widget.attributes.w.animate(self,anim,rtk.scale.framebuffer)end,calculate=function(self,attr,value,target)return value and value*rtk.scale.framebuffer or target[attr]
end,},h=rtk.Attribute{priority=true,type='number',window_sync=true,reflow_uses_exterior_value=true,animate=rtk.Reference('w'),calculate=rtk.Reference('w'),},minw=rtk.Attribute{default=100,window_sync=true,reflow_uses_exterior_value=true,},minh=rtk.Attribute{default=30,window_sync=true,reflow_uses_exterior_value=true,},maxw=rtk.Attribute{window_sync=true,reflow_uses_exterior_value=true,},maxh=rtk.Attribute{window_sync=true,reflow_uses_exterior_value=true,},visible=rtk.Attribute{window_sync=true,},docked=rtk.Attribute{default=false,window_sync=true,reflow=rtk.Widget.REFLOW_NONE,},dock=rtk.Attribute{default=rtk.Window.DOCK_RIGHT,calculate={bottom=rtk.Window.DOCK_BOTTOM,left=rtk.Window.DOCK_LEFT,top=rtk.Window.DOCK_TOP,right=rtk.Window.DOCK_RIGHT,floating=rtk.Window.DOCK_FLOATING
},window_sync=true,reflow=rtk.Widget.REFLOW_NONE,},pinned=rtk.Attribute{default=false,window_sync=true,calculate=function(self,attr,value,target)return rtk.has_js_reascript_api and value
end,},borderless=rtk.Attribute{default=false,window_sync=true,calculate=rtk.Reference('pinned')},title=rtk.Attribute{default='REAPER application',reflow=rtk.Widget.REFLOW_NONE,window_sync=true,redraw=false,},opacity=rtk.Attribute{default=1.0,reflow=rtk.Widget.REFLOW_NONE,window_sync=true,redraw=false,},resizable=rtk.Attribute{default=true,reflow=rtk.Widget.REFLOW_NONE,window_sync=true,},hwnd=nil,in_window=false,is_focused=not rtk.has_js_reascript_api and true or false,running=false,cursor=rtk.mouse.cursors.POINTER,scalability=rtk.Widget.BOX,}function rtk.Window:initialize(attrs,...)rtk.Container.initialize(self,attrs,self.class.attributes.defaults,...)rtk.window=self
Expand Down Expand Up @@ -3536,11 +3541,11 @@ local x=self.x
local y=self.y
if not x then
x=0
overrides.halign=rtk.Widget.CENTER
overrides.halign=overrides.halign or rtk.Widget.CENTER
end
if not y then
y=0
overrides.valign=rtk.Widget.CENTER
overrides.valign=overrides.valign or rtk.Widget.CENTER
end
local w=rtk.isrel(self.w)and(self.w*sw)or(calc.w/scale)local h=rtk.isrel(self.h)and(self.h*sh)or(calc.h/scale)w=rtk.clamp(w,minw and minw/scale,maxw and maxw/scale)h=rtk.clamp(h,minh and minh/scale,maxh and maxh/scale)if sw and sh then
if overrides.halign==rtk.Widget.LEFT then
Expand Down Expand Up @@ -4105,7 +4110,7 @@ self._last_mousemove_time=nil
end
event.time=now
if not suppress then
rtk.Container._handle_event(self,0,0,event,false,rtk._modal==nil)end
self:_handle_event(0,0,event,false,rtk._modal==nil)end
assert(event.type~=rtk.Event.MOUSEDOWN or event.button~=0)if event.type==rtk.Event.MOUSEUP then
self._last_mouseup_time=event.time
rtk._drag_candidates=nil
Expand Down Expand Up @@ -5034,9 +5039,9 @@ dela=rtk.clamp(dela,1,#value)delb=rtk.clamp(delb,1,#value+1)value=value:sub(1,de
if insert then
self._dirty_positions=math.min(caret-1,self._dirty_positions or math.inf)value=value:sub(0,caret-1)..insert..value:sub(caret)caret=caret+insert:len()end
if value~=calc.value then
caret=rtk.clamp(caret,1,#value+1)self:sync('value', value)if caret~=calc.caret then
caret=rtk.clamp(caret,1,#value+1)self:sync('value', value, nil, false)if caret~=calc.caret then
self:sync('caret', caret)end
self._dirty_view=true
self:_handle_change()self._dirty_view=true
end
end
function rtk.Entry:delete_range(a,b)self:push_undo()self:_edit(nil,nil,a,b)end
Expand Down Expand Up @@ -6081,7 +6086,9 @@ elseif rtk.os.linux then
rtk.font.multiplier=0.7
end
rtk.set_theme_by_bgcolor(rtk.color.get_reaper_theme_bg() or '#262626')rtk.theme.default=true
end
reaper.atexit(function()if rtk.window and rtk.window.running then
rtk.window:close()end
rtk.log.flush()end)end
init()return rtk
end)()
return rtk
2 changes: 1 addition & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.0
1.4.0

0 comments on commit 78cbffe

Please sign in to comment.