From 3d56615d1952322aeb2a82c607e0a04623724084 Mon Sep 17 00:00:00 2001 From: Alexander Iljin Date: Sat, 1 Jun 2019 09:27:41 +0200 Subject: [PATCH 1/8] Revert "slides: fix illegible code snippets on Windows" This reverts commit 4b1e2b8af856c049fd07d86737a7b648648e2a41. --- extra/slides/slides.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/slides/slides.factor b/extra/slides/slides.factor index 26c2db0999..21fed8c67f 100644 --- a/extra/slides/slides.factor +++ b/extra/slides/slides.factor @@ -27,7 +27,7 @@ CONSTANT: stylesheet } { code-style H{ - { page-color T{ rgba f 0.9 0.9 0.9 1 } } + { page-color T{ rgba f 0.4 0.4 0.4 0.3 } } } } { snippet-style From 74313e9b5244af4666aec5ec0981fdbd50fa2e09 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Mon, 17 Aug 2015 09:43:54 -0700 Subject: [PATCH 2/8] Revert "slides: make it work on windows (no gradients)." This reverts commit 9d428cbcaf22e3f7bb65c20815dd97a4d2af9e40. --- extra/slides/slides.factor | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/extra/slides/slides.factor b/extra/slides/slides.factor index 21fed8c67f..89129667e5 100644 --- a/extra/slides/slides.factor +++ b/extra/slides/slides.factor @@ -57,35 +57,23 @@ CONSTANT: stylesheet } format ] ($block) ; -: divider-interior ( -- interior ) - os windows? [ - T{ rgba f 0.25 0.25 0.25 1.0 } - ] [ { - T{ rgba f 0.25 0.25 0.25 1.0 } - T{ rgba f 1.0 1.0 1.0 0.0 } - } - ] if ; - : $divider ( -- ) [ - divider-interior >>interior + { + T{ rgba f 0.25 0.25 0.25 1.0 } + T{ rgba f 1.0 1.0 1.0 0.0 } + } >>interior ${ default-font-size 67 * default-font-size 5/6 * } >>dim { 1 0 } >>orientation gadget. ] ($block) ; -: page-interior ( -- interior ) - os windows? [ - T{ rgba f 0.8 0.8 1.0 1.0 } - ] [ { - T{ rgba f 0.8 0.8 1.0 1.0 } - T{ rgba f 0.8 1.0 1.0 1.0 } - } - ] if ; - : page-theme ( gadget -- gadget ) - page-interior >>interior ; + { + T{ rgba f 0.8 0.8 1.0 1.0 } + T{ rgba f 0.8 1.0 1.0 1.0 } + } >>interior ; : ( list -- gadget ) [ From 7ad6784911fe0b22fd273437263dff53fcc37d6e Mon Sep 17 00:00:00 2001 From: Alexander Iljin Date: Sat, 1 Jun 2019 09:36:22 +0200 Subject: [PATCH 3/8] Revert "ui.gadgets.buttons: workaround for windows gradient bug" This reverts commit 20a663ab0b2d9cca63e48cc144047e6495b80f44. --- basis/ui/gadgets/buttons/buttons.factor | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/basis/ui/gadgets/buttons/buttons.factor b/basis/ui/gadgets/buttons/buttons.factor index adcaa1a445..c7609dbe06 100644 --- a/basis/ui/gadgets/buttons/buttons.factor +++ b/basis/ui/gadgets/buttons/buttons.factor @@ -1,11 +1,10 @@ ! Copyright (C) 2005, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs colors colors.constants combinators -combinators.short-circuit combinators.smart fry kernel locals -math.vectors memoize models namespaces sequences system -ui.commands ui.gadgets ui.gadgets.borders ui.gadgets.labels -ui.gadgets.packs ui.gadgets.worlds ui.gestures ui.pens -ui.pens.image ui.pens.solid ui.pens.tile ui.theme +USING: accessors assocs colors combinators combinators.short-circuit +combinators.smart fry kernel locals math.vectors memoize models +namespaces sequences ui.commands ui.gadgets ui.gadgets.borders +ui.gadgets.labels ui.gadgets.packs ui.theme ui.gadgets.worlds +ui.gestures ui.pens ui.pens.image ui.pens.solid ui.pens.tile ui.theme.images ; FROM: models => change-model ; IN: ui.gadgets.buttons @@ -129,7 +128,7 @@ PRIVATE> ] 2dip ; : ( -- pen ) - "button" os windows? [ COLOR: grey95 ] [ transparent ] if button-text-color + "button" transparent button-text-color dup "button-clicked" transparent button-clicked-text-color dup dup From a3b439047f8ea1fe2abf8b26ca912b8b1a7f71e3 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Sun, 16 Aug 2015 08:04:58 -0700 Subject: [PATCH 4/8] Revert "ui.gadgets.labeled: separate title-bar-interior with a comment why." This reverts commit cb575c1ba86d07e6dd40788c9081fba01501f8ce. --- basis/ui/gadgets/labeled/labeled.factor | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/basis/ui/gadgets/labeled/labeled.factor b/basis/ui/gadgets/labeled/labeled.factor index ce9daeaae6..d5412bd3da 100644 --- a/basis/ui/gadgets/labeled/labeled.factor +++ b/basis/ui/gadgets/labeled/labeled.factor @@ -11,16 +11,13 @@ TUPLE: labeled-gadget < track content ; M: labeled-gadget focusable-child* content>> ; -! gradients don't work as backgrounds on windows, see #152 and #1397 -: title-bar-interior ( -- interior ) +: ( title -- title-bar ) + >label [ t >>bold? ] change-font + { 0 4 } os windows? [ toolbar-background ] [ title-bar-gradient ] - if ; - -: ( title -- title-bar ) - >label [ t >>bold? ] change-font - { 0 4 } title-bar-interior >>interior ; + if >>interior ; PRIVATE> From f84cfc720956d0ee6a682198d126d5da10fcabd8 Mon Sep 17 00:00:00 2001 From: nicolas-p Date: Sun, 16 Aug 2015 11:14:24 +0200 Subject: [PATCH 5/8] Revert "ui.gadgets.labeled: flat colour on windows because of the gradient bug" This reverts commit b81a5f9c7a13f11119dfbf53a5574201b35510be. --- basis/ui/gadgets/labeled/labeled.factor | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/basis/ui/gadgets/labeled/labeled.factor b/basis/ui/gadgets/labeled/labeled.factor index d5412bd3da..15eee9d44e 100644 --- a/basis/ui/gadgets/labeled/labeled.factor +++ b/basis/ui/gadgets/labeled/labeled.factor @@ -14,10 +14,7 @@ M: labeled-gadget focusable-child* content>> ; : ( title -- title-bar ) >label [ t >>bold? ] change-font { 0 4 } - os windows? - [ toolbar-background ] - [ title-bar-gradient ] - if >>interior ; + title-bar-gradient >>interior ; PRIVATE> From f445b44af6421fb4b0d7d920ca8bbe536032ee36 Mon Sep 17 00:00:00 2001 From: Alexander Iljin Date: Sun, 2 Jun 2019 01:42:50 +0200 Subject: [PATCH 6/8] windows.uniscribe: support text with transparent background This fixes issues #152 and #1658. --- basis/windows/uniscribe/uniscribe.factor | 36 +++++++++++++++++++----- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/basis/windows/uniscribe/uniscribe.factor b/basis/windows/uniscribe/uniscribe.factor index 1c6c78ff53..5e7635a199 100644 --- a/basis/windows/uniscribe/uniscribe.factor +++ b/basis/windows/uniscribe/uniscribe.factor @@ -1,10 +1,11 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.c-types alien.data arrays assocs cache -classes.struct combinators destructors fonts init io.encodings.string -io.encodings.utf16n kernel literals locals math namespaces sequences -windows.errors windows.fonts windows.gdi32 windows.offscreen -windows.ole32 windows.types windows.usp10 ; +classes.struct colors colors.constants combinators destructors +fonts images init io.encodings.string io.encodings.utf16n kernel +literals locals math namespaces sequences windows.errors +windows.fonts windows.gdi32 windows.offscreen windows.ole32 +windows.types windows.usp10 ; IN: windows.uniscribe TUPLE: script-string < disposable font string metrics ssa size image ; @@ -48,8 +49,17 @@ CONSTANT: ssa-dwFlags flags{ SSA_GLYPHS SSA_FALLBACK SSA_TAB } [ check-ole32-error ] [ |ScriptStringFree void* deref ] bi* ; : set-dc-colors ( dc font -- ) - [ background>> color>RGB SetBkColor drop ] - [ foreground>> color>RGB SetTextColor drop ] 2bi ; + dup background>> >rgba alpha>> 1 number= [ + ! No transparency needed, set colors from the font. + [ background>> color>RGB SetBkColor drop ] + [ foreground>> color>RGB SetTextColor drop ] 2bi + ] [ + ! Draw white text on black background. The resulting grayscale + ! image will be used as transparency mask for the actual color. + drop + [ COLOR: black color>RGB SetBkColor drop ] + [ COLOR: white color>RGB SetTextColor drop ] bi + ] if ; : selection-start/end ( script-string -- iMinSel iMaxSel ) string>> dup selection? [ [ start>> ] [ end>> ] bi ] [ drop 0 0 ] if ; @@ -67,10 +77,22 @@ CONSTANT: ssa-dwFlags flags{ SSA_GLYPHS SSA_FALLBACK SSA_TAB } FALSE ! fDisabled ScriptStringOut check-ole32-error ; +! The image is a grayscale rendering of a text string. We want the text to +! have the given color. Move the blue channel of the image (any color +! channel will do, since it's grayscale) into its alpha channel, and make +! the entire image a rectangle of the given color with varying +! transparency. +:: color-to-alpha ( image color -- image' ) + image color >rgba-components drop [ 255 * >integer ] tri@ 3array [ + swap first suffix -rot image set-pixel-at + ] curry each-pixel image RGBA >>component-order ; + :: render-image ( dc ssa script-string -- image ) script-string size>> :> size size dc - [ ssa size script-string draw-script-string ] make-bitmap-image ; + [ ssa size script-string draw-script-string ] make-bitmap-image + script-string font>> [ foreground>> ] [ background>> ] bi + >rgba alpha>> 1 number= [ drop ] [ color-to-alpha ] if ; : set-dc-font ( dc font -- ) cache-font SelectObject win32-error=0/f ; From 3d56183360a94ea3fa12033d0a168d33138b3228 Mon Sep 17 00:00:00 2001 From: Alexander Iljin Date: Sat, 8 Jun 2019 12:11:35 +0200 Subject: [PATCH 7/8] windows.uniscribe: speed up pixel array processing for transparent fonts The approach was suggested by John Benediktsson in a GitHub comment. --- basis/windows/uniscribe/uniscribe.factor | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/basis/windows/uniscribe/uniscribe.factor b/basis/windows/uniscribe/uniscribe.factor index 5e7635a199..6f3b436c49 100644 --- a/basis/windows/uniscribe/uniscribe.factor +++ b/basis/windows/uniscribe/uniscribe.factor @@ -1,11 +1,13 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.c-types alien.data arrays assocs cache -classes.struct colors colors.constants combinators destructors -fonts images init io.encodings.string io.encodings.utf16n kernel -literals locals math namespaces sequences windows.errors +USING: accessors alien.c-types alien.data arrays assocs +byte-arrays cache classes.struct colors colors.constants +combinators destructors fonts images init io.encodings.string +io.encodings.utf16n kernel literals locals math math.bitwise +namespaces sequences specialized-arrays windows.errors windows.fonts windows.gdi32 windows.offscreen windows.ole32 windows.types windows.usp10 ; +SPECIALIZED-ARRAY: uint32_t IN: windows.uniscribe TUPLE: script-string < disposable font string metrics ssa size image ; @@ -83,9 +85,11 @@ CONSTANT: ssa-dwFlags flags{ SSA_GLYPHS SSA_FALLBACK SSA_TAB } ! the entire image a rectangle of the given color with varying ! transparency. :: color-to-alpha ( image color -- image' ) - image color >rgba-components drop [ 255 * >integer ] tri@ 3array [ - swap first suffix -rot image set-pixel-at - ] curry each-pixel image RGBA >>component-order ; + color >rgba-components drop [ 255 * >integer ] tri@ + 3byte-array uint32_t deref 24 bits :> rgb + image bitmap>> uint32_t cast-array [ + 0xff bitand 24 shift rgb bitor + ] map! drop image RGBA >>component-order ; :: render-image ( dc ssa script-string -- image ) script-string size>> :> size From 4a7644e5094b7cef04d4576f8d03e4b8eebfce80 Mon Sep 17 00:00:00 2001 From: Alexander Iljin Date: Sat, 8 Jun 2019 13:47:06 +0200 Subject: [PATCH 8/8] windows.uniscribe: support transparency in text color --- basis/windows/uniscribe/uniscribe.factor | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/basis/windows/uniscribe/uniscribe.factor b/basis/windows/uniscribe/uniscribe.factor index 6f3b436c49..00164ff8b8 100644 --- a/basis/windows/uniscribe/uniscribe.factor +++ b/basis/windows/uniscribe/uniscribe.factor @@ -85,11 +85,14 @@ CONSTANT: ssa-dwFlags flags{ SSA_GLYPHS SSA_FALLBACK SSA_TAB } ! the entire image a rectangle of the given color with varying ! transparency. :: color-to-alpha ( image color -- image' ) - color >rgba-components drop [ 255 * >integer ] tri@ - 3byte-array uint32_t deref 24 bits :> rgb - image bitmap>> uint32_t cast-array [ - 0xff bitand 24 shift rgb bitor - ] map! drop image RGBA >>component-order ; + color >rgba-components :> alpha + [ 255 * >integer ] tri@ 3byte-array uint32_t deref 24 bits :> rgb + image bitmap>> uint32_t cast-array + alpha 1 < + [ [ 0xff bitand alpha * >integer 24 shift rgb bitor ] map! ] + [ [ 0xff bitand 24 shift rgb bitor ] map! ] + if drop + image RGBA >>component-order ; :: render-image ( dc ssa script-string -- image ) script-string size>> :> size