diff --git a/basis/help/lint/lint.factor b/basis/help/lint/lint.factor index 57f64459c8..2281c295c3 100755 --- a/basis/help/lint/lint.factor +++ b/basis/help/lint/lint.factor @@ -132,6 +132,11 @@ SYMBOL: vocabs-quot [ check-descriptions ] } cleave ; +: check-class-description ( word element -- ) + [ class? not ] + [ { $class-description } swap elements empty? not ] bi* and + [ "A word that is not a class has a $class-description" throw ] when ; + : all-word-help ( words -- seq ) [ word-help ] filter ; @@ -153,7 +158,8 @@ M: help-error error. dup '[ _ dup word-help [ check-values ] - [ nip [ check-nulls ] [ check-see-also ] [ check-markup ] tri ] 2bi + [ check-class-description ] + [ nip [ check-nulls ] [ check-see-also ] [ check-markup ] tri ] 2tri ] check-something ] [ drop ] if ; diff --git a/basis/images/bitmap/bitmap.factor b/basis/images/bitmap/bitmap.factor index 88eb984488..cf16df7d82 100755 --- a/basis/images/bitmap/bitmap.factor +++ b/basis/images/bitmap/bitmap.factor @@ -108,11 +108,6 @@ M: bitmap-image load-image* ( path bitmap -- bitmap ) load-bitmap-data process-bitmap-data fill-image-slots ; -M: bitmap-image normalize-scan-line-order - dup dim>> '[ - _ first 4 * reverse concat - ] change-bitmap ; - MACRO: (nbits>bitmap) ( bits -- ) [ -3 shift ] keep '[ bitmap-image new @@ -121,6 +116,7 @@ MACRO: (nbits>bitmap) ( bits -- ) swap >>width swap array-copy [ >>bitmap ] [ >>color-index ] bi _ >>bit-count fill-image-slots + t >>upside-down? ] ; : bgr>bitmap ( array height width -- bitmap ) diff --git a/basis/images/images.factor b/basis/images/images.factor index 82576774f4..cb44825e62 100644 --- a/basis/images/images.factor +++ b/basis/images/images.factor @@ -27,7 +27,7 @@ R16G16B16 R32G32B32 R16G16B16A16 R32G32B32A32 ; { R32G32B32A32 [ 16 ] } } case ; -TUPLE: image dim component-order bitmap ; +TUPLE: image dim component-order upside-down? bitmap ; : ( -- image ) image new ; inline @@ -82,11 +82,16 @@ M: ARGB normalize-component-order* M: ABGR normalize-component-order* drop ARGB>RGBA 4 BGR>RGB ; -GENERIC: normalize-scan-line-order ( image -- image ) - -M: image normalize-scan-line-order ; +: normalize-scan-line-order ( image -- image ) + dup upside-down?>> [ + dup dim>> first 4 * '[ + _ reverse concat + ] change-bitmap + f >>upside-down? + ] when ; : normalize-image ( image -- image ) [ >byte-array ] change-bitmap normalize-component-order - normalize-scan-line-order ; + normalize-scan-line-order + RGBA >>component-order ; diff --git a/basis/images/tiff/tiff.factor b/basis/images/tiff/tiff.factor index a50ac0cad9..2ea1b08e20 100755 --- a/basis/images/tiff/tiff.factor +++ b/basis/images/tiff/tiff.factor @@ -503,7 +503,7 @@ ERROR: unknown-component-order ifd ; : ifd>image ( ifd -- image ) { [ [ image-width find-tag ] [ image-length find-tag ] bi 2array ] - [ ifd-component-order ] + [ ifd-component-order f ] [ bitmap>> ] } cleave tiff-image boa ; diff --git a/basis/opengl/textures/textures.factor b/basis/opengl/textures/textures.factor index 79af9be48b..48cdafb837 100644 --- a/basis/opengl/textures/textures.factor +++ b/basis/opengl/textures/textures.factor @@ -11,14 +11,16 @@ IN: opengl.textures TUPLE: texture loc dim texture-coords texture display-list disposed ; -format ( component-order -- format type ) +M: RGB component-order>format drop GL_RGB GL_UNSIGNED_BYTE ; +M: BGR component-order>format drop GL_BGR GL_UNSIGNED_BYTE ; M: RGBA component-order>format drop GL_RGBA GL_UNSIGNED_BYTE ; M: ARGB component-order>format drop GL_BGRA_EXT GL_UNSIGNED_INT_8_8_8_8_REV ; M: BGRA component-order>format drop GL_BGRA_EXT GL_UNSIGNED_BYTE ; +> focusable-child resend-gesture ; : show-popup ( owner popup visible-rect -- ) diff --git a/basis/ui/gadgets/menus/menus-docs.factor b/basis/ui/gadgets/menus/menus-docs.factor index d7297217ed..ad0881a382 100644 --- a/basis/ui/gadgets/menus/menus-docs.factor +++ b/basis/ui/gadgets/menus/menus-docs.factor @@ -16,7 +16,7 @@ HELP: show-commands-menu { $notes "Useful for right-click context menus." } ; ARTICLE: "ui.gadgets.menus" "Popup menus" -"The " { $vocab-link "ui.gadgets.menus" } " vocabulary implements popup menus." +"The " { $vocab-link "ui.gadgets.menus" } " vocabulary displays popup menus in " { $link "ui.gadgets.glass" } "." { $subsection } { $subsection show-menu } { $subsection show-commands-menu } ; diff --git a/basis/ui/gadgets/status-bar/status-bar-docs.factor b/basis/ui/gadgets/status-bar/status-bar-docs.factor index f5a6409fca..57c69c2a66 100644 --- a/basis/ui/gadgets/status-bar/status-bar-docs.factor +++ b/basis/ui/gadgets/status-bar/status-bar-docs.factor @@ -3,7 +3,7 @@ ui.gadgets ui.gadgets.worlds ui ; IN: ui.gadgets.status-bar HELP: show-status -{ $values { "string" string } { "gadget" gadget } } +{ $values { "string/f" string } { "gadget" gadget } } { $description "Displays a status message in the gadget's world." } { $notes "The status message will only be visible if the window was opened with " { $link open-status-window } ", and not " { $link open-window } "." } ; diff --git a/basis/ui/pens/gradient/gradient.factor b/basis/ui/pens/gradient/gradient.factor index a137ae022b..485015b898 100644 --- a/basis/ui/pens/gradient/gradient.factor +++ b/basis/ui/pens/gradient/gradient.factor @@ -41,4 +41,6 @@ M: gradient draw-interior [ last-vertices>> gl-vertex-pointer ] [ last-colors>> gl-color-pointer ] [ colors>> draw-gradient ] - } cleave ; \ No newline at end of file + } cleave ; + +M: gradient pen-background 2drop transparent ; \ No newline at end of file diff --git a/basis/ui/pens/solid/solid.factor b/basis/ui/pens/solid/solid.factor index 32d400463e..950035e773 100644 --- a/basis/ui/pens/solid/solid.factor +++ b/basis/ui/pens/solid/solid.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel accessors opengl ui.pens ui.pens.caching ; +USING: kernel accessors opengl math colors ui.pens ui.pens.caching ; IN: ui.pens.solid TUPLE: solid < caching-pen color interior-vertices boundary-vertices ; @@ -29,4 +29,4 @@ M: solid draw-boundary (gl-rect) ; M: solid pen-background - nip color>> ; \ No newline at end of file + nip color>> dup alpha>> 1 number= [ drop transparent ] unless ; \ No newline at end of file diff --git a/basis/ui/ui-docs.factor b/basis/ui/ui-docs.factor index d08dea299e..f2b6154745 100644 --- a/basis/ui/ui-docs.factor +++ b/basis/ui/ui-docs.factor @@ -171,6 +171,7 @@ ARTICLE: "ui-layouts" "Gadget hierarchy and layouts" { $subsection "ui-frame-layout" } { $subsection "ui-book-layout" } "Advanced topics:" +{ $subsection "ui.gadgets.glass" } { $subsection "ui-null-layout" } { $subsection "ui-incremental-layout" } { $subsection "ui-layout-impl" } diff --git a/extra/cap/cap.factor b/extra/cap/cap.factor index 1f62441028..64696759bb 100644 --- a/extra/cap/cap.factor +++ b/extra/cap/cap.factor @@ -1,30 +1,31 @@ ! Copyright (C) 2008 Doug Coleman, Joe Groff. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays byte-arrays kernel math namespaces -opengl.gl sequences math.vectors ui images.bitmap images.viewer +opengl.gl sequences math.vectors ui images images.viewer models ui.gadgets.worlds ui.gadgets fry alien.syntax ; IN: cap : screenshot-array ( world -- byte-array ) - dim>> [ first 3 * 4 align ] [ second ] bi * ; + dim>> [ first 4 * ] [ second ] bi * ; : gl-screenshot ( gadget -- byte-array ) [ - GL_BACK glReadBuffer - GL_PACK_ALIGNMENT 4 glPixelStorei - 0 0 - ] dip - [ dim>> first2 GL_BGR GL_UNSIGNED_BYTE ] + [ + GL_BACK glReadBuffer + GL_PACK_ALIGNMENT 4 glPixelStorei + 0 0 + ] dip + dim>> first2 GL_RGBA GL_UNSIGNED_BYTE + ] [ screenshot-array ] bi [ glReadPixels ] keep ; : screenshot ( window -- bitmap ) - [ gl-screenshot ] - [ dim>> first2 ] bi - bgr>bitmap ; - -: save-screenshot ( window path -- ) - [ screenshot ] dip save-bitmap ; + [ ] dip + [ gl-screenshot >>bitmap ] [ dim>> >>dim ] bi + RGBA >>component-order + t >>upside-down? + normalize-image ; : screenshot. ( window -- ) [ screenshot ] [ title>> ] bi open-window ; diff --git a/extra/images/viewer/viewer.factor b/extra/images/viewer/viewer.factor index b920b60430..4eaa984953 100644 --- a/extra/images/viewer/viewer.factor +++ b/extra/images/viewer/viewer.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2007 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors images images.loader io.pathnames kernel -namespaces opengl opengl.gl sequences strings ui ui.gadgets +USING: accessors images images.loader io.pathnames kernel namespaces +opengl opengl.gl opengl.textures sequences strings ui ui.gadgets ui.gadgets.panes ui.render ; IN: images.viewer @@ -12,8 +12,8 @@ M: image-gadget pref-dim* : draw-image ( image -- ) 0 0 glRasterPos2i 1.0 -1.0 glPixelZoom - [ dim>> first2 GL_RGBA GL_UNSIGNED_BYTE ] - [ bitmap>> ] bi glDrawPixels ; + [ dim>> first2 ] [ component-order>> component-order>format ] [ bitmap>> ] tri + glDrawPixels ; M: image-gadget draw-gadget* ( gadget -- ) image>> draw-image ; diff --git a/extra/otug-talk/2bi.png b/extra/otug-talk/2bi.png deleted file mode 100644 index 8f431f87ce..0000000000 Binary files a/extra/otug-talk/2bi.png and /dev/null differ diff --git a/extra/otug-talk/2bi.tiff b/extra/otug-talk/2bi.tiff new file mode 100644 index 0000000000..16c0777254 Binary files /dev/null and b/extra/otug-talk/2bi.tiff differ diff --git a/extra/otug-talk/2bi_at.png b/extra/otug-talk/2bi_at.png deleted file mode 100644 index 55d42c2a4c..0000000000 Binary files a/extra/otug-talk/2bi_at.png and /dev/null differ diff --git a/extra/otug-talk/2bi_at.tiff b/extra/otug-talk/2bi_at.tiff new file mode 100644 index 0000000000..e41ab98eeb Binary files /dev/null and b/extra/otug-talk/2bi_at.tiff differ diff --git a/extra/otug-talk/2bi_star.png b/extra/otug-talk/2bi_star.png deleted file mode 100644 index 0fff37624b..0000000000 Binary files a/extra/otug-talk/2bi_star.png and /dev/null differ diff --git a/extra/otug-talk/2bi_star.tiff b/extra/otug-talk/2bi_star.tiff new file mode 100644 index 0000000000..f457ce5481 Binary files /dev/null and b/extra/otug-talk/2bi_star.tiff differ diff --git a/extra/otug-talk/bi.png b/extra/otug-talk/bi.png deleted file mode 100644 index 2470c9fab1..0000000000 Binary files a/extra/otug-talk/bi.png and /dev/null differ diff --git a/extra/otug-talk/bi.tiff b/extra/otug-talk/bi.tiff new file mode 100644 index 0000000000..ad0ce97cc0 Binary files /dev/null and b/extra/otug-talk/bi.tiff differ diff --git a/extra/otug-talk/bi_at.png b/extra/otug-talk/bi_at.png deleted file mode 100644 index 282f2f118d..0000000000 Binary files a/extra/otug-talk/bi_at.png and /dev/null differ diff --git a/extra/otug-talk/bi_at.tiff b/extra/otug-talk/bi_at.tiff new file mode 100644 index 0000000000..07d25bcd01 Binary files /dev/null and b/extra/otug-talk/bi_at.tiff differ diff --git a/extra/otug-talk/bi_star.png b/extra/otug-talk/bi_star.png deleted file mode 100644 index e94e3710cf..0000000000 Binary files a/extra/otug-talk/bi_star.png and /dev/null differ diff --git a/extra/otug-talk/bi_star.tiff b/extra/otug-talk/bi_star.tiff new file mode 100644 index 0000000000..17f3350b51 Binary files /dev/null and b/extra/otug-talk/bi_star.tiff differ diff --git a/extra/otug-talk/otug-talk.factor b/extra/otug-talk/otug-talk.factor index 16ee2b740b..2ce307ce20 100644 --- a/extra/otug-talk/otug-talk.factor +++ b/extra/otug-talk/otug-talk.factor @@ -1,41 +1,14 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: slides help.markup math arrays hashtables namespaces -sequences kernel sequences parser memoize io.encodings.binary -locals kernel.private tools.vocabs.browser assocs quotations - tools.vocabs tools.annotations tools.crossref -help.topics math.functions compiler.tree.optimizer -compiler.cfg.optimizer fry -ui.gadgets.panes tetris tetris.game combinators generalizations -multiline sequences.private ; +USING: slides help.markup math arrays hashtables namespaces sequences +kernel sequences parser memoize io.encodings.binary locals +kernel.private tools.vocabs.browser assocs quotations tools.vocabs +tools.annotations tools.crossref help.topics math.functions +compiler.tree.optimizer compiler.cfg.optimizer fry ui.gadgets.panes +tetris tetris.game combinators generalizations multiline +sequences.private ; IN: otug-talk -USING: cairo cairo.ffi cairo.gadgets accessors -io.backend ui.gadgets ; - -TUPLE: png-gadget < cairo-gadget surface ; - -: ( file -- gadget ) - png-gadget new-gadget - swap normalize-path - cairo_image_surface_create_from_png >>surface ; inline - -M: png-gadget pref-dim* ( gadget -- ) - surface>> - [ cairo_image_surface_get_width ] - [ cairo_image_surface_get_height ] - bi 2array ; - -M: png-gadget render-cairo* ( gadget -- ) - cr swap surface>> 0 0 cairo_set_source_surface - cr cairo_paint ; - -M: png-gadget ungraft* ( gadget -- ) - surface>> cairo_surface_destroy ; - -: $bitmap ( element -- ) - [ first gadget. ] ($block) ; - : $tetris ( element -- ) drop [ gadget. ] ($block) ; @@ -105,11 +78,11 @@ CONSTANT: otug-slides } { $slide "Data flow combinators - cleave family" { { $link bi } ", " { $link tri } ", " { $link cleave } } - { $bitmap "resource:extra/otug-talk/bi.png" } + { $image "resource:extra/otug-talk/bi.tiff" } } { $slide "Data flow combinators - cleave family" { { $link 2bi } ", " { $link 2tri } ", " { $link 2cleave } } - { $bitmap "resource:extra/otug-talk/2bi.png" } + { $image "resource:extra/otug-talk/2bi.tiff" } } { $slide "Data flow combinators" "First, let's define a data type:" @@ -128,19 +101,19 @@ CONSTANT: otug-slides } { $slide "Data flow combinators - spread family" { { $link bi* } ", " { $link tri* } ", " { $link spread } } - { $bitmap "resource:extra/otug-talk/bi_star.png" } + { $image "resource:extra/otug-talk/bi_star.tiff" } } { $slide "Data flow combinators - spread family" { { $link 2bi* } } - { $bitmap "resource:extra/otug-talk/2bi_star.png" } + { $image "resource:extra/otug-talk/2bi_star.tiff" } } { $slide "Data flow combinators - apply family" { { $link bi@ } ", " { $link tri@ } ", " { $link napply } } - { $bitmap "resource:extra/otug-talk/bi_at.png" } + { $image "resource:extra/otug-talk/bi_at.tiff" } } { $slide "Data flow combinators - apply family" { { $link 2bi@ } } - { $bitmap "resource:extra/otug-talk/2bi_at.png" } + { $image "resource:extra/otug-talk/2bi_at.tiff" } } { $slide "Shuffle words" "When data flow combinators are not enough" diff --git a/extra/slides/slides.factor b/extra/slides/slides.factor index 6a5b7ab816..752d0b3ffa 100755 --- a/extra/slides/slides.factor +++ b/extra/slides/slides.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: arrays hashtables help.markup help.stylesheet io io.styles kernel math models namespaces sequences ui ui.gadgets -ui.gadgets.books ui.gadgets.panes ui.gestures ui.pens.gradient ui.render +ui.gadgets.books ui.gadgets.panes ui.gestures ui.pens.gradient parser accessors colors ; IN: slides @@ -98,6 +98,7 @@ TUPLE: slides < book ; parse-definition strip-tease [ parsed ] each ; parsing \ slides H{ + { T{ button-down } [ request-focus ] } { T{ key-down f f "DOWN" } [ next-page ] } { T{ key-down f f "UP" } [ prev-page ] } } set-gestures diff --git a/extra/tetris/gl/gl.factor b/extra/tetris/gl/gl.factor index 70300779b5..f8c901ff56 100644 --- a/extra/tetris/gl/gl.factor +++ b/extra/tetris/gl/gl.factor @@ -35,7 +35,7 @@ IN: tetris.gl : scale-board ( width height board -- ) [ width>> ] [ height>> ] bi swapd [ / ] dup 2bi* 1 glScalef ; -: (draw-tetris) ( width height tetris -- ) +: draw-tetris ( width height tetris -- ) #! width and height are in pixels GL_MODELVIEW [ { @@ -44,7 +44,4 @@ IN: tetris.gl [ next-piece draw-next-piece ] [ current-piece draw-piece ] } cleave - ] do-matrix ; - -: draw-tetris ( width height tetris -- ) - origin get [ (draw-tetris) ] with-translation ; + ] do-matrix ; \ No newline at end of file