From aee589190b1e8911eda3565d0086ff721bd388e2 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 18 Nov 2008 14:10:21 -0600 Subject: [PATCH 1/5] Add signed-le> and signed-be> wordS --- basis/math/bitwise/bitwise.factor | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/basis/math/bitwise/bitwise.factor b/basis/math/bitwise/bitwise.factor index ad1907fcb0..afd83d4458 100644 --- a/basis/math/bitwise/bitwise.factor +++ b/basis/math/bitwise/bitwise.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: arrays kernel math math.functions sequences sequences.private words namespaces macros hints -combinators fry ; +combinators fry io.binary ; IN: math.bitwise ! utilities @@ -93,3 +93,11 @@ PRIVATE> : bit-count ( x -- n ) dup 0 < [ bitnot ] when (bit-count) ; inline + +! Signed byte array to integer conversion +: signed-le> ( bytes -- x ) + [ le> ] [ length 8 * 1- on-bits ] bi + 2dup > [ bitnot bitor ] [ drop ] if ; + +: signed-be> ( bytes -- x ) + signed-le> ; From f32908f502ebb82a1d807e6bb5ba19a65f87348f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 18 Nov 2008 14:10:31 -0600 Subject: [PATCH 2/5] Fix load-bitmap to work with negative height --- extra/graphics/bitmap/bitmap.factor | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/extra/graphics/bitmap/bitmap.factor b/extra/graphics/bitmap/bitmap.factor index 4d83300934..4c35e3d7d0 100755 --- a/extra/graphics/bitmap/bitmap.factor +++ b/extra/graphics/bitmap/bitmap.factor @@ -1,11 +1,11 @@ ! Copyright (C) 2007 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: alien arrays byte-arrays combinators summary -io.backend graphics.viewer io io.binary io.files kernel libc -math math.functions namespaces opengl opengl.gl prettyprint -sequences strings ui ui.gadgets.panes io.encodings.binary -accessors grouping ; +USING: alien arrays byte-arrays combinators summary io.backend +graphics.viewer io io.binary io.files kernel libc math +math.functions math.bitwise namespaces opengl opengl.gl +prettyprint sequences strings ui ui.gadgets.panes +io.encodings.binary accessors grouping ; IN: graphics.bitmap ! Currently can only handle 24bit bitmaps. @@ -56,8 +56,8 @@ M: bitmap-magic summary : parse-bitmap-header ( bitmap -- ) 4 read le> >>header-length - 4 read le> >>width - 4 read le> >>height + 4 read signed-le> >>width + 4 read signed-le> >>height 2 read le> >>planes 2 read le> >>bit-count 4 read le> >>compression From d0e53db5fc9415250170748d01e81fea8c48fb1c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 18 Nov 2008 14:15:38 -0600 Subject: [PATCH 3/5] Rendering tweaks --- basis/opengl/opengl.factor | 3 ++- basis/ui/gadgets/buttons/buttons.factor | 4 ++-- basis/ui/gadgets/editors/editors.factor | 2 +- basis/ui/gadgets/grid-lines/grid-lines.factor | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/basis/opengl/opengl.factor b/basis/opengl/opengl.factor index 21fe663c44..ecb4c4a08c 100644 --- a/basis/opengl/opengl.factor +++ b/basis/opengl/opengl.factor @@ -64,7 +64,8 @@ MACRO: all-enabled-client-state ( seq quot -- ) [ 2 GL_FLOAT 0 ] dip glTexCoordPointer ; inline : line-vertices ( a b -- ) - append >c-float-array gl-vertex-pointer ; + [ first2 [ 0.5 + ] bi@ ] bi@ 4 narray + >c-float-array gl-vertex-pointer ; : gl-line ( a b -- ) line-vertices GL_LINES 0 2 glDrawArrays ; diff --git a/basis/ui/gadgets/buttons/buttons.factor b/basis/ui/gadgets/buttons/buttons.factor index 11fb69fc7d..c975e64b12 100644 --- a/basis/ui/gadgets/buttons/buttons.factor +++ b/basis/ui/gadgets/buttons/buttons.factor @@ -111,8 +111,8 @@ TUPLE: checkmark-paint < caching-pen color last-vertices ; : checkmark-points ( dim -- points ) { - [ { 0 0 } v* { 0 1 } v+ ] - [ { 1 1 } v* { 0 1 } v+ ] + [ { 0 0 } v* ] + [ { 1 1 } v* ] [ { 0 1 } v* ] [ { 1 0 } v* ] } cleave 4array ; diff --git a/basis/ui/gadgets/editors/editors.factor b/basis/ui/gadgets/editors/editors.factor index 74647a6afb..2cf6d24154 100644 --- a/basis/ui/gadgets/editors/editors.factor +++ b/basis/ui/gadgets/editors/editors.factor @@ -112,7 +112,7 @@ M: editor ungraft* line-height * ; : caret-loc ( editor -- loc ) - [ editor-caret* ] keep 2dup loc>x 1+ + [ editor-caret* ] keep 2dup loc>x rot first rot line>y 2array ; : caret-dim ( editor -- dim ) diff --git a/basis/ui/gadgets/grid-lines/grid-lines.factor b/basis/ui/gadgets/grid-lines/grid-lines.factor index d7844e3fa3..adfdd16f69 100644 --- a/basis/ui/gadgets/grid-lines/grid-lines.factor +++ b/basis/ui/gadgets/grid-lines/grid-lines.factor @@ -27,7 +27,7 @@ M: grid-lines draw-boundary dup grid set dup rect-dim half-gap v- grid-dim set compute-grid - [ { 1 0 } draw-grid-lines ] + [ { -0.5 -0.5 } gl-translate { 1 0 } draw-grid-lines ] [ { 0.5 -0.5 } gl-translate { 0 1 } draw-grid-lines From 9fb6224e301a7bb2851169057da13e991457d730 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 18 Nov 2008 14:15:48 -0600 Subject: [PATCH 4/5] Add UI render test tool --- extra/ui/render/test/reference.bmp | Bin 0 -> 73554 bytes extra/ui/render/test/reference.bmp.2 | Bin 0 -> 89322 bytes extra/ui/render/test/test.factor | 70 +++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 extra/ui/render/test/reference.bmp create mode 100644 extra/ui/render/test/reference.bmp.2 create mode 100644 extra/ui/render/test/test.factor diff --git a/extra/ui/render/test/reference.bmp b/extra/ui/render/test/reference.bmp new file mode 100644 index 0000000000000000000000000000000000000000..0740fcc8173f0a6fc4fcfa76802b5146e5a7c59b GIT binary patch literal 73554 zcmeIwu?Ye}7=+RPx-bw-t-u1zO{~HGGvjlWD?&cr!Y&*a&CI($o|kRD=eF*3-S@h$ zb+?xW#gNHaszyq*OiTL2FeZaU0zo?xW#gNH zaszyq*OiTL2FeZaU0zo?xW#gNHaszyq*OiTL O2FeZaU0(OkvwZ-#zpe-X literal 0 HcmV?d00001 diff --git a/extra/ui/render/test/reference.bmp.2 b/extra/ui/render/test/reference.bmp.2 new file mode 100644 index 0000000000000000000000000000000000000000..630563a5c7d6bc7838e122b7207ff3ad83cf5102 GIT binary patch literal 89322 zcmeI5L6X}x5JlzkGP|50XYt-Q$TG_;vd&3nPUpQZp|HhJ`oa(xN@Am7_M0+Hh>!^2 z_kRsQQ!an|{`1c-C;Rz#Dt}Mq$5j5B%9qn0r?1oXpQ-)#-%gh@z5M^@d^*j4?Dctm z!rZi_e)-V(d^%Hx(cltL3o2y@4ZPWyY31)|1uV|SoOir={x*$!#3I^r^gk;Ad)t`k zl{;WB51A!<@9*!YT6ueWtG3lXqxboIUB88G*vrk{;sdUI)aT&-OIz9&eYh_T&q5SJAdv>W7S+^;ibREpL(1Eu-AvL7Duob=l{r_ zVGs5q{g=7#l07~5w{kUY`!UP9my^JfJ@o;6?Z;P3OU-wj_wsNEdwuw7v8VYC_F%8& z725XY754J*rZZ*T+n1wf@)CPab!478?8URkx|fGHohj_Wp8A1$KLub9_WHSvo>YO7 zJw1C^8^vD(_MGa-JoS=2^#R=Zb7vZ>=KPKU_Ta7$cd(a-wQ{Bwd(E|)gW<0af4a}t zSa|7QdVtq43cy|;zFHh)*1eq0kDqnP zo}T-yjpDBX>s~wu5hEzsQy;*cKX<0F<~zP?iJ%~+PuT0jS1XTczJt9O4kCJmJ=lxz z9ewgWXKOv`)yAGPCyA_kta~|~A3tl@gS~hc<{Sa+!Cp@1$IrTCPtP9KM)B8x?>XZ+ zh!{c1p85dp{JArYRdasF5J5pqpRm`5uT~y|y%_ID_X>OQ?CCzAbuXHTe*MEDC!Jw1C^8^vD(_MAN(KTcmId+GzY^XJYqR?Ybx z!#Hesj|BGm@YTv=RraRf&;LW)4p-U3czcTHZ&LvF;@Q)E{@uD~>^0Xt*z-mp?D??wYp_>a4_hBy#wGSP`ULU?%c}(-& zUX0bA1A8A32)hA$uoq^&CaJbUapb3zDv@$9kZggxU>ePFLC{u-#}wR75D_vc)j z)9a(ndXB}-U+M$6yXoSog=$`7?5_XGM0c;39J%rSXdcWu9*d#IThAV=@m=D~b>06@ z=mL8==_}b&AHd!K>)s_ZT6TP~NKVM<^zmj5dwuw7@lF z91-lrv#0xf*vrEq?8URUW!`SaNavIVfDF{?5Pjn&YwHeSo7VZ-<>@A{yE-tKhV-o0od!qS1XTc zzI&9VN8b;7{n+}fC)k6%&pblAj{>k4&mMbDA8(KTRM?AWk3Hw;l=zGf_I?faEKb)l zS>alL;=YfQcl^PUwE2)zwzz4$)d$y@uEm*q>;8X27u8&2 z!N1=d5}Dlw1$*)5J>BQm*xT#=9Pi!i!-HN>0QTb9+p_M#-U}ul^rNr`dxKi@@WX;V z*gL$*2c017!QPKA|Gskptvt2CUH??7?2c9yB>B0DJN5vFCI&_`r{by?FMv>^Ut? z*E0F(T7TmHz;;YEv^Dn33rn$_{8@czU%T@8ZTc-N)y{QG`{fFIhhVg1?=HrgQ>m}7 zH9PC_fj#4Fk0RqdgmDir3D}dpocJ>;2i>tZz<8o`$kOjlnRSos%rmA{&eM1Q0k)Uf A1ONa4 literal 0 HcmV?d00001 diff --git a/extra/ui/render/test/test.factor b/extra/ui/render/test/test.factor new file mode 100644 index 0000000000..01b5b65bcf --- /dev/null +++ b/extra/ui/render/test/test.factor @@ -0,0 +1,70 @@ +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors colors arrays kernel sequences math byte-arrays +namespaces cap graphics.bitmap +ui.gadgets ui.gadgets.packs ui.gadgets.borders ui.gadgets.grids +ui.gadgets.grid-lines ui.gadgets.labels ui.gadgets.buttons +ui.render ui opengl opengl.gl ; +IN: ui.render.test + +SINGLETON: line-test + +M: line-test draw-interior + 2drop { 0 0 } { 0 10 } gl-line ; + +: ( -- gadget ) + + line-test >>interior + { 1 10 } >>dim ; + +TUPLE: ui-render-test < pack { first-time? initial: t } ; + +: message-window ( text -- ) +