2022-12-20 10:45:48 +00:00
|
|
|
/*
|
|
|
|
canvas.h
|
|
|
|
|
|
|
|
Integration of 2d and 3d objects
|
|
|
|
|
|
|
|
Copyright (C) 2022 Bill Currie <bill@taniwha.org>
|
|
|
|
|
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
|
|
Date: 2022/12/12
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __QF_scene_canvas_h
|
|
|
|
#define __QF_scene_canvas_h
|
|
|
|
|
|
|
|
#include "QF/ecs.h"
|
2023-01-20 06:57:29 +00:00
|
|
|
#include "QF/ui/view.h"
|
2022-12-20 10:45:48 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
canvas_update,
|
|
|
|
canvas_updateonce,
|
|
|
|
canvas_tile,
|
|
|
|
canvas_pic,
|
2023-01-17 02:33:47 +00:00
|
|
|
canvas_fitpic, // pic is scaled to fit the view
|
2022-12-20 10:45:48 +00:00
|
|
|
canvas_subpic,
|
|
|
|
canvas_cachepic,
|
|
|
|
canvas_fill,
|
|
|
|
canvas_charbuff,
|
2023-07-01 10:49:49 +00:00
|
|
|
canvas_passage_glyphs, // copy of text_passage_glyphs
|
|
|
|
canvas_glyphs, // copy of text_passage_glyphs
|
2022-12-20 10:45:48 +00:00
|
|
|
canvas_func,
|
|
|
|
canvas_outline,
|
2023-01-21 18:43:58 +00:00
|
|
|
canvas_lateupdate,
|
2022-12-20 10:45:48 +00:00
|
|
|
|
|
|
|
// last so deleting an entity removes the grouped components first
|
|
|
|
canvas_canvas,
|
|
|
|
|
|
|
|
canvas_comp_count
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct canvas_s {
|
2023-07-01 10:53:26 +00:00
|
|
|
bool visible;
|
2022-12-20 10:45:48 +00:00
|
|
|
uint32_t range[canvas_comp_count];
|
|
|
|
} canvas_t;
|
|
|
|
|
|
|
|
extern const struct component_s canvas_components[canvas_comp_count];
|
|
|
|
|
|
|
|
typedef struct canvas_system_s {
|
|
|
|
ecs_registry_t *reg;
|
2022-12-20 16:54:10 +00:00
|
|
|
uint32_t base;
|
2022-12-20 10:45:48 +00:00
|
|
|
uint32_t view_base;
|
2023-01-20 18:26:02 +00:00
|
|
|
uint32_t text_base;
|
2022-12-20 10:45:48 +00:00
|
|
|
} canvas_system_t;
|
|
|
|
|
|
|
|
struct view_s;
|
|
|
|
struct view_pos_s;
|
|
|
|
|
|
|
|
typedef void (*canvas_update_f) (struct view_s);
|
|
|
|
typedef void (*canvas_func_f) (struct view_pos_s, struct view_pos_s);
|
|
|
|
|
|
|
|
typedef struct canvas_subpic_s {
|
|
|
|
struct qpic_s *pic;
|
|
|
|
uint32_t x, y;
|
|
|
|
uint32_t w, h;
|
|
|
|
} canvas_subpic_t;
|
|
|
|
|
2023-01-20 06:57:29 +00:00
|
|
|
#define CANVASINLINE GNU89INLINE inline
|
|
|
|
|
2023-01-20 18:26:02 +00:00
|
|
|
void Canvas_InitSys (canvas_system_t *canvas_sys, ecs_registry_t *reg);
|
2022-12-20 16:54:10 +00:00
|
|
|
void Canvas_AddToEntity (canvas_system_t canvas_sys, uint32_t ent);
|
2023-01-20 06:57:29 +00:00
|
|
|
uint32_t Canvas_New (canvas_system_t canvas_sys);
|
2022-12-20 16:54:10 +00:00
|
|
|
void Canvas_Draw (canvas_system_t canvas_sys);
|
2023-01-16 02:32:12 +00:00
|
|
|
void Canvas_SortComponentPool (canvas_system_t canvas_sys, uint32_t ent,
|
|
|
|
uint32_t component);
|
2023-01-20 18:26:02 +00:00
|
|
|
void Canvas_SetLen (canvas_system_t canvas_sys, view_pos_t len);
|
2023-01-20 06:57:29 +00:00
|
|
|
CANVASINLINE view_t Canvas_GetRootView (canvas_system_t canvas_sys,
|
|
|
|
uint32_t ent);
|
2023-07-01 10:53:26 +00:00
|
|
|
CANVASINLINE bool *Canvas_Visible (canvas_system_t canvas_sys, uint32_t ent);
|
2023-01-20 06:57:29 +00:00
|
|
|
|
|
|
|
#undef CANVASINLINE
|
|
|
|
#ifndef IMPLEMENT_CANVAS_Funcs
|
|
|
|
#define CANVASINLINE GNU89INLINE inline
|
|
|
|
#else
|
|
|
|
#define CANVASINLINE VISIBLE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
CANVASINLINE
|
|
|
|
view_t
|
|
|
|
Canvas_GetRootView (canvas_system_t canvas_sys, uint32_t ent)
|
|
|
|
{
|
|
|
|
ecs_system_t viewsys = { canvas_sys.reg, canvas_sys.view_base };
|
|
|
|
return View_FromEntity (viewsys, ent);
|
|
|
|
}
|
|
|
|
|
2023-07-01 10:53:26 +00:00
|
|
|
CANVASINLINE
|
|
|
|
bool *
|
|
|
|
Canvas_Visible (canvas_system_t canvas_sys, uint32_t ent)
|
|
|
|
{
|
|
|
|
uint32_t comp = canvas_sys.base + canvas_canvas;
|
|
|
|
return Ent_GetComponent (ent, comp, canvas_sys.reg);
|
|
|
|
}
|
|
|
|
|
2023-01-20 06:57:29 +00:00
|
|
|
#undef CANVASINLINE
|
2022-12-20 10:45:48 +00:00
|
|
|
|
|
|
|
#endif//__QF_scene_canvas_h
|