-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* replace SplitLayout Signed-off-by: Ivan Morgillo <[email protected]> * add splitlayout icon Signed-off-by: Ivan Morgillo <[email protected]> * add SplitLayout icon to the collection Signed-off-by: Ivan Morgillo <[email protected]> * create the SplitLayouts showcase in the Standalone Signed-off-by: Ivan Morgillo <[email protected]> * make it uglier but now the linter is happy Signed-off-by: Ivan Morgillo <[email protected]> * hoist the SplitLayout divider state Signed-off-by: Ivan Morgillo <[email protected]> * remove nested layout from SplitLayouts showcase Signed-off-by: Ivan Morgillo <[email protected]> * add responsive minimum width to SplitLayout Signed-off-by: Ivan Morgillo <[email protected]> * make the linter happy Signed-off-by: Ivan Morgillo <[email protected]> * iterate on SplitLayout icon Signed-off-by: Ivan Morgillo <[email protected]> * fix NaN operation in calculateAdjustedSizes() Signed-off-by: Ivan Morgillo <[email protected]> * iterate on SplitLayout draggable Signed-off-by: Ivan Morgillo <[email protected]> * replace a whens with ifs Signed-off-by: Ivan Morgillo <[email protected]> * iterate on draggable divider Signed-off-by: Ivan Morgillo <[email protected]> * tune the pointer icon while dragging Signed-off-by: Ivan Morgillo <[email protected]> * make the linter happy Signed-off-by: Ivan Morgillo <[email protected]> * add min width to SplitLayout in IDE sample Signed-off-by: Ivan Morgillo <[email protected]> * fix wrong params in SplitLayouts reference: #570 (comment) Signed-off-by: Ivan Morgillo <[email protected]> * name params consistently in SplitLayout reference: #570 (comment) Signed-off-by: Ivan Morgillo <[email protected]> * add missing KDOC reference: #570 (comment) Signed-off-by: Ivan Morgillo <[email protected]> * add missing KDOC to public API reference: #570 (comment) Signed-off-by: Ivan Morgillo <[email protected]> * remove redundant value reference: #570 (comment) Signed-off-by: Ivan Morgillo <[email protected]> * inlined variable reference: #570 (comment) Signed-off-by: Ivan Morgillo <[email protected]> * extract draggableState variable reference: #570 (comment) Signed-off-by: Ivan Morgillo <[email protected]> * rename maxPositionPx reference: #570 (comment) Signed-off-by: Ivan Morgillo <[email protected]> * simplify pointer icon management reference: #570 (comment) Signed-off-by: Ivan Morgillo <[email protected]> * rename fillModifier reference: #570 (comment) Signed-off-by: Ivan Morgillo <[email protected]> * remove redundant .then() reference: #570 (comment) Signed-off-by: Ivan Morgillo <[email protected]> * add -Px suffix to a couple of values reference: #570 (comment) Signed-off-by: Ivan Morgillo <[email protected]> * extract a couple of methods reference: #570 (comment) Signed-off-by: Ivan Morgillo <[email protected]> * moved values into doLayout() reference: #570 (comment) Signed-off-by: Ivan Morgillo <[email protected]> * iterate on windows resizing Signed-off-by: Ivan Morgillo <[email protected]> * iterate once more on divider positioning while dragging Signed-off-by: Ivan Morgillo <[email protected]> * Fix formatting --------- Signed-off-by: Ivan Morgillo <[email protected]> Co-authored-by: Sebastiano Poggi <[email protected]>
- Loading branch information
Showing
8 changed files
with
606 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...one/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/component/SplitLayouts.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import androidx.compose.foundation.border | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.foundation.text.input.TextFieldState | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import org.jetbrains.jewel.foundation.theme.JewelTheme | ||
import org.jetbrains.jewel.ui.component.HorizontalSplitLayout | ||
import org.jetbrains.jewel.ui.component.OutlinedButton | ||
import org.jetbrains.jewel.ui.component.SplitLayoutState | ||
import org.jetbrains.jewel.ui.component.Text | ||
import org.jetbrains.jewel.ui.component.TextField | ||
import org.jetbrains.jewel.ui.component.VerticalSplitLayout | ||
|
||
@Composable | ||
fun SplitLayouts( | ||
outerSplitState: SplitLayoutState, | ||
verticalSplitState: SplitLayoutState, | ||
innerSplitState: SplitLayoutState, | ||
onResetState: () -> Unit, | ||
) { | ||
Column(Modifier.fillMaxSize()) { | ||
Row(verticalAlignment = Alignment.CenterVertically) { | ||
Text("Reset split state:") | ||
Spacer(Modifier.width(8.dp)) | ||
OutlinedButton(onClick = onResetState) { Text("Reset") } | ||
} | ||
|
||
Spacer(Modifier.height(16.dp)) | ||
|
||
HorizontalSplitLayout( | ||
state = outerSplitState, | ||
first = { FirstPane() }, | ||
second = { SecondPane(innerSplitState = innerSplitState, verticalSplitState = verticalSplitState) }, | ||
modifier = Modifier.fillMaxWidth().weight(1f).border(1.dp, color = JewelTheme.globalColors.borders.normal), | ||
firstPaneMinWidth = 300.dp, | ||
secondPaneMinWidth = 200.dp, | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
private fun FirstPane() { | ||
Box(modifier = Modifier.fillMaxSize().padding(16.dp), contentAlignment = Alignment.Center) { | ||
val state by remember { mutableStateOf(TextFieldState()) } | ||
TextField(state, placeholder = { Text("Placeholder") }) | ||
} | ||
} | ||
|
||
@Composable | ||
private fun SecondPane(innerSplitState: SplitLayoutState, verticalSplitState: SplitLayoutState) { | ||
VerticalSplitLayout( | ||
state = verticalSplitState, | ||
modifier = Modifier.fillMaxSize(), | ||
first = { | ||
val state by remember { mutableStateOf(TextFieldState()) } | ||
Box(Modifier.fillMaxSize().padding(16.dp), contentAlignment = Alignment.Center) { | ||
TextField(state, placeholder = { Text("Right Panel Content") }) | ||
} | ||
}, | ||
second = { | ||
HorizontalSplitLayout( | ||
first = { | ||
Box(Modifier.fillMaxSize().padding(16.dp), contentAlignment = Alignment.Center) { | ||
Text("Second Pane left") | ||
} | ||
}, | ||
second = { | ||
Box(Modifier.fillMaxSize().padding(16.dp), contentAlignment = Alignment.Center) { | ||
Text("Second Pane right") | ||
} | ||
}, | ||
modifier = Modifier.fillMaxSize(), | ||
state = innerSplitState, | ||
firstPaneMinWidth = 100.dp, | ||
secondPaneMinWidth = 100.dp, | ||
) | ||
}, | ||
firstPaneMinWidth = 300.dp, | ||
secondPaneMinWidth = 100.dp, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
samples/standalone/src/main/resources/icons/components/splitLayout.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions
7
samples/standalone/src/main/resources/icons/components/splitLayout_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.