fix text string sizing in UI
parent
a344c65cca
commit
958f20e97c
|
@ -90,11 +90,11 @@ M: editor user-input* ( ch editor -- ? )
|
||||||
scroll>bottom t ;
|
scroll>bottom t ;
|
||||||
|
|
||||||
M: editor pref-size ( editor -- w h )
|
M: editor pref-size ( editor -- w h )
|
||||||
editor-text shape-size >r 1 + r> ;
|
dup editor-text label-size >r 1 + r> ;
|
||||||
|
|
||||||
M: editor layout* ( editor -- )
|
M: editor layout* ( editor -- )
|
||||||
dup editor-caret over caret-size rot resize-gadget
|
dup editor-caret over caret-size rot resize-gadget
|
||||||
dup editor-caret swap caret-pos rot move-gadget ;
|
dup editor-caret swap caret-pos rot move-gadget ;
|
||||||
|
|
||||||
M: editor draw-shape ( editor -- )
|
M: editor draw-shape ( editor -- )
|
||||||
dup [ editor-text draw-shape ] with-trans ;
|
[ editor-text ] keep [ draw-string ] with-trans ;
|
||||||
|
|
|
@ -59,7 +59,15 @@ C: gadget ( shape -- gadget )
|
||||||
[ [ resize-shape ] keep relayout ] ?resize ;
|
[ [ resize-shape ] keep relayout ] ?resize ;
|
||||||
|
|
||||||
: paint-prop ( gadget key -- value )
|
: paint-prop ( gadget key -- value )
|
||||||
swap gadget-paint hash ;
|
over [
|
||||||
|
dup pick gadget-paint hash* dup [
|
||||||
|
2nip cdr
|
||||||
|
] [
|
||||||
|
drop >r gadget-parent r> paint-prop
|
||||||
|
] ?ifte
|
||||||
|
] [
|
||||||
|
2drop f
|
||||||
|
] ifte ;
|
||||||
|
|
||||||
: set-paint-prop ( gadget value key -- )
|
: set-paint-prop ( gadget value key -- )
|
||||||
rot gadget-paint set-hash ;
|
rot gadget-paint set-hash ;
|
||||||
|
|
|
@ -9,8 +9,11 @@ TUPLE: label text ;
|
||||||
C: label ( text -- label )
|
C: label ( text -- label )
|
||||||
<empty-gadget> over set-delegate [ set-label-text ] keep ;
|
<empty-gadget> over set-delegate [ set-label-text ] keep ;
|
||||||
|
|
||||||
M: label pref-size label-text shape-size ;
|
: label-size ( gadget text -- w h )
|
||||||
|
>r font paint-prop r> size-string ;
|
||||||
|
|
||||||
|
M: label pref-size ( label -- w h )
|
||||||
|
dup label-text label-size ;
|
||||||
|
|
||||||
M: label draw-shape ( label -- )
|
M: label draw-shape ( label -- )
|
||||||
dup delegate draw-shape
|
[ label-text ] keep [ draw-string ] with-trans ;
|
||||||
dup shape-pos [ label-text draw-shape ] with-trans ;
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ SYMBOL: clip
|
||||||
: with-clip ( shape quot -- )
|
: with-clip ( shape quot -- )
|
||||||
#! All drawing done inside the quotation is clipped to the
|
#! All drawing done inside the quotation is clipped to the
|
||||||
#! shape's bounds. The quotation is called with a boolean
|
#! shape's bounds. The quotation is called with a boolean
|
||||||
#! that is set to false if
|
#! that is set to false if the gadget is entirely clipped.
|
||||||
[
|
[
|
||||||
>r screen-bounds clip [ intersect dup ] change set-clip
|
>r screen-bounds clip [ intersect dup ] change set-clip
|
||||||
r> call
|
r> call
|
||||||
|
@ -65,7 +65,7 @@ SYMBOL: clip
|
||||||
#! paint, just call the quotation.
|
#! paint, just call the quotation.
|
||||||
f over set-gadget-redraw?
|
f over set-gadget-redraw?
|
||||||
dup gadget-paint [
|
dup gadget-paint [
|
||||||
dup dup [
|
dup [
|
||||||
[
|
[
|
||||||
drop
|
drop
|
||||||
] [
|
] [
|
||||||
|
@ -74,5 +74,4 @@ SYMBOL: clip
|
||||||
] with-trans
|
] with-trans
|
||||||
] ifte
|
] ifte
|
||||||
] with-clip
|
] with-clip
|
||||||
surface get swap [ shape-x x get + ] keep [ shape-y y get + ] keep [ shape-w pick + 1 - ] keep shape-h pick + 1 - red rgb rectangleColor
|
|
||||||
] bind ;
|
] bind ;
|
||||||
|
|
|
@ -63,18 +63,7 @@ global [
|
||||||
swap *int swap *int
|
swap *int swap *int
|
||||||
] ifte ;
|
] ifte ;
|
||||||
|
|
||||||
global [ <namespace> fonts set ] bind
|
: draw-string ( text -- )
|
||||||
|
|
||||||
M: string shape-x drop 0 ;
|
|
||||||
M: string shape-y drop 0 ;
|
|
||||||
M: string shape-w
|
|
||||||
font get swap size-string ( h -) drop ;
|
|
||||||
|
|
||||||
M: string shape-h ( text -- h )
|
|
||||||
#! This is just the height of the current font.
|
|
||||||
drop font get lookup-font TTF_FontHeight ;
|
|
||||||
|
|
||||||
M: string draw-shape ( text -- )
|
|
||||||
dup empty? [
|
dup empty? [
|
||||||
drop
|
drop
|
||||||
] [
|
] [
|
||||||
|
@ -85,3 +74,5 @@ M: string draw-shape ( text -- )
|
||||||
[ >r x get y get r> draw-surface ] keep
|
[ >r x get y get r> draw-surface ] keep
|
||||||
SDL_FreeSurface
|
SDL_FreeSurface
|
||||||
] ifte ;
|
] ifte ;
|
||||||
|
|
||||||
|
global [ <namespace> fonts set ] bind
|
||||||
|
|
|
@ -70,11 +70,10 @@ TUPLE: tile original ;
|
||||||
C: tile ( child caption -- tile )
|
C: tile ( child caption -- tile )
|
||||||
[ f line-border swap set-delegate ] keep
|
[ f line-border swap set-delegate ] keep
|
||||||
[ >r tile-content r> add-gadget ] keep
|
[ >r tile-content r> add-gadget ] keep
|
||||||
[ tile-actions ] keep
|
[ tile-actions ] keep ;
|
||||||
dup delegate pref-size pick resize-gadget ;
|
|
||||||
|
|
||||||
M: tile pref-size shape-size ;
|
M: tile pref-size shape-size ;
|
||||||
|
|
||||||
: tile ( gadget title -- )
|
: tile ( gadget title -- )
|
||||||
#! Show the gadget in a new tile.
|
#! Show the gadget in a new tile.
|
||||||
<tile> world get add-gadget ;
|
<tile> [ world get add-gadget ] keep prefer ;
|
||||||
|
|
Loading…
Reference in New Issue