Releases: khonsulabs/cushy
v0.4.0
Breaking Changes
- Dependency
kludgine
has been updated tov0.10.0
, which updates Cushy to
wgpu v22.0.0
andcosmic-text v0.12.0
. - At some point, a dependency of the
image
crate has been updated with a
minimum supported Rust version (MSRV) of1.80.0
. This is Cushy's new MSRV to
reflect this requirement. Source::for_each_*
now invoke the callback with the current contents of of
the source before attaching the callback. New functions beginning with
for_each_subsequent_
have been added with the original behavior.CushyWindowBuilder
has been renamed toStandaloneWindowBuilder
and
MakeWidget::build_virtual_window
has been renamed to
build_standalone_window
.- All animation easing related functionality has been reactored into a separate
crate:easing-function
. Most code will remain unaffected due to re-exports,
but theEasing
trait no longer accepts aZeroToOne
parameter, instead
accepting anf32
value.
Fixed
-
Fixed a panic that could occur when removing certain nested hierarchies from a
window. -
CallbackHandle
now has amust_use
hint that might help users discover the
persist function. -
Fixed a deadlock that could occur when multiple threads were attempting to
execute change callbacks for the same dynamic at the same time. -
The initial
inner_size
of aWindow
is now used if it is non-zero and
WindowAttributes::inner_size
isNone
. -
Container's layout and drawing functions now properly round up/down the
measurements to ensure accurate rendering. Fixes #158. -
Input
selection handling when dragging below or above the text field is now
handled correctly. -
Nested hierarchies of widgets stored in a reused
WidgetInstance
are now
properly unmounted and remounted. For widgets that storeMountedWidget
s, in
theirmounted
events the widgets should remount their children if needed.This fix not only fixes underlying issues with how unmounting was occuring,
but also fixesStack
,Grid
, andWidgetRef
to automatically remount as
needed.
Added
AnimationRecorder::animate_keypress
is a new helper that animates a single
key press.AnimationRecorder::animate_mouse_button
is a new helper that animates a
single mouse button press and release.Window::on_close_requested
is a new function that allows providing a
callback that is invoked before the window is closed when the user or
operating system requests that a window is closed. If the callback returns
true, the window is allowed to be closed. If false is returned, the window
will remain open. This feature is most commonly used to prevent losing unsaved
changes.Fraction
now hasLinearInterpolation
andPercentBetween
implementations.Window::zoom
allows setting aDynamic<Fraction>
that scales all DPI-scaled
operations by an additional scaling factor.Edges
andContainerShadow
now implementfigures::Round
.
v0.3.0
Breaking Changes
-
This crate's MSRV is now
1.74.1
, required by updatingwgpu
. -
wgpu
has been updated to0.20
. -
winit
has been updated to0.30
. -
All context types no longer accept a
'window
lifetime. For most end-user
code, it means removing one elided lifetime from these types:WidgetContext
EventContext
LayoutContext
GraphicsContext
-
WidgetContext
'sDeref
target is now&mut dyn PlatformWindow
. This change
ensures all widgets utilize a shared interface between any host architecture. -
All
DeviceId
parameters have been changed to aDeviceId
type provided by
Cushy. This allows for creating arbitrary input device IDs when creating an
integration with other frameworks or driving simulated input in a
VirtualWindow
. -
WidgetRef
is now astruct
instead of an enum. This refactor changes the
mounted state to be stored in aWindowLocal
, ensuringWidgetRef
s work
properly when used in aWidgetInstance
shared between multiple windows. -
WidgetRef::unmount_in
should be called when the widget is being unmounted to
clean up individual window state. -
Dynamic<T>
andDynamicReader<T>
have had most of their functions moved
into the traitsSource<T>
andDestination<T>
. This unifies the APIs
between the two types, and offers a path for other specialized reactive data
types to all share a unified API. -
map_mut
now takes aMutable<'_, T>
parameter instead of an&mut T
parameter. This type tracks whether the reference is accessed using
DerefMut
, allowingmap_mut
to skip invoking change callbacks if only
Deref
is used. -
redraw_when_changed()
/invalidate_when_changed()
from some types have been
moved to theTrackable
trait. This was to ensure all trackable types provide
the same API. -
Label
has been refactored to accept anyDisplay
type. As a result of this,
Label::text
is now nameddisplay
andLabel::new()
now accepts an
IntoReadOnly<T>
instead ofIntoValue<String>
. -
Dynamic<WidgetList>::wrap
andWidgetList::wrap
have been renamed to
into_wrap
for consistency. -
Cushy now has its own
KeyEvent
type, as winit's has private fields. This
prevented simulating input in aVirtualWindow
. -
FlexibleDimension::ZERO
has been removed, and nowFlexibleDimension
implementsZero
which defines an associated constant of the same name and
purpose. -
Children
has been renamed toWidgetList
. -
ColorExt::into_source_and_lightness
has been renamed to
ColorExt::into_hsl
, and its return type is nowHsl
instead of the
individual components. -
Window::font_data_to_load
has been renamed tofonts
, and now has the
FontCollection
type. -
Several font-related functions have been moved from
GraphicsContext
to
WidgetContext
:GraphicsContext::set_font_family()
GraphicsContext::find_available_font_family()
GraphicsContext::set_available_font_family()
-
Open::open
now require exclusive references to the application. -
PlatformWindowImplementation::set_cursor_icon
and
PlatformWindow::set_cursor_icon
have been renamed toset_cursor
and accept
winit
0.30's newCursor
type. -
Button::on_click
now takes aOption<ButtonClick>
structure. When this
value is provided, information about the mouse click that caused the event is
provided. -
OverlayBuilder
has hade many of its functions moved into a new trait,
Overlayable
. This is to ensure common API surfaces across all overlayable
widgets including the newMenu
widget.
Fixed
-
The root widget is now included in the search for widgets to accept focus.
-
Widgets that have been laid out with a 0px width or height no longer have
theirredraw
functions called nor can they receive focus. -
Grid
now synchronizes removal of widgets fromGridWidgets
correctly. -
WidgetInstance
s can now be shared between windows. Any unpredictable
behaviors when doing this should be reported, as some widgets may still have
state that should be moved into aWindowLocal
type. -
Grid
no longer passesConstraintLimit::Fill
along to children when it
contains more than one element. Previously, if rows contained widgets that
filled the given space, this would cause the grid to calculate layouts
incorrectly. -
A potential edge case where a
DynamicReader
would not return after being
disconnected has been removed. -
[#120][120]: Dividing a
ZeroToOne
now properly checks forNaN
and0.
. -
Removed a possible deadlock when using
DynamicReader::block_until_updated
. -
Removed an edge case ensuring
Waker
s are signaled forDynamicReader
s that
are waiting for value when the lastDynamic
is dropped. -
Progress
now utilizesIntoSource<Progress>
instead of
IntoDynamic<Progress>
. In general, this should not cause any code breakages
unless the traits were being used in generics. -
Space
now honorsConstraintLimit::Fill
in its layout. -
When handling the Ctrl/Cmd+W shortcut to close windows, repeat keys are now
ignored. -
Color::constrast_between
was incorrectly allowing hue shifts to weigh in on
the contrast when the color was desaturated, and the attempt to account for
that was incorrectly being applied to the lightness contrast calculation. In
short, this function should be much more accurate in perceived contrast
evaluation. -
Graphics::set_font_family
now clears the cached font family list, ensuring
that the next call to apply_current_font_settings works correctly. -
Image
now returns the correct size fromlayout()
when in aspect scaling
modes. Previously, it reported back the minimum size, since it's scale was
considered flexible. This new behavior ensures that it always requests a size
that is scaled with the aspect ratio.The rendering behavior remains unchanged, and the image will scale correctly
within whatever bounds it is given. -
Widget::unmounted
is now invoked for all widgets in the hierarchy.
Previously, only the parent widget was having its unmounted event invoked. -
Resizing windows should no longer be out of sync with the resize operation.
Previously, the window background would sometimes paint in newly revealed
areas before the UI was redrawn.
Changed
WidgetCacheKey
now includes theKludgineId
of the context it was created
from. This ensures if aWidgetInstance
moves or is shared between windows,
the cache is invalidated.- All
Dynamic
mapping functions now utilize weak references, and the
CallbackHandle
now contains a strong reference to the originating dynamic.
This should have no visible impact on end-user code. ForEach
/MapEach
's implementations for tuples are now defined using
Source<T>
andDynamicRead<T>
. This allows combinations ofDynamic<T>
s
andDynamicReader<T>
s to be used in for_each/map_each expressions.
Added
-
Cushy now supports being embedded in any wgpu application. Here are the API
highlights:CushyWindow
is a type that contains the state of a standalone window. It
defines an API designed to enable full control with winit integration into
any wgpu application. This type's design is inspired by wpgu's
"Encapsulating Graphics Work" article. Each of its functions require being
passed a type that implementsPlatformWindowImplementation
, which exposes
all APIs Cushy needs to be fully functional.VirtualWindow
is a type that makes it easy to render a Cushy interface in
any wgpu application where no winit integration is desired. It utilizes
VirtualState
as itsPlatformWindowImplementation
. This type also exposes
a design inspired by wpgu's "Encapsulating Graphics Work" article.WindowDynamicState
is a set of dynamics that can be updated through
external threads and tasks.- is a new trait that allows
customizing the behavior that Cushy widgets need to be rendered.
-
Cushy now supports easily rendering a virtual window:
VirtualRecorder
. This
type utilizes aVirtualWindow
and provides easy access to captured images.
This type has the ability to capture animated PNGs as well as still images. -
figures
is now directly re-exported at this crate's root. Kludgine still
also provides this export, so existing references through kludgine will
continue to work. This was added as an attempt to fix links on docs.rs (see
rust-lang/docs.rs#1588). -
Disclose
is a new widget that shows a disclosure triangle and uses a
Collapse
widget to show/hide the content when the disclosure button is
clicked. This widget also supports an optional label that is shown above the
content and is also clickable. -
[#99][99]: When an unhandled spacebar event is received by the window, the
focused widget will be activated and deactived by the events. This previously
was aButton
-specific behavior that has been refactored into an automatic
behavior for all widgets. -
GridWidgets
now implementsFromIterator
for types that implement
Into<GridSection<N>>
. -
Window::titled
allows setting a window's title, and can be provided a
string-type or aDynamic<String>
to allow updating the title while the
window is open. -
DynamicReader::on_disconnect
allows attaching a callback that is invoked
once the final sourceDynamic
is dropped. -
Dynamic::instances()
returns the number of clones the dynamic has in
existence. -
Dynamic::readers()
returns the number ofDynamicReader
s for the dynamic in
existence. -
RunningWindow::kludgine_id()
returns a unique id for that window. -
WindowLocal<T>
is aHashMap
-based type that stores data on a per-window
basis usingRunningWindow::kludgine_id()
as the key. -
Source<T>
andDestination<T>
are new traits that contain the reactive data
model's API i...
v0.2.0
Breaking Changes
- This crate has been renamed from
Gooey
toCushy
. Other than the name of
the library changing, the only type to change name isGooey
->Cushy
. This
changelog has had all references and links updated. - Many bounds required
UnwindSafe
due to a misunderstanding on how to handle
this trait inappit
. All requirements forUnwindSafe
have been removed. Cushy
no longer implements default. To gain access to aCushy
instance,
create aPendingApp
or get a reference to the runningApp
.Window::new
no longer accepts aCushy
parameter. The window now adopts the
Cushy
from the application it is opened within.MakeWidget::into_window()
no longer takes any parameters.
Changed
-
#92: When a Window is resizable and the root widget's
layout()
function returns a size larger than the window's inner size, the window will
no longer be resized to fit. The content will be forced to render in the given
space, which may result in clipping.Using a
Resize
widget in the root hierarchy allows setting minimum width and
heights for the content.
Fixed
- A memory leak has been fixed that prevented the underlying widget tree of each
window from being dropped. This was caused by a reference counting cycle, and
has been fixed by switchingMountedWidget
to use a weak reference internally
and having the window hold the strong reference to the tree. - #112: Click-selection is handled correctly across graphemes now.
Previously, code that was handling selecting between "ff" where cosmic_text
had merged the two ASCII characters into a single glpyh was not honoring
graphemes, allowing dragging selections inbetween multi-character glyphs. - #113:
Input
now constraints its internal selection to the value's
length automatically. This fixes an issue where the backspace key no longer
would work after clearing the text field by setting theDynamic
. - Validation callbacks are now associated with the
Dynamic<Validation>
being
created rather than being persisted indefinitely on the source dynamic.
Added
-
Validations::validate_result
attaches aDynamic<Result<T,E>>
to the
validations. This was already available onwhen
conditioned validations. -
Dynamic::[try_]compare_swap
allows swapping the contents of a dynamic after
verifying the current contents. -
#91: Multi-window support has been implemented.
PendingApp
allows
opening one or more windows before starting the program.App
is a handle to
the running application that can be used to open additional windows at
runtime.Open
is a new trait that allows various types to open as a window given a
reference to an application. This trait is implemented for all types that
implementedRun
, which means any type that was previously able to be run as
a standalone executable can now be opened as a window within a multi-window
application.The
multi-window
example demonstates using this feature to open multiple
windows before starting Cushy as well as dynamically opening windows at
runtime. -
Window::on_close
sets a callback to be invoked when the window has closed. -
WindowHandle
is a handle to a Cushy window. It enables requesting that the
window closes, refreshing the window, or invalidating a widget contained in
the window. -
RunningWindow::handle()
returns aWindowHandle
for the current window. -
RunningWindow::request_close()
requests that the window should close. This
ensuresWindowBehavior::close_requested
is invoked before the window is
closed. -
PendingWindow
is a new type that can return aWindowHandle
for a window
that hasn't opened yet. This can be used to allow a widget on a window to
close the window. -
Style components for customizing default widget colors have been added:
DefaultForegroundColor
DefaultBackgroundColor
DefaultHoveredForegroundColor
DefaultHoveredBackgroundColor
DefaultActiveForegroundColor
DefaultActiveBackgroundColor
DefaultDisabledForegroundColor
DefaultDisabledBackgroundColor
-
CallbackHandle
can now be added with otherCallbackHandle
s to merge
multiple handles into a single handle. -
Dynamic::set_source
allows attaching aCallbackHandle
to aDynamic
,
ensuring the callback stays alive as long as the dynamic has an instance
alive.
v0.1.3
Added
-
#94:
Window::inner_size
allows setting a dynamic that will be
synchronized with the window's inner size. When the dynamic is set to a new
value, a resize request will be sent to the operating system. When the
window's size is changed by the operating system, this dynamic will be updated
with the new value.This dynamic is also accessible through
RunningWindow::inner_size
, which is
accessible through contexts passed into variousWidget
functions. -
Progress
now implementsDefault
by returningProgress::Indeterminant
.
Fixed
-
#97:
Dynamic
callback invocations could be missed for a value when
multiple threads were updating values at the same time. Now it is
guaranteed that each callback will observe the latest value at least once.Cycles on the same thread are still detected and logged to prevent infinite
loops from callback chain cycles. -
An integer underflow has been fixed in the Grid/Stack widgets.
-
Padding is now rounded to the nearest whole pixel when applied across widgets.