Skip to content

Commit c90acc4

Browse files
committed
Update README with icon rendering customization details
Added documentation for the `IconRenderProperties` class, explaining its purpose, usage, and available factory methods. This enables users to customize tray icon rendering for different operating systems. Minor formatting adjustments were also made for clarity.
1 parent 6526695 commit c90acc4

1 file changed

Lines changed: 37 additions & 3 deletions

File tree

README.md

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
- **Single Instance Management**: Ensures that only one instance of the application can run at a time and allows restoring focus to the running instance when another instance is attempted.
2323
- **Tray Position Detection**: Allows determining the position of the system tray, which helps in positioning related windows appropriately.
2424
- **Compose Recomposition Support**: The tray supports Compose recomposition, making it possible to dynamically show or hide the tray icon, for example:
25-
25+
2626
<p align="center">
2727
<img src="screenshots/demo.gif" alt="demo">
2828
</p>
@@ -67,7 +67,6 @@ application {
6767
modifier = Modifier.fillMaxSize() // This is crucial!
6868
)
6969
},
70-
iconRenderProperties = IconRenderProperties.forCurrentOperatingSystem(), // If you need icon render customization
7170
tooltip = "My Application",
7271
primaryAction = {
7372
Log.i(logTag, "Primary action triggered")
@@ -132,6 +131,41 @@ application {
132131
- **dispose**: Call to remove the system tray icon and exit gracefully.
133132
- **Primary Action**: An action triggered by a left-click on the tray icon (Windows and macOS) or as a top item in the context menu (Linux).
134133

134+
### 🎨 Icon Rendering Customization
135+
136+
The `IconRenderProperties` class allows you to customize how your tray icon is rendered. This is an optional parameter when using the Tray component, with a default value already provided:
137+
138+
```kotlin
139+
iconRenderProperties = IconRenderProperties.forCurrentOperatingSystem()
140+
```
141+
142+
#### Available Factory Methods:
143+
144+
1. **forCurrentOperatingSystem()**: Creates properties optimized for the current operating system:
145+
- Windows: 32x32 pixels
146+
- macOS: 44x44 pixels
147+
- Linux: 24x24 pixels
148+
149+
```kotlin
150+
IconRenderProperties.forCurrentOperatingSystem(
151+
sceneWidth = 192, // Optional: Width of the compose scene (default: 192)
152+
sceneHeight = 192, // Optional: Height of the compose scene (default: 192)
153+
density = Density(2f) // Optional: Density for the compose scene (default: 2f)
154+
)
155+
```
156+
157+
2. **withoutScalingAndAliasing()**: Creates properties that don't force icon scaling and aliasing:
158+
159+
```kotlin
160+
IconRenderProperties.withoutScalingAndAliasing(
161+
sceneWidth = 192, // Optional: Width of the compose scene (default: 192)
162+
sceneHeight = 192, // Optional: Height of the compose scene (default: 192)
163+
density = Density(2f) // Optional: Density for the compose scene (default: 2f)
164+
)
165+
```
166+
167+
This allows you to fine-tune how your icon appears in the system tray across different platforms.
168+
135169
### 🔄 Single Instance Management
136170

137171
The `SingleInstanceManager` ensures that only one instance of the application is running at a time. When a second instance tries to start, it sends a restore request to the existing instance to bring it to the foreground.
@@ -214,4 +248,4 @@ Feel free to open issues or pull requests if you find any bugs or have suggestio
214248

215249
## 🙏 Acknowledgements
216250

217-
This library is developed and maintained by Elie G, aiming to provide an easy and cross-platform system tray solution for Kotlin applications.
251+
This library is developed and maintained by Elie G, aiming to provide an easy and cross-platform system tray solution for Kotlin applications.

0 commit comments

Comments
 (0)