URI:
       tgraphics.h - ltk - Socket-based GUI for X11 (WIP)
  HTML git clone git://lumidify.org/ltk.git (fast, but not encrypted)
  HTML git clone https://lumidify.org/git/ltk.git (encrypted, but very slow)
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       tgraphics.h (3877B)
       ---
            1 /*
            2  * Copyright (c) 2021, 2022 lumidify <nobody@lumidify.org>
            3  *
            4  * Permission to use, copy, modify, and/or distribute this software for any
            5  * purpose with or without fee is hereby granted, provided that the above
            6  * copyright notice and this permission notice appear in all copies.
            7  *
            8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
            9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
           10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
           11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
           12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
           13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
           14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
           15  */
           16 
           17 #ifndef LTK_GRAPHICS_H
           18 #define LTK_GRAPHICS_H
           19 
           20 /* FIXME: make this global and use it elsewhere */
           21 #define USE_XLIB_GRAPHICS 1
           22 
           23 typedef struct ltk_renderdata ltk_renderdata;
           24 
           25 /* FIXME: Is it faster to take ltk_color* or ltk_color? */
           26 
           27 #include <X11/Xft/Xft.h>
           28 #include "rect.h"
           29 #include "color.h"
           30 #include "ltk.h"
           31 #include "compat.h"
           32 
           33 typedef enum {
           34         LTK_BORDER_NONE = 0,
           35         LTK_BORDER_TOP = 1,
           36         LTK_BORDER_RIGHT = 2,
           37         LTK_BORDER_BOTTOM = 4,
           38         LTK_BORDER_LEFT = 8,
           39         LTK_BORDER_ALL = 0xF
           40 } ltk_border_sides;
           41 
           42 /* typedef struct ltk_surface ltk_surface; */
           43 
           44 /* FIXME: graphics context */
           45 ltk_surface *ltk_surface_create(ltk_renderdata *renderdata, int w, int h);
           46 void ltk_surface_destroy(ltk_surface *s);
           47 /* returns 0 if successful, 1 if not resizable */
           48 int ltk_surface_resize(ltk_surface *s, int w, int h);
           49 /* FIXME: kind of hacky */
           50 void ltk_surface_update_size(ltk_surface *s, int w, int h);
           51 ltk_surface *ltk_surface_from_window(ltk_renderdata *renderdata, int w, int h);
           52 void ltk_surface_get_size(ltk_surface *s, int *w, int *h);
           53 void ltk_surface_copy(ltk_surface *src, ltk_surface *dst, ltk_rect src_rect, int dst_x, int dst_y);
           54 void ltk_surface_draw_rect(ltk_surface *s, ltk_color *c, ltk_rect rect, int line_width);
           55 void ltk_surface_fill_rect(ltk_surface *s, ltk_color *c, ltk_rect rect);
           56 /* FIXME: document properly, especiall difference to draw_rect with offsets and line_width */
           57 void ltk_surface_draw_border(ltk_surface *s, ltk_color *c, ltk_rect rect, int line_width, ltk_border_sides border_sides);
           58 void ltk_surface_draw_border_clipped(ltk_surface *s, ltk_color *c, ltk_rect rect, ltk_rect clip_rect, int line_width, ltk_border_sides border_sides);
           59 void ltk_surface_fill_polygon(ltk_surface *s, ltk_color *c, ltk_point *points, size_t npoints);
           60 void ltk_surface_fill_polygon_clipped(ltk_surface *s, ltk_color *c, ltk_point *points, size_t npoints, ltk_rect clip);
           61 
           62 /* TODO */
           63 /*
           64 void ltk_surface_draw_arc(ltk_surface *s, ltk_color *c, int x, int y, int w, int h, int angle1, int angle2, int line_width);
           65 void ltk_surface_fill_arc(ltk_surface *s, ltk_color *c, int x, int y, int w, int h, int angle1, int angle2);
           66 void ltk_surface_draw_circle(ltk_surface *s, ltk_color *c, int xc, int yc, int r, int line_width);
           67 void ltk_surface_fill_circle(ltk_surface *s, ltk_color *c, int xc, int yc, int r);
           68 */
           69 
           70 /* FIXME: only generate draw if needed */
           71 #if USE_XFT == 1
           72 XftDraw *ltk_surface_get_xft_draw(ltk_surface *s);
           73 #endif
           74 #if USE_XLIB_GRAPHICS == 1
           75 Drawable ltk_surface_get_drawable(ltk_surface *s);
           76 #endif
           77 
           78 void renderer_set_imspot(ltk_renderdata *renderdata, int x, int y);
           79 ltk_renderdata *renderer_create_window(const char *title, int x, int y, unsigned int w, unsigned int h);
           80 void renderer_destroy_window(ltk_renderdata *renderdata);
           81 void renderer_set_window_properties(ltk_renderdata *renderdata, ltk_color *bg);
           82 /* FIXME: this is kind of out of place */
           83 void renderer_swap_buffers(ltk_renderdata *renderdata);
           84 /* FIXME: this is just for the socket name and is a bit weird */
           85 unsigned long renderer_get_window_id(ltk_renderdata *renderdata);
           86 
           87 #endif /* LTK_GRAPHICS_H */