Skip to content

Commit 9112347

Browse files
authored
Improvements v12.9 add padding (#91)
* tweaks * padding * tweak button * tweak button * improve handling of min/max content in children * fix 2.0.x compilation issue * fix 2.0.x compilation issue - test 2.0.x version
1 parent 10fd554 commit 9112347

File tree

12 files changed

+49
-21
lines changed

12 files changed

+49
-21
lines changed

.github/workflows/build-full.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
matrix:
1111
nimversion:
1212
- '2.x'
13+
- '2.0.14'
1314

1415
os:
1516
- ubuntu-latest

.github/workflows/build-pr.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
matrix:
1111
nimversion:
1212
- '2.x'
13+
- '2.0.14'
1314
os:
1415
- ubuntu-latest
1516
steps:

examples/hnbrowser.nim

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,25 @@ proc draw*(self: Main) {.slot.} =
100100
offset 2'pp, 2'pp
101101
cornerRadius 7.0'ux
102102
size 96'pp, 90'pp
103+
echo "\n"
104+
printLayout(this, cmTerminal)
103105

104106
Vertical.new "items":
105107
with this:
106-
contentHeight cx"min-content", 3'ui
108+
contentHeight cx"max-content", 3'ui
107109

108110
for idx, story in self.stories:
109-
capture story:
110-
Button.new "story":
111+
# if idx > 5: break
112+
capture story, idx:
113+
Button.new "story" & $idx:
114+
onSignal(doRightClick) do(this: Button[tuple[]]):
115+
printLayout(this, cmTerminal)
111116
with this:
112-
size 1'fr, ux(2*lh)
117+
# size 1'fr, ux(2*lh)
118+
size 1'fr, max(ux(2.0*lh.float), cx"min-content")
119+
# this.cxPadOffset[drow] = 20'ux
120+
# this.cxPadSize[drow] = 20'ux
121+
113122
Text.new "text":
114123
with this:
115124
size 1'fr, ux(2*lh)
@@ -119,7 +128,6 @@ proc draw*(self: Main) {.slot.} =
119128
justify Left
120129
align Middle
121130
text({font: $story.link.title})
122-
# printLayout(this, cmTerminal)
123131

124132
var main = Main(name: "main")
125133
var frame = newAppFrame(main, size=(600'ui, 280'ui))

figuro.nimble

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "0.12.8"
1+
version = "0.12.9"
22
author = "Jaremy Creechley"
33
description = "UI Engine for Nim"
44
license = "MIT"
@@ -9,7 +9,7 @@ srcDir = "src"
99
requires "nim >= 2.0.10"
1010
requires "sigils >= 0.11.8"
1111
requires "pixie >= 5.0.1"
12-
requires "cssgrid >= 0.9.4"
12+
requires "cssgrid >= 0.9.8"
1313
requires "chroma >= 0.2.7"
1414
requires "bumpy"
1515
requires "pretty"

src/figuro/common/nodes/uinodes.nim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type
5959
nIndex*: int
6060
diffIndex*: int
6161

62-
box*: Box
62+
box*, bpad*: Box
6363
bmin*, bmax*: Size
6464
screenBox*: Box
6565
offset*: Position
@@ -72,6 +72,8 @@ type
7272

7373
cxSize*: array[GridDir, Constraint] = [csAuto(), csAuto()]
7474
cxOffset*: array[GridDir, Constraint] = [csAuto(), csAuto()]
75+
cxPadSize*: array[GridDir, Constraint] = [csAuto(), csAuto()]
76+
cxPadOffset*: array[GridDir, Constraint] = [csAuto(), csAuto()]
7577
cxMin*: array[GridDir, Constraint] = [csNone(), csNone()]
7678
cxMax*: array[GridDir, Constraint] = [csNone(), csNone()]
7779

src/figuro/renderer/opengl.nim

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,11 @@ proc configureWindowEvents(renderer: Renderer) =
9898
uxInput.mouse.prev = prevPos.descaled()
9999
uxInput.mouse.consumed = false
100100
lastMouse = uxInput.mouse
101-
let res = renderer.uxInputList.trySend(uxInput)
102-
if res == false:
103-
echo "warning: mouse event blocked!"
101+
if not renderer.uxInputList.trySend(uxInput):
102+
info "warning: mouse event blocked!"
103+
104+
window.onFocusChange = proc() =
105+
warn "onFocusChange"
104106

105107
window.onScroll = proc() =
106108
var uxInput = AppInputs(mouse: lastMouse)

src/figuro/runtime/runtimeCore.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ proc tick*(self: AppTicker) {.slot.} =
5858
os.sleep(self.period.inMilliseconds)
5959

6060
proc updateTheme*(self: AppFrame, css: CssTheme) {.slot.} =
61-
debug "CSS theme into app", numberOfCssRules = css.rules().toSeq().len()
61+
debug "CSS theme into app", numberOfCssRules = rules(css).toSeq().len()
6262
self.theme.css = css
6363
refresh(self.root)
6464

src/figuro/runtime/utils/cssMonitor.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ when not defined(noFiguroDmonMonitor):
5252
proc update(file: string) =
5353
let css = loadTheme(file)
5454
if css != nil:
55-
notice "CSS Updated: ", file = file, css = css.rules().toSeq.len()
55+
notice "CSS Updated: ", file = file, css = rules(css).toSeq.len()
5656
emit self.cssUpdate(css)
5757
os.sleep(16) # TODO: fixme: this is a hack to ensure proper text resizing
58-
notice "CSS Updated: second: ", file = file, css = css.rules().toSeq.len()
58+
notice "CSS Updated: second: ", file = file, css = rules(css).toSeq.len()
5959
emit self.cssUpdate(css)
6060

6161
let cssFiles = @[defaultTheme, appFile]

src/figuro/ui/apisImpl.nim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ template onHover*(current: Figuro, inner: untyped) =
173173
if evHover in current.events:
174174
inner
175175

176-
template onHover*(inner: untyped) =
177-
## Sets and onHover behavior.
178-
onHover(node, inner)
176+
# template onHover*(inner: untyped) =
177+
# ## Sets and onHover behavior.
178+
# onHover(node, inner)
179179

180180
proc getTitle*(current: Figuro): string =
181181
## Gets window title

src/figuro/ui/cssengine.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,5 +222,5 @@ proc applyThemeRules*(node: Figuro) =
222222
if skipCss in node.attrs:
223223
return
224224
let node = if node of Text: node.parent[] else: node
225-
for rule in node.frame[].theme.css.rules():
225+
for rule in rules(node.frame[].theme.css):
226226
rule.eval(node)

0 commit comments

Comments
 (0)