Allow the support of multiple different graphics contexts.
Within a "context" all graphics related state is stored. This includes the current graphics and text viewports, selected colours, selected fonts, and cursor-related information.
Swapping to a different context will allow for a different set of graphics state to be used. Thus one can have multiple text viewports, for instance, each with their own current font.
Information on the commands to use this new feature will be added here soon.
TODO:
[x] Make the text cursor exist and flash again
[x] Re-order functions in context.h and the various context/*.h files for better understandability/maintainability
[x] Move screen mode changing functionality into agon_screen.h
[x] work out what changing screen modes means for multiple contexts - do we reset back to just one?
stack gets deleted. saved contexts cleared out
this will need some revisiting when we support multiple command processors
[x] Implement "context reset" functionality
done, in the context of reset after a mode change
also now done with added options
[x] track or move more things into context:
[x] penWidth
[x] line pattern, and pattern length
[x] currently selected bitmap
[x] char to bitmap mappings
printerOn ?
it's unclear to me where this setting truly belongs. this may make sense within context, tracked within individual stream processors, or as a global setting. for now it's staying as a global setting
[x] Implement context management API
actual API differs from first sketch - documentation to follow, eventually
[x] select (by ID, making a new context if necessary by copying current context)
[x] reset
[x] copy (make a new context copying existing one, and select it)
[x] delete
[x] save (as numbered context for later selection) ?
dependent on exact API design, if we have automatic context creation this could be useful
[x] save
similar in concept to the saveGState() call in Apple's Core Graphics - save a copy of the current context to a stack
this would be an alternative way to create a new state without using "select"
[x] save and select ?
push current context to stack, and select a numbered context to replace it. this would be similar to calling push and then select, but would omit the creation of a new context that would otherwise just get thrown away
[x] restore
similar in context to restoreGState() in Core Graphics - restoring to last context
[x] restore all
effectively just pop until you can't pop no more... you'd be left at the original (top-level) context from the stack
[x] clear stack ?
this would remove the stack history, leaving your current context unaffected
[x] selectStack ?
wild and crazy idea to save the whole current stack of graphics contexts...
having said that, if we support context stacks, this may replace plain "select"
this is what has happened :grinning:
This PR builds on the multi-font work of #198 and includes all of that code
Allow the support of multiple different graphics contexts.
Within a "context" all graphics related state is stored. This includes the current graphics and text viewports, selected colours, selected fonts, and cursor-related information.
Swapping to a different context will allow for a different set of graphics state to be used. Thus one can have multiple text viewports, for instance, each with their own current font.
Information on the commands to use this new feature will be added here soon.
TODO:
context.h
and the variouscontext/*.h
files for better understandability/maintainabilityagon_screen.h
printerOn ?copy (make a new context copying existing one, and select it)save (as numbered context for later selection) ?saveGState()
call in Apple's Core Graphics - save a copy of the current context to a stackrestoreGState()
in Core Graphics - restoring to last contextselectStack ?This PR builds on the multi-font work of #198 and includes all of that code