18 KiB
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Unreleased
Breaking Changes
- All context types no longer accept a
'windowlifetime. For most end-user code, it means removing one elided lifetime from these types:WidgetContextEventContextLayoutContextGraphicsContext
WidgetContext'sDereftarget is now&mut dyn PlatformWindow. This change ensures all widgets utilize a shared interface between any host architecture.- All
DeviceIdparameters have been changed to aDeviceIdtype provided by Cushy. This allows for creating arbitrary input device IDs when creating an integration with other frameworks or driving simulated input in aVirtualWindow. WidgetRefis now astructinstead of an enum. This refactor changes the mounted state to be stored in aWindowLocal, ensuringWidgetRefs work properly when used in aWidgetInstanceshared between multiple windows.WidgetRef::unmount_inshould 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_mutnow takes aMutable<'_, T>parameter instead of an&mut Tparameter. This type tracks whether the reference is accessed usingDerefMut, allowingmap_mutto skip invoking change callbacks if onlyDerefis used.redraw_when_changed()/invalidate_when_changed()from some types have been moved to theTrackabletrait. This was to ensure all trackable types provide the same API.Labelhas been refactored to accept anyDisplaytype. As a result of this,Label::textis now nameddisplayandLabel::new()now accepts anIntoReadOnly<T>instead ofIntoValue<String>.Dynamic<WidgetList>::wrapandWidgetList::wraphave been renamed tointo_wrapfor consistency.- Cushy now has its own
KeyEventtype, as winit's has private fields. This prevented simulating input in aVirtualWindow. FlexibleDimension::ZEROhas been removed, and nowFlexibleDimensionimplementsZerowhich defines an associated constant of the same name and purpose.Childrenhas been renamed toWidgetList.ColorExt::into_source_and_lightnesshas been renamed toColorExt::into_hsl, and its return type is nowHslinstead of the individual components.
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 their
redrawfunctions called nor can they receive focus. -
Gridnow synchronizes removal of widgets fromGridWidgetscorrectly. -
WidgetInstances 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 aWindowLocaltype. -
Gridno longer passesConstraintLimit::Fillalong 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
DynamicReaderwould not return after being disconnected has been removed. -
#120: Dividing a
ZeroToOnenow properly checks forNaNand0.. -
Removed a possible deadlock when using
DynamicReader::block_until_updated. -
Removed an edge case ensuring
Wakers are signaled forDynamicReaders that are waiting for value when the lastDynamicis dropped. -
Compatibility with Rust v1.70.0 has been restored, and continuous integration testing the MSRV has been added.
-
Progressnow utilizesIntoSource<Progress>instead ofIntoDynamic<Progress>. In general, this should not cause any code breakages unless the traits were being used in generics. -
Spacenow honorsConstraintLimit::Fillin its layout. -
When handling the Ctrl/Cmd+W shortcut to close windows, repeat keys are now ignored.
-
Color::constrast_betweenwas 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_familynow clears the cached font family list, ensuring that the next call to apply_current_font_settings works correctly. -
Imagenow 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.
Changed
WidgetCacheKeynow includes theKludgineIdof the context it was created from. This ensures if aWidgetInstancemoves or is shared between windows, the cache is invalidated.- All
Dynamicmapping functions now utilize weak references, and theCallbackHandlenow 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 usingSource<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:
CushyWindowis 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.VirtualWindowis a type that makes it easy to render a Cushy interface in any wgpu application where no winit integration is desired. It utilizesVirtualStateas itsPlatformWindowImplementation. This type also exposes a design inspired by wpgu's "Encapsulating Graphics Work" article.WindowDynamicStateis 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 aVirtualWindowand provides easy access to captured images. This type has the ability to capture animated PNGs as well as still images. -
figuresis 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). -
Discloseis a new widget that shows a disclosure triangle and uses aCollapsewidget 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: When an unhandled spacebar event is received by the window, the focused widget will be activated and deactived by the events. This previously was a
Button-specific behavior that has been refactored into an automatic behavior for all widgets. -
GridWidgetsnow implementsFromIteratorfor types that implementInto<GridSection<N>>. -
Window::titledallows 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_disconnectallows attaching a callback that is invoked once the final sourceDynamicis dropped. -
Dynamic::instances()returns the number of clones the dynamic has in existence. -
Dynamic::readers()returns the number ofDynamicReaders 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 interface.Dynamic<T>implements both traits, andDynamicReader<T>implements onlySource<T>. -
DynamicRead<T>is a new trait that provides read-only access to a dynamic's contents. -
IntoReadOnly<T>is a new trait that types can implement to convert into aReadOnly<T>. -
IntoReader<T>is a new trait that types can implement to convert into aDynamicReader<T>. -
ReadOnly<T>is a type similar toValue<T>but instead of possibly being aDynamic<T>,ReadOnly::Readercontains aDynamicReader<T>. This type can be used where widgets that receive a value but never mutate it. -
Owned<T>is a new type that can be used where no shared ownership is necessary. This type uses aRefCellinternally instead of anArc+Mutex.Owned<T>implementsSource<T>andDestination<T>. -
GenerationalValue<T>now implementsDefaultwhenTdoes. -
Value<T>now implementsFrom<Dynamic<T>>. -
Most
into_functions that create widgets now haveto_variations that cloneselfbefore calling theinto_function. This has only been done in situations where it is known or likely that the clone being performed is cheap. -
CallbackHandlenow hasweak()andforget_owners(). These functions allow aCallbackHandleto release its strong references to theDynamicthat the callback is installed on. This enables forming weak callback graphs that clean up independent of one another. -
Source<T>::weak_clonereturns aDynamic<T>with a clone of each value stored in the original source. The returned dynamic holds no strong references to the original source. -
Point,Size, andRectnow implementLinearInterpolate. -
MakeWidget::build_virtual_window()returns a builder for aVirtualWindow. -
MakeWidget::build_recorder()returns a builder for aVirtualRecorder. -
Space::dynamic()returns a space that dynamically colors itself using component provided. This allows the spacer to use values from the theme at runtime. -
Space::primary()returns a space that contains the primary color. -
Hslis a new color type that is composed of hue, saturation, and lightness. -
Hslais a new color type that combinesHslwith an alpha component. -
Additional color pickers are now available:
HslPickerpicksHslHslaPickerpicksHslaRgbPickerpicksColorwith 255/1.0 alpha channelRgbaPickerpicksColor
-
ComponentPickeris a picker of variousColorComponentimplementors. It has constructors for each -
InvalidationBatchis a type that can batch invalidation requests being made by a background task. This can be useful if the background task is updating a variety ofDynamic<T>s, but wish to limit redrawing the interface until the task has completed its updates.This type does not prevent redraws from being performed due to the operating system or other threads requeseting them.
-
A new feature
plottersenables integration with the excellent plotters crate.Graphics::as_plot_area()is a new function that returns aplotters::DrawingAreathat can be used to draw any plot that theplotterscrate supports. -
Delimiteris a new widget that is similar to html'shrtag. -
Listis a new widget that creates lists similar to HTML'solandultags. -
Dynamic::try_lock()is a panic-free version ofDynamic::lock().
v0.2.0
Breaking Changes
- This crate has been renamed from
GooeytoCushy. 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
UnwindSafedue to a misunderstanding on how to handle this trait inappit. All requirements forUnwindSafehave been removed. Cushyno longer implements default. To gain access to aCushyinstance, create aPendingAppor get a reference to the runningApp.Window::newno longer accepts aCushyparameter. The window now adopts theCushyfrom the application it is opened within.MakeWidget::into_window()no longer takes any parameters.Label<T>is now generic over a new trait:DynamicDisplay. This new trait allows a way to query aWidgetContextto resolve the value to display. The trait is automatically implemented for all types that implementDisplay, so this change in practice shouldn't break much code.
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
Resizewidget 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 switching
MountedWidgetto 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:
Inputnow 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_resultattaches aDynamic<Result<T,E>>to the validations. This was already available onwhenconditioned validations. -
Dynamic::[try_]compare_swapallows swapping the contents of a dynamic after verifying the current contents. -
#91: Multi-window support has been implemented.
PendingAppallows opening one or more windows before starting the program.Appis a handle to the running application that can be used to open additional windows at runtime.Openis 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-windowexample demonstates using this feature to open multiple windows before starting Cushy as well as dynamically opening windows at runtime. -
Window::on_closesets a callback to be invoked when the window has closed. -
WindowHandleis 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 aWindowHandlefor the current window. -
RunningWindow::request_close()requests that the window should close. This ensuresWindowBehavior::close_requestedis invoked before the window is closed. -
PendingWindowis a new type that can return aWindowHandlefor 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:
DefaultForegroundColorDefaultBackgroundColorDefaultHoveredForegroundColorDefaultHoveredBackgroundColorDefaultActiveForegroundColorDefaultActiveBackgroundColorDefaultDisabledForegroundColorDefaultDisabledBackgroundColor
-
CallbackHandlecan now be added with otherCallbackHandles to merge multiple handles into a single handle. -
Dynamic::set_sourceallows attaching aCallbackHandleto aDynamic, ensuring the callback stays alive as long as the dynamic has an instance alive.
v0.1.3 (2023-12-19)
Added
-
#94
Window::inner_sizeallows 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 variousWidgetfunctions. -
Progressnow implementsDefaultby returningProgress::Indeterminant. -
WeakDynamic<T>now implementsDebugwhenTisDebug.
Fixed
-
#97:
Dynamiccallback 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.
v0.1.2 (2023-12-18)
Fixed
- Cushy now compiles for Windows. An indirect dependency,
appit, also needs to be updated to v0.1.1. Runningcargo updateshould be enough to updateappit.
v0.1.1 (2023-12-18)
This release only contains fixed links in the README. No code was changed.
v0.1.0 (2023-12-18)
This is the initial alpha release of Cushy.