diff --git a/modules/view/backends/gtk3/font.reds b/modules/view/backends/gtk3/font.reds index 7f945b6291..d8d339121b 100644 --- a/modules/view/backends/gtk3/font.reds +++ b/modules/view/backends/gtk3/font.reds @@ -73,10 +73,11 @@ make-font: func [ hFont [handle!] ][ ; no more deal with different styles but only font via pango_font_description (excluding color, underline, strike) + ;; DEBUG: print ["make-font face " face " " font lf] hFont: font-description font - + ;; DEBUG: print ["make-font font-description: " hFont lf] set-font-handle font hFont - + ;; DEBUG: print ["make-font set-font-handle: " font " " hFont lf] values: object/get-values font if face <> null [ @@ -84,7 +85,7 @@ make-font: func [ block/rs-append blk as red-value! face ] - ;; DEBUG: print ["font-description: " hFont lf] + ;; DEBUG: print ["make-font end font-description: " hFont lf] hFont ] @@ -110,7 +111,9 @@ get-font-handle: func [ free-font-handle: func [ hFont [handle!] ][ + ;; DEBUG: print ["free-font-handle " hFont lf] pango_font_description_free hFont + ;; DEBUG: print ["free-font-handle end " hFont lf] ] free-font: func [ @@ -120,11 +123,11 @@ free-font: func [ hFont [handle!] ][ hFont: get-font-handle font 0 - if hFont <> null [ + unless null? hFont [ state: as red-block! (object/get-values font) + FONT_OBJ_STATE state/header: TYPE_NONE + free-font-handle hFont ] - free-font-handle hFont ] set-font-handle: func [ @@ -138,7 +141,9 @@ set-font-handle: func [ hFontP [handle!] ][ ; release previous hFont first + ;; DEBUG: print ["set-font-handle " font " " hFont lf] hFontP: get-font-handle font 0 + ;; DEBUG: print ["set-font-handle get " hFontP lf] unless null? hFontP [ free-font-handle hFontP ] @@ -161,13 +166,13 @@ update-font: func [ font [red-object!] flag [integer!] ][ + ;; DEBUG: print ["update-font " font lf] switch flag [ FONT_OBJ_NAME FONT_OBJ_SIZE FONT_OBJ_STYLE FONT_OBJ_ANGLE FONT_OBJ_ANTI-ALIAS? [ - free-font font make-font null font ] default [0] @@ -254,6 +259,10 @@ font-description: func [ pango_font_description_set_stretch fd PANGO_STRETCH_NORMAL pango_font_description_set_variant fd PANGO_VARIANT_NORMAL + ;; DOES NOT WORK AS EXPECTED: + ;; css: pango_font_description_to_string fd + ;; print ["font description css: " css lf] + fd ] diff --git a/modules/view/backends/gtk3/gui.reds b/modules/view/backends/gtk3/gui.reds index 3cb152117a..16b473b093 100644 --- a/modules/view/backends/gtk3/gui.reds +++ b/modules/view/backends/gtk3/gui.reds @@ -222,17 +222,23 @@ get-text-size: func [ ;;; get pango_context ; from widget first - widget: face-handle? face - pc: gtk_widget_get_pango_context widget - pl: pango_layout_new pc ;seems more natural than pango-context + ; widget: face-handle? face + ; pc: as handle! 0 pl: as handle! 0 + ; unless null? widget [ + ; pc: gtk_widget_get_pango_context widget + ; unless null? pc [pl: pango_layout_new pc ];seems more natural than pango-context + ; ] ; globally otherwise - if null? pl [pl: pango_layout_new pango-context] + ;if null? pl [ + pl: pango_layout_new pango-context + ;] pango_layout_set_text pl text -1 pango_layout_set_font_description pl hFont pango_layout_get_pixel_size pl :width :height g_object_unref pl +; unless null? pc [g_object_unref pc] size/width: width size/height: height @@ -1595,10 +1601,9 @@ OS-make-view: func [ gtk_container_add widget gtk_fixed_new gtk_window_move widget offset/x offset/y gobj_signal_connect(widget "delete-event" :window-delete-event null) - ;gobj_signal_connect(widget "destroy" :window-destroy null) - gtk_widget_add_events widget GDK_STRUCTURE_MASK - gobj_signal_connect(widget "configure-event" :window-configure-event null) - ;gobj_signal_connect(widget "size-allocate" :window-size-allocate null) + ;BUG (make `vid.red` failing):gtk_widget_add_events widget GDK_STRUCTURE_MASK + ;gobj_signal_connect(widget "configure-event" :window-configure-event null) + gobj_signal_connect(widget "size-allocate" :window-size-allocate null) ] sym = slider [ vertical?: size/y > size/x diff --git a/modules/view/backends/gtk3/handlers.reds b/modules/view/backends/gtk3/handlers.reds index 79b3dd0342..2f451eacf5 100644 --- a/modules/view/backends/gtk3/handlers.reds +++ b/modules/view/backends/gtk3/handlers.reds @@ -259,29 +259,28 @@ window-removed-event: func [ count/value: count/value - 1 ] -window-configure-event: func [ - [cdecl] - widget [handle!] - event [GdkEventConfigure!] - /local - sz [red-pair!] -][ - - - ;;DEBUG: print [ "window-resizing " event/x "x" event/y " " event/width "x" event/height lf] - sz: (as red-pair! get-face-values widget) + FACE_OBJ_SIZE ;-- update face/size - either any [event/width <> sz/x event/height <> sz/y] [ - ;if 0 = (motion/cpt % motion/sensitiv) [ - motion/x_new: event/width - motion/y_new: event/height - motion/x_root: as float! event/x - motion/y_root: as float! event/y - make-event widget 0 EVT_SIZING - ;] - ;motion/cpt: motion/cpt + 1 - yes - ][no] -] +;; BUG: `vid.red` fails... back with window-size-allocate handler for resizing +; window-configure-event: func [ +; [cdecl] +; widget [handle!] +; event [GdkEventConfigure!] +; /local +; sz [red-pair!] +; ][ +; ;;DEBUG: print [ "window-resizing " event/x "x" event/y " " event/width "x" event/height lf] +; sz: (as red-pair! get-face-values widget) + FACE_OBJ_SIZE ;-- update face/size +; either any [event/width <> sz/x event/height <> sz/y] [ +; ;if 0 = (motion/cpt % motion/sensitiv) [ +; motion/x_new: event/width +; motion/y_new: event/height +; motion/x_root: as float! event/x +; motion/y_root: as float! event/y +; make-event widget 0 EVT_SIZING +; ;] +; ;motion/cpt: motion/cpt + 1 +; yes +; ][no] +; ] window-size-allocate: func [ @@ -291,12 +290,14 @@ window-size-allocate: func [ /local sz [red-pair!] ][ - ;;DEBUG: print [ "window-size-allocate " rect/width "x" rect/height lf] - make-event widget 0 EVT_SIZING sz: (as red-pair! get-face-values widget) + FACE_OBJ_SIZE ;-- update face/size - sz/x: rect/width - sz/y: rect/height - ;; DEBUG: print [ "window-size-allocate end " sz lf] + if any [rect/width <> sz/x rect/height <> sz/y] [ + motion/x_new: rect/width + motion/y_new: rect/height + motion/x_root: as float! rect/x + motion/y_root: as float! rect/y + make-event widget 0 EVT_SIZING + ] ] range-value-changed: func [