Merge branch 'master' of git://factorcode.org/git/factor

db4
Doug Coleman 2008-11-18 15:12:31 -06:00
commit 1f85c444b7
8 changed files with 92 additions and 13 deletions

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: arrays kernel math math.functions sequences USING: arrays kernel math math.functions sequences
sequences.private words namespaces macros hints sequences.private words namespaces macros hints
combinators fry ; combinators fry io.binary ;
IN: math.bitwise IN: math.bitwise
! utilities ! utilities
@ -93,3 +93,11 @@ PRIVATE>
: bit-count ( x -- n ) : bit-count ( x -- n )
dup 0 < [ bitnot ] when (bit-count) ; inline 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 )
<reversed> signed-le> ;

View File

@ -64,7 +64,8 @@ MACRO: all-enabled-client-state ( seq quot -- )
[ 2 GL_FLOAT 0 ] dip glTexCoordPointer ; inline [ 2 GL_FLOAT 0 ] dip glTexCoordPointer ; inline
: line-vertices ( a b -- ) : 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 -- ) : gl-line ( a b -- )
line-vertices GL_LINES 0 2 glDrawArrays ; line-vertices GL_LINES 0 2 glDrawArrays ;

View File

@ -111,8 +111,8 @@ TUPLE: checkmark-paint < caching-pen color last-vertices ;
: checkmark-points ( dim -- points ) : checkmark-points ( dim -- points )
{ {
[ { 0 0 } v* { 0 1 } v+ ] [ { 0 0 } v* ]
[ { 1 1 } v* { 0 1 } v+ ] [ { 1 1 } v* ]
[ { 0 1 } v* ] [ { 0 1 } v* ]
[ { 1 0 } v* ] [ { 1 0 } v* ]
} cleave 4array ; } cleave 4array ;

View File

@ -112,7 +112,7 @@ M: editor ungraft*
line-height * ; line-height * ;
: caret-loc ( editor -- loc ) : caret-loc ( editor -- loc )
[ editor-caret* ] keep 2dup loc>x 1+ [ editor-caret* ] keep 2dup loc>x
rot first rot line>y 2array ; rot first rot line>y 2array ;
: caret-dim ( editor -- dim ) : caret-dim ( editor -- dim )

View File

@ -27,7 +27,7 @@ M: grid-lines draw-boundary
dup grid set dup grid set
dup rect-dim half-gap v- grid-dim set dup rect-dim half-gap v- grid-dim set
compute-grid 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.5 -0.5 } gl-translate
{ 0 1 } draw-grid-lines { 0 1 } draw-grid-lines

View File

@ -1,11 +1,11 @@
! Copyright (C) 2007 Doug Coleman. ! Copyright (C) 2007 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien arrays byte-arrays combinators summary USING: alien arrays byte-arrays combinators summary io.backend
io.backend graphics.viewer io io.binary io.files kernel libc graphics.viewer io io.binary io.files kernel libc math
math math.functions namespaces opengl opengl.gl prettyprint math.functions math.bitwise namespaces opengl opengl.gl
sequences strings ui ui.gadgets.panes io.encodings.binary prettyprint sequences strings ui ui.gadgets.panes
accessors grouping ; io.encodings.binary accessors grouping ;
IN: graphics.bitmap IN: graphics.bitmap
! Currently can only handle 24bit bitmaps. ! Currently can only handle 24bit bitmaps.
@ -56,8 +56,8 @@ M: bitmap-magic summary
: parse-bitmap-header ( bitmap -- ) : parse-bitmap-header ( bitmap -- )
4 read le> >>header-length 4 read le> >>header-length
4 read le> >>width 4 read signed-le> >>width
4 read le> >>height 4 read signed-le> >>height
2 read le> >>planes 2 read le> >>planes
2 read le> >>bit-count 2 read le> >>bit-count
4 read le> >>compression 4 read le> >>compression

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

View File

@ -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 ;
: <line-gadget> ( -- gadget )
<gadget>
line-test >>interior
{ 1 10 } >>dim ;
TUPLE: ui-render-test < pack { first-time? initial: t } ;
: message-window ( text -- )
<label> "Message" open-window ;
: check-rendering ( gadget -- )
gl-screenshot
"resource:extra/ui/render/test/reference.bmp" load-bitmap array>>
= "perfect" "needs work" ? "Your UI rendering is " prepend
message-window ;
M: ui-render-test draw-gadget*
[ call-next-method ] [
dup first-time?>> [
dup check-rendering
f >>first-time?
] when
drop
] bi ;
: <ui-render-test> ( -- gadget )
\ ui-render-test new-gadget
{ 1 0 } >>orientation
<gadget>
black <solid> >>interior
{ 98 98 } >>dim
1 <border> add-gadget
<gadget>
gray <solid> >>boundary
{ 94 94 } >>dim
3 <border>
red <solid> >>boundary
add-gadget
<line-gadget> <line-gadget> <line-gadget> 3array
<line-gadget> <line-gadget> <line-gadget> 3array
<line-gadget> <line-gadget> <line-gadget> 3array
3array <grid>
{ 5 5 } >>gap
blue <grid-lines> >>boundary
add-gadget
<gadget>
{ 14 14 } >>dim
black <checkmark-paint> >>interior
black <solid> >>boundary
4 <border>
add-gadget ;
: ui-render-test ( -- )
<ui-render-test> "Test" open-window ;
MAIN: ui-render-test