Skip to content

Commit

Permalink
- [Docs] Updated docs site
Browse files Browse the repository at this point in the history
  • Loading branch information
pusolito committed Jun 28, 2024
1 parent c77a31e commit 6ba5606
Show file tree
Hide file tree
Showing 55 changed files with 263 additions and 465 deletions.
2 changes: 1 addition & 1 deletion docs/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


<script src="https://unpkg.com/kotlin-playground@1"></script><link rel="stylesheet" href="/doodle-tutorials/assets/css/styles.8934ba38.css">
<script src="/doodle-tutorials/assets/js/runtime~main.6895b875.js" defer="defer"></script>
<script src="/doodle-tutorials/assets/js/runtime~main.d8542a75.js" defer="defer"></script>
<script src="/doodle-tutorials/assets/js/main.2c8e2dcd.js" defer="defer"></script>
</head>
<body class="navigation-with-keyboard">
Expand Down
Binary file modified docs/animation-full.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
1 change: 1 addition & 0 deletions docs/assets/js/41d8cb0f.df20a61b.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/assets/js/41d8cb0f.fcf2d19a.js

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/assets/js/72e519b5.259cf7e1.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/assets/js/72e519b5.33335f67.js

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/assets/js/bfecc435.6252ae92.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/assets/js/bfecc435.e5ef6759.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/assets/js/common.b3d10bd6.js

This file was deleted.

1 change: 1 addition & 0 deletions docs/assets/js/common.beb03187.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/assets/js/ec59b1a4.72104478.js

This file was deleted.

1 change: 1 addition & 0 deletions docs/assets/js/ec59b1a4.d5001b6f.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/assets/js/runtime~main.6895b875.js

This file was deleted.

1 change: 1 addition & 0 deletions docs/assets/js/runtime~main.d8542a75.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/calculator/CalculatorRunner.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/calculator_wasm/CalculatorRunner.js

Large diffs are not rendered by default.

Binary file not shown.
2 changes: 1 addition & 1 deletion docs/contacts/ContactsRunner.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/contacts_wasm/ContactsRunner.js

Large diffs are not rendered by default.

Binary file modified docs/contacts_wasm/doodle-tutorials-ContactsRunner-wasm-js.wasm
Binary file not shown.
34 changes: 1 addition & 33 deletions docs/docs/calculator.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


<script src="https://unpkg.com/kotlin-playground@1"></script><link rel="stylesheet" href="/doodle-tutorials/assets/css/styles.8934ba38.css">
<script src="/doodle-tutorials/assets/js/runtime~main.6895b875.js" defer="defer"></script>
<script src="/doodle-tutorials/assets/js/runtime~main.d8542a75.js" defer="defer"></script>
<script src="/doodle-tutorials/assets/js/main.2c8e2dcd.js" defer="defer"></script>
</head>
<body class="navigation-with-keyboard">
Expand Down Expand Up @@ -100,17 +100,14 @@ <h2 class="anchor anchorWithStickyNavbar_LWe7" id="defining-our-application">Def
<code theme="darcula" mode="kotlin" data-highlight-only="true">
package io.nacular.doodle.examples


// ...


class CalculatorApp(display: Display): Application {
init {
// creat and display a single Calculator
display += Calculator()
}


override fun shutdown() { /* no-op */ }
}
</code>
Expand All @@ -123,10 +120,8 @@ <h2 class="anchor anchorWithStickyNavbar_LWe7" id="creating-a-fullscreen-web-app
<code theme="darcula" mode="kotlin" data-highlight-only="true">
package io.nacular.doodle.examples


//...


fun fullScreen() {
application(modules = listOf(PointerModule)) {
// load app
Expand Down Expand Up @@ -155,49 +150,39 @@ <h3 class="anchor anchorWithStickyNavbar_LWe7" id="calculator-output">Calculator
private inner class Output: View() {
//...


// Transform used to scale text down as it grows beyond window width
private var textTransform = Identity


//...


/** Text representation of number */
var text = &quot;0&quot;
set(new) {
field = new

val textWidth = textMetrics.width(field, font)
val windowWidth = width - inset * 2


// use transform when text grows beyond window width
textTransform = when {
textWidth &gt; windowWidth -&gt; (windowWidth/textWidth).let { Identity.scale(x = it, y = it, around = Point(width / 2, height)) }
else -&gt; Identity
}


rerender()
}


//...


override fun render(canvas: Canvas) {
val textPosition = textMetrics.size(text, font).let {
val x = when {
textTransform.isIdentity -&gt; width - it.width - inset
else -&gt; (width - it.width) / 2
}


Point(x, height - it.height)
}


// scaling, if present, is applied to the canvas before text rendered
canvas.transform(textTransform) {
text(text, at = textPosition, font = font, color = foregroundColor ?: White)
Expand All @@ -221,10 +206,8 @@ <h2 class="anchor anchorWithStickyNavbar_LWe7" id="more-dependencies">More Depen
<code theme="darcula" mode="kotlin" data-highlight-only="true">
package io.nacular.doodle.examples


// ...


class CalculatorApp(
display : Display,
textMetrics : TextMetrics,
Expand All @@ -236,7 +219,6 @@ <h2 class="anchor anchorWithStickyNavbar_LWe7" id="more-dependencies">More Depen
display += Calculator(fontDetector, textMetrics, numberFormatter)
}


override fun shutdown() { /* no-op */ }
}
</code>
Expand Down Expand Up @@ -266,67 +248,55 @@ <h2 class="anchor anchorWithStickyNavbar_LWe7" id="the-buttons">The Buttons<a hr
<code theme="darcula" mode="kotlin" data-highlight-only="true">
class Calculator(/*...*/): View() {


//...


init {
GlobalScope.launch {
loadFonts()

ButtonGroup(allowDeselectAll = true, buttons = *arrayOf(`÷`, `*`, `-`, `+`))


val outputHeight = 100.0
val buttonSpacing = 10.0


val gridPanel = GridPanel().apply {
add(clear, 0, 0); add(negate, 0, 1); add(`÷`, 0, 2); add(`÷`, 0, 3)
add(`7`, 1, 0); add(`8`, 1, 1); add(`9`, 1, 2); add(`*`, 1, 3)
add(`4`, 2, 0); add(`5`, 2, 1); add(`6`, 2, 2); add(`-`, 2, 3)
add(`1`, 3, 0); add(`2`, 3, 1); add(`3`, 3, 2); add(`+`, 3, 3)
add(`0`, 4, 0, columnSpan = 2 ); add(decimal, 4, 2); add(`=`, 4, 3)


verticalSpacing = buttonSpacing
horizontalSpacing = buttonSpacing
}


children += listOf(output, gridPanel)


// Place output outside grid so the height can be more easily controlled
val constraints = constrain(output, gridPanel) { output, grid -&gt;
output.top = parent.top
output.left = parent.left
output.right = parent.right
output.height = constant(outputHeight)

grid.top = output.bottom + buttonSpacing
grid.left = output.left
grid.right = output.right
grid.bottom = parent.bottom
}


layout = object: Layout by constraints {
// Set total height to grid panel&#x27;s ideal width and height, plus output and spacing
override fun idealSize(container: PositionableContainer, default: Size?) = gridPanel.idealSize?.let {
Size(it.width, it.height + outputHeight + buttonSpacing)
}
}


// Force idealSize when gridPanel is laid out
gridPanel.sizePreferencesChanged += { _,_,new -&gt;
idealSize = new.idealSize?.let { Size(it.width, it.height + outputHeight + buttonSpacing) }
}
}
}


//...
}
</code>
Expand All @@ -340,13 +310,11 @@ <h2 class="anchor anchorWithStickyNavbar_LWe7" id="custom-hit-detection">Custom
class CalcButtonBehavior(textMetrics: TextMetrics): CommonTextButtonBehavior&lt;Button&gt;(textMetrics) {
//...


override fun contains(view: Button, point: Point): Boolean {
val radius = view.height / 2
val leftCircle = Circle(center = Point(view.x + radius, view.center.y), radius = radius)
val rightCircle = Circle(center = Point(view.bounds.right - radius, view.center.y), radius = radius)


return when {
point.x &lt; radius -&gt; point in leftCircle
point.x &gt; view.width - radius -&gt; point in rightCircle
Expand Down
Loading

0 comments on commit 6ba5606

Please sign in to comment.