Age | Commit message (Collapse) | Author |
|
Switching to https since it's less likely to be blocked and
harder to MITM than git://.
|
|
This introduces some stage_render() flow control and render-time
freeing of nodes via the nodes render_func().
It's particularly useful for one-shot ephemeral nodes which are
thrown on-screen and require nothing more than their render and
free funcs for a full lifecycle. An example would be something
running an effect briefly which runs autonomously from just a
timer alone, returning the free request from the final render once
the ending time arrives.
|
|
The old stuff didn't seem to work with BUILT_SOURCES
|
|
When !stage_conf_t.replace and stage_conf_t.stage is non-NULL,
stage_conf_t.stage will be used for the stage memory in stage_new()
instead of allocating some.
It's up to the caller to free this memory as needed, which may safely
be done from stage_ops_t.free_func() if needed.
Note that at this time there's no way for external callers to actually
know the stage_t size, as it's entirely opaque. A future commit will
expose a padded variant of the struct, exposing its size appropriately
without making it completely public.
|
|
More preparation for caller-supplied stage memory. As-is this
changes nothing functionally since there's no way to supply caller-
allocated uninitialized memory to stage_new() yet. There's the
.replace capability, but that requires a valid stage in .stage,
which could only be gotten correctly via stage_new() originally,
so it'll always have the .allocated member set.
A future commit will wire up using the .stage member as caller-supplied
memory when set in stage_new() without .replace.
|
|
In preparation for supporting caller-supplied stage memory, add another
stage_t pointer to the conf called .stage.
The naming of .adopt was always awkward and resulted from the reuse of
the .parent pointer to indicate the stage to replace. Now that there's
a .stage member, just rename .adopt to .replace, with the same semantics.
At some point I need to firm up what .replace does with the other conf
data. Currently, only the name, ops, and object, are updated. The
existing active/locked/alpha etc are retained unchanged, ignored from
the conf. This can be surprising/unexpected to someone performing a
replace through the .conf, and it would probably be convenient to be
able to set everything during a replace. So there should probably be
a convenience helper for constructing a conf from an existing stage,
which can then be overridden selectively while passing to a new().
|
|
When set, this turns stage_new() into a stage_replace() against the
supplied parent.
So if you have an existing stage_t and you wish to turn it into
something else directly via stage_new(), simply pass it in as the
parent with the adopt flag set.
Previously it was rather contorted to do this kind of thing, and
kind of impossible really. This way avoids the allocation of the
new stage_t while preserving the usability of all existing components
build around the stage_new/stage_conf_t API.
This is kind of experimental and I haven't tested it yet, just a wart
I tripped over in the "sars" Blender 2020 project and wanted to do
something quick about before it falls off my radar as I'm busy with
unrelated things.
|
|
also from internal _stage_set_object() for better ergonomics
|
|
Even if the build is out-of-tree, bootstrap litters the tree with
this stuff, and it can be annoying for other projects embedding
libstage as git notices the "untracked content"
|
|
Particularly in cached stages it's often needed to start out dirty, by
copying from the stage_conf_t passed to stage_new() it still defaults
to the common clean/0 case but eliminates the need for a separate
stage_dirty() call in the caching case.
|
|
|
|
This seemed useful at the time, but it's proven a bit inadequate
when adding relative picking in addition to what the stage could
provide via the lookup hook. Then once adding relative picking
externally, including the spatial stuff the lookup stage hook
typically added was conveniently handled as well.
So just get rid of this, even though it probably would be
perfectly sufficient for purely touch-based interfaces where
there's no relative navigation. i.e. tab/arrow key to select
the next item.
|
|
Introduces stage_ops_t, tidying up stage_new() users.
For now the stage_t simply references the passed in ops struct, so the
caller must ensure its lifetime survives the referencing stages. That
may be annoying if callers tend to construct them as compound literals
at the call site, but I don't expect that to be too onerous to avoid.
|
|
stage_new() call sites were getting quite annoying, using compound
literals with designated initializers on a struct makes the call sites
a lot more readable, self-documenting, and often more compact thanks
to the automatic zeroing of omitted members.
I don't particularly like the name, and may switch it later, something
shorter would be nice.
|
|
|
|
This effectively makes rendering two passes, with a first pass giving
stage nodes an opportunity to maintain caches or other preparatory
steps before actual rendering.
|
|
This adds a dirty bit to every stage_t, but only maintains the bit
at the root. This means rendering is assumed to occur at the root,
as that's the only place the dirty state will be correctly managed.
|
|
Rather than having a per-node match function to facilitate stage
lookups by opaque keys returning a boolean result, make it a
more general lookup returning a stage_t *.
It's still basically a boolean, where NULL is a miss. But by
returning the stage_t *, it enables things like encapsulated
stages for caching purposes where a node might represent an
isolated stage it can propagate lookups down to and return
the results out of.
When the match function only returned a 1/0, and the outer
lookup machinery returned the current stage node on a hit,
there was no way to hand out arbitrary stage pointers.
|
|
It's common to need access to some rendering context from the
per-stage render functions, this simply plumbs an opaque pointer
from stage_render() down to the render functions.
|
|
This is identical to stage_lookup_name() except instead of comparing
the name, it calls the per-stage stage_match_func_t with the supplied
key and returns the first match according to the match func.
By supplying a spatial key like a &(vec2){x,y}, and match funcs that
can test the vec2 against their respective stage object for overlap,
simple spatial searches can be performed against the stage heirarchy.
This isn't optimized or anything, but for simple scenes it can be
convenient. Things like simple game menus might have a stage node
per menu entry and event handlers can just search the stage with
the X,Y coordinates of the events to map events to visual elements.
|
|
Preparation for adding stage_lookup_key() to search a stage
heirarchy by an opaque key the per-node functions know how to
compare against.
|
|
Cosmetic readability change, I don't like to typedef pointer types
|
|
some trivial rearranging as well
|
|
|
|
It appears at some point some of the getters were lost, or
maybe were never implemented.
Regardless, what's there uses result pointer parameters and it's
more annoying to use that way. Just return the values directly,
not like there are error conditions to distinguish.
|
|
This hasn't belonged in libstage since losing all dimensionality
|
|
|
|
Now stage_t is the only type, and a tree of stages may be
constructed by supplying a parent to stage_new().
Essentially stage_t swallowed stage_node_t.
The heirarchy is handy for grouping stages logically, and alpha
is computed statefully during the recursive render. So alpha of
grouped stages may be varied at a single parent. The active
flag is also honored recursively for a similar effect; toggle
subtrees in a single place.
Container stages may be created by omitting object/render/free
attributes. These are handy for the aforementioned group
alpha/active controls.
|
|
|
|
|
|
|
|
|
|
|
|
Preparing to discard src/list.h
|
|
Now that libstage has no coupling to the rendering backend,
there's no need for this.
|
|
Having the stage manage the rendering dimensions for nodes
seemed like a good idea at the time.
This commit removes all that so there's no more coupling to
SDL or dimensional types. Now the stage really is nothing
more than a thin drawing list abstraction. The layers can be
used for ordering the drawing, which is the only semi-dimensional
thing remaining.
The stage_fit() helper remains for now out of convenience, but
it's really out of place in this library.
|
|
I added a way to set these mappings per-node, but not per-stage.
This adds setters for the stage, and new nodes are created with
the current per-stage setting. The nodes may still have their
mapping mode changed independent of the stage and one another, but
this gives a means of easily setting a global mapping mode for a
given stage.
|
|
Until now all aabb and position mapping has been simple linear
filling of the stage. When the stage isn't square, which is
usually, this isn't always desirable especially for the aabb
sizing of things. This introduces per-node settings for the
mapping of the node's aabb and position.
The default continues to be to map the full stage, with two new
settings for the minimum square and maximum square.
|
|
Static nodes are unaffected by stage movement, or if later there's a
hierarchy in the stage, this would probably escape all ancestral influence.
The anticipated use case is overlays like consoles, HUDs, and scores etc.
Things which don't move with the dynamic game field.
|
|
Initially it seemed plausible this might have to work on more than
stage nodes, like composite or ephemeral constructions involving the
same aabb/pos/origin types, but it doesn't seem to be the case for
now so operate on the higher order node and stage types.
Also makes it simpler to stick logic conditional on node state inside
the function...
|
|
Just pass in the boolean setting rather than having different
functions.
|
|
Callers of libstage may be middle abstractions which don't actually
have any SDL dependency, don't unnecessarily introduce one by forcing
them to include SDL headers.
|
|
There was too much fractional math happening at once resulting in
artifacts like nodes sharing the same position jiggling relative to
eachother as they moved. Instead compute the various values discretely,
flooring their values.
This also integrates the node origin, which previously was ignored.
A clamp has also been added to prevent zero-size nodes in rect w or h when
their AABB dimensions are non-zero.
|
|
A way to specify how the node's position relates to the node's
AABB rather than always being centered.
An origin of -1,-1 would place position at the bottom left corner
of the node's AABB, and +1,+1 the top right corner.
|
|
Starting to get an inkling of a need for a more hierarchical structure for
the stage. Something which allows arbitrary grouping of nodes which can
then be moved around and even scaled as one at the parent.
|
|
|
|
It's desirable to be able to fit dimensions to an aspect ratio prior
to stage creation. Since stage creation requires an SDL2 Renderer,
it must already have the window etc. Turn this into a lower level
helper for fitting so the window can be sized before creating the
renderer from it.
Should probably name it differently, but this is fine for now.
|
|
Convenient for whole-stage fades...
|
|
|
|
Leaving the existing node aabb semantics as both sizing and placing the
node relative to the stage size and its center, add a simple means of
statefully shifting the aabb.
When the position is left unset, it's 0,0, and effectively a noop leaving
the aabb to exclusively size and place the node. If you treat the aabb
as purely sizing the node, treating it as centered at 0,0 then you can
exclusively use this position api for placement of the node.
|