198 Commits

Author SHA1 Message Date
014b4b66f4 Unit tests for Row and Column (#434) 2024-08-19 10:25:50 -04:00
d51a959b79 Unit tests for Box, Filler, Spacer, Row and Column modifiers (#270) 2024-08-18 00:02:46 -04:00
b15c83435a Create internal Turbine-like abstraction for Mosaic unit testing (#433) 2024-08-17 22:18:05 -04:00
d24b8cd880 Add unit test for counter (#397) 2024-08-16 19:14:25 -04:00
4d053dbbd3 Change runMosaic to support effects (#284) 2024-08-16 16:58:08 -04:00
74cb7c89e5 Reuse updater lambdas and eliminate backing field for efficiency (#432)
* Reuse updater lambdas and eliminate backing field for efficiency

Use the same lambda instances for all nodes to update their modifier, measure policy, or debug policy. Also eliminate the Modifier backing field and instead just recompute the layers.

* Update Node.kt
2024-08-15 23:16:09 -04:00
5ca7ff1a15 Update dependency com.pinterest.ktlint:ktlint-cli to v1.3.0 (#392)
* Update dependency com.pinterest.ktlint:ktlint-cli to v1.3.0

* Format

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jake Wharton <jw@squareup.com>
2024-06-07 03:39:41 +00:00
e36abdc1be Support synchronized update (#357) 2024-06-04 13:14:24 -04:00
148502f815 Some code fixes (#384)
- Move `Fill` and `Stroke` inside the `DrawStyle`
- Remove `toString` from `DrawStyle.Stroke` because `@Poko` is already doing it
- In the robot sample, the use of the `offset` modifier in the robot (`Text`)
- Remove `TODO https://github.com/JakeWharton/mosaic/issues/11` in the robot sample, it seems that it is no longer relevant
- In the robot sample, add `isActive` check in the loop for keyboard input
- Fix in the `README.md` `mutableStateOf` to `mutableIntStateOf`, as is correct in newer versions
2024-05-30 07:49:11 -04:00
d542cf1587 Modify DrawScope#drawRect (#383)
- Change the `drawRect` method in `DrawScope` like the method from the Compose UI
- Add support for `DrawStyle`: `Fill` and `Stroke` in `DrawScope#drawRect`
- Add support for drawing a rectangle from text characters
- Add `Filler` with code point
- Change the robot sample to show `drawRect` with `Stroke`
2024-05-29 21:50:07 -04:00
a5ec60767d Update to Kotlin 2.0
* Update Kotlin and Compose to v2

* Kotlin 2.0 updates

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jake Wharton <jw@squareup.com>
2024-05-28 16:55:50 -04:00
67ac843266 Migrate to isSameInstanceAs (#379) 2024-05-28 20:50:32 +00:00
15d9d2df30 Remove autoboxing and object creation from multiple locations (#372)
- Add `Color.Unspecified` for replace nullable `Color`
- Add some extension functions for `Color` to check on `Color.Unspecified`
- Use `TextStyle.Unspecified` instead null for `TextStyle`
- Add some extension functions for `TextStyle` to check on `TextStyle.Unspecified` and `TextStyle.Empty`
- Make `TextStyle` an inline class
- Using `Int` as codepoint (`TextPixel#codePoint`) instead of `String` in `TextPixel` (`TextPixel#value`)
- Rename `style: TextStyle` to `textStyle: TextStyle` for clearer and less confusing naming, as there are several other styles
- Add emoji to demo sample and use of 2 styles for part of the text
2024-05-27 21:15:36 -04:00
6efdb159b8 Support true color palette (#356)
Also update rrtop sample with several color palettes
2024-05-15 21:30:20 -04:00
20766cd55c Update dependency io.nlopez.compose.rules:ktlint to v0.3.20 (#361)
* Update dependency io.nlopez.compose.rules:ktlint to v0.3.20

* Suppress

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jake Wharton <jw@squareup.com>
2024-05-10 15:25:45 +00:00
7aa13e5e93 Remove Terminal.Size and use IntSize instead in Terminal.size for optimization purposes (#363) 2024-05-09 19:23:05 -04:00
36fc6a8e3b Update dependency io.nlopez.compose.rules:ktlint to v0.3.15 (#345)
* Update dependency io.nlopez.compose.rules:ktlint to v0.3.15

* Use mutableIntStateOf

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jake Wharton <jw@squareup.com>
2024-04-14 01:34:12 +00:00
fc9a48cfd3 Use CLRF line endings to support rendering in raw mode (#337)
* Use CRLF line endings to support rendering when terminal runs in raw mode

* Update tests to expect CRLF line endings

* Update CHANGELOG.md

* Update CHANGELOG.md

* Apply changes from spotlessKotlin

---------

Co-authored-by: Jake Wharton <github@jakewharton.com>
2024-03-27 21:37:21 +00:00
e58ceb1dd0 Update dependency com.pinterest.ktlint:ktlint-cli to v1.2.0 (#320)
* Update dependency com.pinterest.ktlint:ktlint-cli to v1.2.0

* Appease ktlint

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jake Wharton <jw@squareup.com>
2024-02-29 02:17:03 +00:00
f192af3b26 Add Binary Compatibility Validator (#298)
* Add Binary Compatibility Validator

Tracking changes to the library's public contract.

https://github.com/Kotlin/binary-compatibility-validator

* Apply suggestions from code review

---------

Co-authored-by: Jake Wharton <github@jakewharton.com>
2024-01-16 16:45:19 +00:00
2d6177d8a5 Update compose-rules to 0.3.9 and remove suppressions (#300) 2024-01-16 15:10:26 +00:00
829d1182a7 Fix build after separate merges (#269) 2023-12-02 04:24:39 +00:00
e107cdc241 Unit tests for modifiers and some fixes (#261)
* Unit tests for modifiers and some fixes

Added unit tests for `AspectRatio`, `Offset`, `Padding`, `Size` modifiers.
Added unit tests for `Arrangement`.
Added some auxiliary tools for unit tests.
Added `equals` and `hashCode` implementations for `SizeModifier`, `FillModifier`, `WrapContentModifier`, `UnspecifiedConstraintsModifier`.
Added a new `Composable` - `Filler`. Draws the same symbol over its entire size. Similar to `Spacer`, where such a symbol is a space without additional styles.
Added a `Composable` `Box` without content.
Fixed formatting in the `toString` implementation for `Alignment`, taking into account possible non-integers.
Fixed a problem in `OffsetModifier` with incorrect transmission of `x` and `y` due to shadowing fields.
Fixed some bugs and typos in `Node.kt` related to the `minIntrinsicWidth`, `maxIntrinsicWidth`, `minIntrinsicHeight`, `maxIntrinsicHeight` methods.

* Code review fixes
2023-12-01 22:13:10 -05:00
12fc6fc245 Introduce Compose ktlint rules (#267) 2023-12-01 22:03:15 -05:00
e49763c074 Rewrite Row and Column (#251)
Added Arrangement to Row and Column.
Changed the implementation of Row and Column to one common with Constraints support.
Modifier.weight has been added to RowScope and ColumnScope.
2023-11-18 22:44:51 -05:00
d491a59894 Add fill and wrapContent modifiers (#252) 2023-11-18 22:26:59 -05:00
ed15b629a2 Add offset modifier (#254)
* Add offset modifier

* Reformat
2023-11-18 12:47:49 -05:00
ace66719d7 Add aspectRatio modifier (#253) 2023-11-17 17:20:12 -05:00
9ad686151b Initialize AnsiConsole before usage (#249) 2023-11-13 22:33:15 +00:00
9358bd8ad5 Add new demo app for messing around (#246) 2023-11-13 21:16:08 +00:00
201de77270 Migrate to AssertK (#245) 2023-11-13 19:35:57 +00:00
ec6c09eca2 Enable Spotless/ktlint formatting (#243) 2023-11-13 19:01:40 +00:00
a07ef25b0e Enable default hierarchy (#244) 2023-11-13 18:57:01 +00:00
6da826625c Convert data class to Poko (#242) 2023-11-13 18:40:37 +00:00
8123702fa9 Add AnnotatedString with SpanStyle for text customization (#227)
* Add AnnotatedString with SpanStyle for text customization

This is a simplified version of AnnotatedString and SpanStyle from Jetpack Compose. There is no ParagraphStyle support. SpanStyle contains fewer properties.

The tests are also taken from Jetpack Compose, but simplified.

The API has been saved for using AnnotatedString and creating and styling it, for quick understanding if you know Jetpack Compose.

The code has two Compose Text functions, two DrawScope.DrawText methods, two TextLayout inheritors, in which the difference is only in the accepted value - either String or AnnotatedString. This is done for optimization, but in theory it may be unnecessary.

Update the jest example using AnnotatedString.

* Add MosaicComposable to Text function with AnnotatedString parameter

* Change TextLayout access modifier to internal
2023-11-13 13:21:00 -05:00
b02bfada7b Add Constraints and intrinsics to layout system (#239)
* Add Constraints and intrinsics to layout system

Added the `Constraints` parameter for all required methods.
Extended `MeasurePolicy` with methods of intrinsics.
`Constraints` are fully supported in `Box` and `Modifier.padding`.

* Add Spacer and size modifiers

`Spacer` and size modifiers use new `Constraints`.

* Fix unit tests
2023-11-13 13:05:11 -05:00
f02173c4d1 Migrate to Poko from data classes (#240)
At least for those in public API.
2023-11-13 17:29:22 +00:00
a8e0d288d7 CompositionLocal for terminal size by Mordant (#230)
* CompositionLocal for terminal size by Mordant

The Mordant KMP library has been added to the mosaic-runtime module in commonMain, which allows you to interact with the cli.

This makes it possible to get the size of the terminal via `CompositionLocal` - `Terminal.current.size`.

* Use local variable for terminalInfo in loop with terminal size update

Co-authored-by: Jake Wharton <github@jakewharton.com>

---------

Co-authored-by: Jake Wharton <github@jakewharton.com>
2023-11-13 11:35:59 -05:00
f7ec16cb4b Add Alignment to Row, Column and Box (#233)
* Add Alignment to Row, Column and Box

* Apply suggestions from code review

---------

Co-authored-by: Jake Wharton <github@jakewharton.com>
2023-10-31 21:03:08 +00:00
a4dc9edde0 Add MosaicComposable annotation (#229)
The annotation is used to mark Mosaic Compose functions that cannot be used in other Compose code or for other compositions.
2023-10-15 17:23:54 -04:00
469f87b75a Ensure node top layer can only be set internally to the type (#189) 2023-06-11 04:27:43 +00:00
1b48b1412a Add Box layout (#183) 2023-05-17 04:36:10 +00:00
26d6f5c54b Add modifiers to row/column (#182) 2023-05-17 04:18:14 +00:00
bdc5e277b2 Use Applier.onEndChanges for emitting frames (#181) 2023-05-17 03:51:59 +00:00
f18e140e7e Add background modifier, fix multimodifier positioning (#180) 2023-05-17 03:38:59 +00:00
92783cf020 Eliminate the static policy (#178)
The node knows whether it's static or not now, just do the logic there.
2023-05-16 03:24:16 +00:00
caeacc14a0 Rewrite node to use modifiers (#172) 2023-05-15 22:49:51 -04:00
ae51963ceb Shuffle things around for cleaner layering (#164)
The 'layout' package is now a standalone widget tree. The 'ui' package is now only composables. The root package contains all the code for integration and Compose.
2023-03-28 03:14:28 +00:00
40be11f82c Create text layout abstraction (#163)
Caches operations like string splitting and measuring.
2023-03-28 02:00:17 +00:00
0503166d05 Do not clip the canvas for each child (#162)
Compose UI does not clip. It's easier to make clip opt-in than to make it opt-out.
2023-03-27 01:21:19 +00:00