]> git.neil.brown.name Git - edlib.git/commitdiff
Change numeric args to Draw:image
authorNeilBrown <neil@brown.name>
Fri, 28 Apr 2023 23:05:59 +0000 (09:05 +1000)
committerNeilBrown <neil@brown.name>
Fri, 28 Apr 2023 23:05:59 +0000 (09:05 +1000)
'num' now combine both the "Stretch" flag and the various alignment
flags.
This leaves num2 open for other purposes.

Signed-off-by: NeilBrown <neil@brown.name>
DOC/Calls
display-x11-xcb.c
lib-renderline.c
python/display-pygtk.py
python/render-present.py
render-lines.c

index 8bdf02cae1e56fb9b9cfbb235b189967c990ec36..46d257fce3b2d04ea8c665075f055b3221de0275 100644 (file)
--- a/DOC/Calls
+++ b/DOC/Calls
@@ -121,14 +121,14 @@ Draw an image on the pane (or ancestor which as been cleared).
   If "comm:" the command is run with 'str2' passed as arg 'str1', and
   result should be returned as 'bytes' (comm2 called with ->str1 as
   array of bytes, ->num1 as length).
-- num is 1 if image should be stretched to fill pane
-- num2 (if num == 0) is 'or' of
+- num is the 'or' of the following bit flags:
+   - 16 stretch image to exactly fit pane.  If set, lower bits are ignored.
+  Otherwise image will fill the pane in one dimension, and be positioning
+  left/centre/right in the other.
     - 1 centre horizontally
     - 2 right-align horizontally
     - 4 centre vertically
-    - 8 bottom-align vertialls
-  Image will fill the pane in one dimension, and be positioning
-  left/centre/right in the other.
+    - 8 bottom-align vertially
 
 ## all-displays
 
index 40cd099cc2e9b778c99b86861e922ef3144c5f57..dbd9b29cfb77a12badc83e1d30e4a73647b6e006 100644 (file)
@@ -787,15 +787,16 @@ DEF_CMD(xcb_draw_image)
        /* 'str' identifies the image. Options are:
         *     file:filename  - load file from fs
         *     comm:command   - run command collecting bytes
-        * 'num' is '1' if image should be stretched to fill pane
-        * if 'num is '0', then 'num2' is 'or' of
+        * 'num' is '16' if image should be stretched to fill pane
+        * Otherwise it is the 'or' of
         *   0,1,2 for left/middle/right in x direction
         *   0,4,8 for top/middle/bottom in y direction
-        * only one of these can be used as image will fill pane in other direction.
+        * only one of these can be used as image will fill pane
+        * in other direction.
         */
        struct xcb_data *xd = ci->home->data;
-       bool stretch = ci->num == 1;
-       int pos = ci->num2;
+       bool stretch = ci->num & 16;
+       int pos = ci->num;
        int w = ci->focus->w, h = ci->focus->h;
        int x = 0, y = 0;
        int xo, yo;
index 0f85b4036d6f7b75d71d26257a5cf9839c0bb33a..3499a66fe6748a2c3eed8371a73b73a993c7eb53 100644 (file)
@@ -465,7 +465,7 @@ static void render_image(struct pane *p safe, struct pane *focus safe,
        }
        pane_resize(p, (p->parent->w - width)/2, p->y, width, height);
        if (fname && dodraw)
-               home_call(focus, "Draw:image", p, 0, NULL, fname, 5);
+               home_call(focus, "Draw:image", p, 5, NULL, fname);
 
        free(fname);
 }
index 2ac35a5727be3f78da1a9b939e4a94c28ca9dc16..c6929040d17657fdb72045e565c930b5a537a404 100644 (file)
@@ -261,15 +261,16 @@ class EdDisplay(edlib.Pane):
         # 'str' identifies the image. Options are:
         #     file:filename  - load file from fs
         #     comm:command   - run command collecting bytes
-        # 'num' is '1' if image should be stretched to fill pane
-        # if 'num is '0', then 'num2' is 'or' of
+        # 'num' is '16' if image should be stretched to fill pane
+        # otherwise it is 'or' of
         #   0,1,2 for left/middle/right in x direction
         #   0,4,8 for top/middle/bottom in y direction
-        # only one of these can be used as image will fill pane in other direction.
+        # only one of these can be used as image will fill pane
+        # in other direction.
         if not str:
             return edlib.Enoarg
-        stretch = num
-        pos = num2
+        stretch = num & 16
+        pos = num
         w, h = focus.w, focus.h
         x, y = 0, 0
         try:
index fa30b826aa832b2e5fd6a431d42a1f8b286dac3a..18d8b61a3cb83d91555cc66407c02e22e81deaef 100644 (file)
@@ -462,11 +462,11 @@ class PresenterPane(edlib.Pane):
             if c[:6] == 'color:':
                 rv = focus.call('Draw:clear', 'bg:' + c[6:])
             if c[:14] == "image-stretch:":
-                rv = focus.call('Draw:image', 1, "file:" + self.pathto(c[14:]))
+                rv = focus.call('Draw:image', 16, "file:" + self.pathto(c[14:]))
             if c[:6] == "image:":
-                rv = focus.call('Draw:image', 0, 4+1, "file:" + self.pathto(c[6:])) # centre
+                rv = focus.call('Draw:image', 4+1, "file:" + self.pathto(c[6:])) # centre
             if c[:8] == "overlay:":
-                rv = focus.call('Draw:image', 0, 0+2, "file:" + self.pathto(c[8:])) # top right
+                rv = focus.call('Draw:image', 0+2, "file:" + self.pathto(c[8:])) # top right
             if c == "page-local":
                 page = self.find_pages(mark)
                 self.clean_lines(page)
index 84ebf36938363ffc097fafbeb0146ae536a652b7..170746d18b98f661865297148d40dcf85b0eae72 100644 (file)
@@ -767,7 +767,7 @@ static int render(struct mark *pm, struct pane *p safe,
                free(a);
        } else if (strncmp(s, "image:", 6) == 0) {
                home_call(focus, "Draw:clear", p);
-               home_call(focus, "Draw:image", p, 1, NULL, s+6);
+               home_call(focus, "Draw:image", p, 16, NULL, s+6);
                rl->background_uniform = False;
        } else
                home_call(focus, "Draw:clear", p, 0, NULL, "");