mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 21:02:50 +00:00
0fab830be6
By default, horizontal and vertical layouts expand to fill their parent in their on-axis direction (horizontally for horizontal layouts), but fit to their child views in their off-axis. Flexible space views take advantage of auto-expansion, pushing sibling views such that the grandparent view is filled on the parent view's on-axis, and the parent view is filled by the space in the parent view's off-axis. Flexible views currently have a background fill, allowing them to provide background filling of the overall view with minimal overdraw (ancestor views don't need to have any fill at all).
124 lines
3.1 KiB
C
124 lines
3.1 KiB
C
/*
|
|
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"
|
|
#include "QF/ui/view.h"
|
|
|
|
enum {
|
|
canvas_update,
|
|
canvas_updateonce,
|
|
canvas_tile,
|
|
canvas_pic,
|
|
canvas_fitpic, // pic is scaled to fit the view
|
|
canvas_subpic,
|
|
canvas_cachepic,
|
|
canvas_fill,
|
|
canvas_charbuff,
|
|
canvas_passage_glyphs, // copy of text_passage_glyphs
|
|
canvas_glyphs, // copy of text_passage_glyphs
|
|
canvas_func,
|
|
canvas_outline,
|
|
canvas_lateupdate,
|
|
|
|
// last so deleting an entity removes the grouped components first
|
|
canvas_canvas,
|
|
|
|
canvas_comp_count
|
|
};
|
|
|
|
typedef struct canvas_s {
|
|
bool visible;
|
|
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;
|
|
uint32_t base;
|
|
uint32_t view_base;
|
|
uint32_t text_base;
|
|
uint32_t imui_base;
|
|
} 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;
|
|
|
|
#define CANVASINLINE GNU89INLINE inline
|
|
|
|
void Canvas_InitSys (canvas_system_t *canvas_sys, ecs_registry_t *reg);
|
|
void Canvas_AddToEntity (canvas_system_t canvas_sys, uint32_t ent);
|
|
uint32_t Canvas_New (canvas_system_t canvas_sys);
|
|
void Canvas_Draw (canvas_system_t canvas_sys);
|
|
void Canvas_SortComponentPool (canvas_system_t canvas_sys, uint32_t ent,
|
|
uint32_t component);
|
|
void Canvas_SetLen (canvas_system_t canvas_sys, view_pos_t len);
|
|
CANVASINLINE view_t Canvas_GetRootView (canvas_system_t canvas_sys,
|
|
uint32_t ent);
|
|
CANVASINLINE bool *Canvas_Visible (canvas_system_t canvas_sys, uint32_t ent);
|
|
|
|
#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);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
#undef CANVASINLINE
|
|
|
|
#endif//__QF_scene_canvas_h
|