summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-08-27gitmodules: s/git:/https:/HEADmasterVito Caputo
Switching to https since it's less likely to be blocked and harder to MITM than git://.
2020-06-12libstage: add return value to stage_render_func_tVito Caputo
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.
2020-05-29bootstrap: switch to autoreconf --installVito Caputo
The old stuff didn't seem to work with BUILT_SOURCES
2020-05-29libstage: support caller-supplied stage memoryVito Caputo
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.
2020-05-29libstage: only free stage memory when allocatedVito Caputo
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.
2020-05-29libstage: add stage, rename adopt->replace in stage_conf_tVito Caputo
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().
2020-04-20libstage: introduce 'adopt' flag to stage_conf_tVito Caputo
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.
2020-04-20libstage: return stage_t* from stage_replace()Vito Caputo
also from internal _stage_set_object() for better ergonomics
2019-10-07.gitignore: ignore autotools junkVito Caputo
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"
2019-09-16libstage: set initial dirty state via stage_conf_tVito Caputo
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.
2019-09-05libstage: don't prepare at root if inactiveVito Caputo
2019-08-27libstage: drop stage_lookup_key/stage_lookup_func_tVito Caputo
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.
2019-08-27libstage: encapsulate stage funs in an ops structVito Caputo
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.
2019-06-12libstage: introduce stage_conf_t for stage_new()Vito Caputo
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.
2019-06-12libstage: cast lookup result silencing const warnVito Caputo
2019-06-12libstage: introduce prepare_func and prepare passVito Caputo
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.
2019-06-12libstage: add rudimentary dirty stateVito Caputo
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.
2019-05-29libstage: s/match/lookup/gVito Caputo
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.
2019-05-10libstage: add pass-thru pointer to stage_render()Vito Caputo
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.
2019-05-10libstage: add stage_lookup_key()Vito Caputo
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.
2019-05-10libstage: introduce stage_match_func_tVito Caputo
Preparation for adding stage_lookup_key() to search a stage heirarchy by an opaque key the per-node functions know how to compare against.
2019-05-10libstage: drop pointer from func_t typedefsVito Caputo
Cosmetic readability change, I don't like to typedef pointer types
2019-05-10libstage: add missing gettersVito Caputo
some trivial rearranging as well
2019-05-10libstage: move stage_[sg]et_object() by othersVito Caputo
2019-05-10libstage: return values from gettersVito Caputo
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.
2019-05-10libstage: remove vestigial stage_fit()Vito Caputo
This hasn't belonged in libstage since losing all dimensionality
2019-05-10libstage: add some rudimentary assertsVito Caputo
2019-05-10libstage: deprecate stage_node_*, go heirarchicalVito Caputo
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.
2019-05-10libstage: s/dll_pre/dll_add_pre/gVito Caputo
2019-05-10dll_h: sync with upstream for dll_add_(pre|post)Vito Caputo
2019-05-07libstage: update copyright linesVito Caputo
2019-05-07libstage: use dll.h for linked lists, rm list.hVito Caputo
2019-05-07dll_h: move to include/dll_hVito Caputo
2019-05-07dll_h: add dll_h linked list header submoduleVito Caputo
Preparing to discard src/list.h
2018-09-11libstage: remove SDL2 dependency from configure.acVito Caputo
Now that libstage has no coupling to the rendering backend, there's no need for this.
2018-09-11libstage: remove everything dimensionalVito Caputo
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.
2018-07-12libstage: add {position,aabb}_map concept to stageVito Caputo
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.
2018-06-11libstage: add alternate node mappingsVito Caputo
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.
2018-06-09libstage: add stage_node_set_static()Vito Caputo
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.
2018-06-09libstage: simplify aabb_to_rect to operate on nodeVito Caputo
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...
2018-06-09libstage: simplify set active and locked node apiVito Caputo
Just pass in the boolean setting rather than having different functions.
2018-06-09libstage: forward declare SDL types in stage.hVito Caputo
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.
2018-05-24libstage: rewrite aabb_to_rect() for less errorVito Caputo
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.
2018-05-24libstage: add stage_node_[sg]et_origin()Vito Caputo
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.
2018-05-24libstage: add stage_[sg]et_position()Vito Caputo
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.
2018-05-24libstage: use v2f_t instead of float x,y in apiVito Caputo
2018-05-24libstage: decouple stage_fit() from stage_tVito Caputo
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.
2018-05-15stage: add stage_[sg]et_alpha()Vito Caputo
Convenient for whole-stage fades...
2018-05-14LICENSE: add copy of GPLv3Vito Caputo
2018-05-04stage: introduce stage_node_[sg]et_position()Vito Caputo
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.
© All Rights Reserved