PreviousUpNext

15.3.739  src/lib/x-kit/widget/xkit/theme/widget/default/look/sprite-imp.api

## sprite-imp.api
#

# Compiled by:
#     src/lib/x-kit/widget/xkit-widget.sublib


stipulate
    include package   threadkit;                                # threadkit                     is from   src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit.pkg
    #
#   package ap  =  client_to_atom;                              # client_to_atom                is from   src/lib/x-kit/xclient/src/iccc/client-to-atom.pkg
#   package au  =  authentication;                              # authentication                is from   src/lib/x-kit/xclient/src/stuff/authentication.pkg
#   package cpm =  cs_pixmap;                                   # cs_pixmap                     is from   src/lib/x-kit/xclient/src/window/cs-pixmap.pkg
#   package cpt =  cs_pixmat;                                   # cs_pixmat                     is from   src/lib/x-kit/xclient/src/window/cs-pixmat.pkg
#   package dy  =  display;                                     # display                       is from   src/lib/x-kit/xclient/src/wire/display.pkg
#   package xet =  xevent_types;                                # xevent_types                  is from   src/lib/x-kit/xclient/src/wire/xevent-types.pkg
#   package w2x =  windowsystem_to_xserver;                     # windowsystem_to_xserver       is from   src/lib/x-kit/xclient/src/window/windowsystem-to-xserver.pkg
#   package fil =  file__premicrothread;                        # file__premicrothread          is from   src/lib/std/src/posix/file--premicrothread.pkg
#   package fti =  font_index;                                  # font_index                    is from   src/lib/x-kit/xclient/src/window/font-index.pkg
#   package r2k =  xevent_router_to_keymap;                     # xevent_router_to_keymap       is from   src/lib/x-kit/xclient/src/window/xevent-router-to-keymap.pkg
#   package mtx =  rw_matrix;                                   # rw_matrix                     is from   src/lib/std/src/rw-matrix.pkg
#   package rgb =  rgb;                                         # rgb                           is from   src/lib/x-kit/xclient/src/color/rgb.pkg
#   package rop =  ro_pixmap;                                   # ro_pixmap                     is from   src/lib/x-kit/xclient/src/window/ro-pixmap.pkg
#   package rw  =  root_window;                                 # root_window                   is from   src/lib/x-kit/widget/lib/root-window.pkg
#   package rwv =  rw_vector;                                   # rw_vector                     is from   src/lib/std/src/rw-vector.pkg
#   package sep =  client_to_selection;                         # client_to_selection           is from   src/lib/x-kit/xclient/src/window/client-to-selection.pkg
#   package shp =  shade;                                       # shade                         is from   src/lib/x-kit/widget/lib/shade.pkg
#   package sj  =  socket_junk;                                 # socket_junk                   is from   src/lib/internet/socket-junk.pkg
#   package x2s =  xclient_to_sequencer;                        # xclient_to_sequencer          is from   src/lib/x-kit/xclient/src/wire/xclient-to-sequencer.pkg
#   package tr  =  logger;                                      # logger                        is from   src/lib/src/lib/thread-kit/src/lib/logger.pkg
#   package tsr =  thread_scheduler_is_running;                 # thread_scheduler_is_running   is from   src/lib/src/lib/thread-kit/src/core-thread-kit/thread-scheduler-is-running.pkg
#   package u1  =  one_byte_unt;                                # one_byte_unt                  is from   src/lib/std/one-byte-unt.pkg
#   package v1u =  vector_of_one_byte_unts;                     # vector_of_one_byte_unts       is from   src/lib/std/src/vector-of-one-byte-unts.pkg
#   package v2w =  value_to_wire;                               # value_to_wire                 is from   src/lib/x-kit/xclient/src/wire/value-to-wire.pkg
#   package wg  =  widget;                                      # widget                        is from   src/lib/x-kit/widget/old/basic/widget.pkg
#   package wi  =  window;                                      # window                        is from   src/lib/x-kit/xclient/src/window/window.pkg
#   package wme =  window_map_event_sink;                       # window_map_event_sink         is from   src/lib/x-kit/xclient/src/window/window-map-event-sink.pkg
#   package wpp =  client_to_window_watcher;                    # client_to_window_watcher      is from   src/lib/x-kit/xclient/src/window/client-to-window-watcher.pkg
#   package wy  =  widget_style;                                # widget_style                  is from   src/lib/x-kit/widget/lib/widget-style.pkg
#   package e2s =  xevent_to_string;                            # xevent_to_string              is from   src/lib/x-kit/xclient/src/to-string/xevent-to-string.pkg
#   package xc  =  xclient;                                     # xclient                       is from   src/lib/x-kit/xclient/xclient.pkg
#   package xj  =  xsession_junk;                               # xsession_junk                 is from   src/lib/x-kit/xclient/src/window/xsession-junk.pkg
#   package xt  =  xtypes;                                      # xtypes                        is from   src/lib/x-kit/xclient/src/wire/xtypes.pkg
#   package xtr =  xlogger;                                     # xlogger                       is from   src/lib/x-kit/xclient/src/stuff/xlogger.pkg

    package gtg =  guiboss_to_guishim;                          # guiboss_to_guishim            is from   src/lib/x-kit/widget/theme/guiboss-to-guishim.pkg

    package gd  =  gui_displaylist;                             # gui_displaylist               is from   src/lib/x-kit/widget/theme/gui-displaylist.pkg

    package pp  =  standard_prettyprinter;                      # standard_prettyprinter        is from   src/lib/prettyprint/big/src/standard-prettyprinter.pkg
    package r8  =  rgb8;                                        # rgb8                          is from   src/lib/x-kit/xclient/src/color/rgb8.pkg
    #
    package w2p =  sprite_to_spritespace;                       # sprite_to_spritespace         is from   src/lib/x-kit/widget/space/sprite/sprite-to-spritespace.pkg
    package p2w =  spritespace_to_sprite;                       # spritespace_to_sprite         is from   src/lib/x-kit/widget/space/sprite/spritespace-to-sprite.pkg
    #
    package g2d =  geometry2d;                                  # geometry2d                    is from   src/lib/std/2d/geometry2d.pkg
    package evt =  gui_event_types;                             # gui_event_types               is from   src/lib/x-kit/widget/gui/gui-event-types.pkg
    package gts =  gui_event_to_string;                         # gui_event_to_string           is from   src/lib/x-kit/widget/gui/gui-event-to-string.pkg

    package gt  =  guiboss_types;                               # guiboss_types                 is from   src/lib/x-kit/widget/gui/guiboss-types.pkg
    package wt  =  widget_theme;                                # widget_theme                  is from   src/lib/x-kit/widget/theme/widget/widget-theme.pkg

    package g2p =  gadget_to_pixmap;                            # gadget_to_pixmap              is from   src/lib/x-kit/widget/theme/gadget-to-pixmap.pkg

    #
    tracefile   =  "widget-unit-test.trace.log";

    nb = log::note_on_stderr;                                   # log                           is from   src/lib/std/src/log.pkg
herein

    # This api is implemented in:
    #
    #     src/lib/x-kit/widget/xkit/theme/widget/default/look/sprite-imp.pkg
    #
    api Sprite_Imp {

        #
        Sprite                                                                                          # This turns out not to get used in practice, and probably should be dropped if no use turns up for it.
          =
          { id:                                 Id,                                                     # Unique id to facilitate storing node_state instances in indexed datastructures like red-black trees.
            pass_something:                     Replyqueue -> (Int -> Void) -> Void,
            do_something:                       Int -> Void,
            do:                                 (Void -> Void) -> Void                                  # Used by widget subthreads to run code in main widget microthread.
          };

        Startup_Fn
          =
          { 
            gadget_to_guiboss:                  gt::Gadget_To_Guiboss,
            sprite_to_spritespace:              w2p::Sprite_To_Spritespace,
            do:                                 (Void -> Void) -> Void                                  # Used by widget subthreads to run code in main widget microthread.
          }
          ->
          Void;

        Shutdown_Fn
          =
          Void
          ->
          Void;                                                                                         # 

        Initialize_Gadget_Fn
          =
          {
            id:                                 Id,                                                     # Unique id.
            doc:                                String,
            site:                               g2d::Box,                                               # Window rectangle in which to draw.
            gadget_to_guiboss:                  gt::Gadget_To_Guiboss,
            sprite_to_spritespace:              w2p::Sprite_To_Spritespace,
            theme:                              wt::Widget_Theme,
            pass_font:                          List(String) -> Replyqueue
                                                             -> (evt::Font -> Void) -> Void,            # Nonblocking version of next, for use in imps.
             get_font:                          List(String) ->  evt::Font,                             # Accepts a list of font names which are tried in order.
            make_rw_pixmap:                     g2d::Size -> g2p::Gadget_To_Rw_Pixmap,                  # Make an Xserver-side rw_pixmap for scratch use by widget.  In general there is no need for the sprite to explicitly free these -- guiboss_imp will do this automatically when the gui is killed.
            #
            do:                                 (Void -> Void) -> Void                                  # Used by widget subthreads to run code in main widget microthread.
          }
          ->
          Void;

        Redraw_Request_Fn
          =
          {
            id:                                 Id,                                                     # Unique id.
            doc:                                String,
            frame_number:                       Int,                                                    # 1,2,3,... Purely for convenience of widget, guiboss-imp makes no use of this.
            site:                               g2d::Box,                                               # Window rectangle in which to draw.
            popup_nesting_depth:                Int,                                                    # 0 for gadgets on basewindow, 1 for gadgets on popup on basewindow, 2 for gadgets on popup on popup, etc.
            duration_in_seconds:                Float,                                                  # If state has changed look-imp should call redraw_gadget() before this time is up. Also useful for motionblur.
            gadget_to_guiboss:                  gt::Gadget_To_Guiboss,
            sprite_to_spritespace:              w2p::Sprite_To_Spritespace,
            gadget_mode:                        gt::Gadget_Mode,
            theme:                              wt::Widget_Theme,
            do:                                 (Void -> Void) -> Void                                  # Used by widget subthreads to run code in main widget microthread.
          }
          ->
          Void;

        Mouse_Click_Fn
          =
          {
            id:                                 Id,                                                     # Unique id.
            doc:                                String,
            event:                              gt::Mousebutton_Event,                                  # MOUSEBUTTON_PRESS or MOUSEBUTTON_RELEASE.
            button:                             evt::Mousebutton,
            point:                              g2d::Point,
            site:                               g2d::Box,                                               # Widget's assigned area in window coordinates.
            modifier_keys_state:                evt::Modifier_Keys_State,                               # State of the modifier keys (shift, ctrl...).
            mousebuttons_state:                 evt::Mousebuttons_State,                                # State of mouse buttons as a bool record.
            gadget_to_guiboss:                  gt::Gadget_To_Guiboss,
            sprite_to_spritespace:              w2p::Sprite_To_Spritespace,
            theme:                              wt::Widget_Theme
          }
          ->
          Void;

        Mouse_Drag_Fn
          =
          {
            id:                                 Id,                                                     # Unique id.
            doc:                                String,
            event_point:                        g2d::Point,
            start_point:                        g2d::Point,
            last_point:                         g2d::Point,
            site:                               g2d::Box,                                               # Widget's assigned area in window coordinates.
            phase:                              gt::Drag_Phase, 
            button:                             evt::Mousebutton,
            modifier_keys_state:                evt::Modifier_Keys_State,                               # State of the modifier keys (shift, ctrl...).
            mousebuttons_state:                 evt::Mousebuttons_State,                                # State of mouse buttons as a bool record.
            gadget_to_guiboss:                  gt::Gadget_To_Guiboss,
            sprite_to_spritespace:              w2p::Sprite_To_Spritespace,
            theme:                              wt::Widget_Theme,
            do:                                 (Void -> Void) -> Void                                  # Used by widget subthreads to run code in main widget microthread.
          }
          ->
          Void;

        Mouse_Transit_Fn                                                                                # Note that buttons are always all up in a mouse motion -- otherwise it is a mouse-drag event.
          =
          {
            id:                                 Id,                                                     # Unique id.
            doc:                                String,
            event_point:                        g2d::Point,
            site:                               g2d::Box,                                               # Widget's assigned area in window coordinates.
            transit:                            gt::Gadget_Transit,                                     # Mouse is entering (CAME) or leaving (LEFT) widget, or moving (MOVE) across it.
            modifier_keys_state:                evt::Modifier_Keys_State,                               # State of the modifier keys (shift, ctrl...).
            gadget_to_guiboss:                  gt::Gadget_To_Guiboss,
            sprite_to_spritespace:              w2p::Sprite_To_Spritespace,
            theme:                              wt::Widget_Theme,
            do:                                 (Void -> Void) -> Void                                  # Used by widget subthreads to run code in main widget microthread.
          }
          ->
          Void;

        Key_Event_Fn
          =
          {
            id:                                 Id,                                                     # Unique id.
            doc:                                String,
            keystroke:                          gt::Keystroke_Info,                                     # Keystring etc for event.
            site:                               g2d::Box,                                               # Widget's assigned area in window coordinates.
            gadget_to_guiboss:                  gt::Gadget_To_Guiboss,
            sprite_to_spritespace:              w2p::Sprite_To_Spritespace,
            theme:                              wt::Widget_Theme
          }
          ->
          Void;

        Note_Keyboard_Focus_Fn_Arg
          =
          {
            id:                                 Id,                                                     # Unique id.
            doc:                                String,
            have_keyboard_focus:                Bool,                                                   # 
            gadget_to_guiboss:                  gt::Gadget_To_Guiboss,
            sprite_to_spritespace:              w2p::Sprite_To_Spritespace,
            theme:                              wt::Widget_Theme,
            do:                                 (Void -> Void) -> Void                                  # Used by widget subthreads to run code in main widget microthread.
          };
        Note_Keyboard_Focus_Fn = Note_Keyboard_Focus_Fn_Arg -> Void;

        Sprite_Option
            #
            = MICROTHREAD_NAME                  String                                                  # 
            | ID                                Id                                                      # Unique ID for imp, issued by issue_unique_id::issue_unique_id().
            | DOC                               String                                                  # Documentation string for widget, for debugging purposes.
            #
            | WIDGET_CONTROL_CALLBACK           ( p2w::Spritespace_To_Sprite -> Void    )               # Gui boss registers this maildrop to get a port to us once we start up.
            | SPRITE_CALLBACK                   (     Null_Or(Sprite) -> Void   )                       # App      registers this maildrop to get (THE sprite_port) from us once we start up, and NULL when we shut down.
            #
            | STARTUP_FN                        Startup_Fn                                              # Application-specific handler for sprite-imp startup.
            | SHUTDOWN_FN                       Shutdown_Fn                                             # Application-specific handler for sprite-imp shutdown -- mainly saving state for possible later sprite restart.
            #                                                                                           # 
            | INITIALIZE_GADGET_FN              Initialize_Gadget_Fn                                    # Typically used to set up widget background.
            | REDRAW_REQUEST_FN                 Redraw_Request_Fn                                       # Application-specific handler for start-of-frame events from guiboss-imp.
            #
            | MOUSE_CLICK_FN                    Mouse_Click_Fn                                          # Application-specific handler for mousebutton clicks.
            #
            | MOUSE_DRAG_FN                     Mouse_Drag_Fn                                           # Application-specific handler for mouse motions.
            | MOUSE_TRANSIT_FN                  Mouse_Transit_Fn                                        # Application-specific handler for mouse motions.
            #
            | KEY_EVENT_FN                      Key_Event_Fn                                            # Application-specific handler for keyboard key-press and key-release events.
            | NOTE_KEYBOARD_FOCUS_FN            Note_Keyboard_Focus_Fn                                  
            ;

        Sprite_Arg        =  List(Sprite_Option);                                                       # No required components at present.

        make_sprite_start_fn
            :
            Sprite_Arg
            ->
            gt::Sprite_Start_Fn
            ;


        pprint_sprite_arg:      pp::Prettyprinter -> Sprite_Arg -> Void;
    };


end;


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext