diff --git a/src/lib.rs b/src/lib.rs index e1920f6..e1a9d39 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -245,14 +245,28 @@ pub enum StyleVar { // --- Context ----------------------------------------------------------------------------------- // TODO(4bb4) Do this properly. +// I already added a simple Context struct that can be created once and used as long as it is not +// dropped here for initial tests - this is of course neither threadsafe nor otherwise safe to use +// unless one "does it right", so it's not a real solution. +// // The context should have to be created, and ideally it should be difficult to impossible // to do things without having a context. implot-rs makes it so that there is a context and // that context has a "frame()" function that returns a Ui, and that Ui is then used to create // widgets. Windows are built with a build() function that takes a reference to that Ui as an // argument, but also have a begin() function that take a context and put it in their token. // -// I think I'll mirror that here. Adding some simple start and end functions for initial testing -// though. +// I think I'll mirror that here, except that we don't need a frame() function, it's enough +// to create a context once and then keep passing it around. I'll hence need a mutex and +// a mechansim similar (or equal) to what imgui-rs does for making sure there can only be +// a single context. Implementation could go roughly like this: +// +// - Add a mutex for modifying context things +// - Make creation and drop functions use that mutex +// - Change Plot, PlotLine, PlotScatter, PlotBars, PlotText to all require a context. +// I think I'll call this PlotUi to mimmick imgui-rs' Ui. +// - Think about what this means in terms of the stacks and things like is_plot_hovered() - +// they should also only work when there is a context available. +// pub struct Context { raw: *mut sys::ImPlotContext, }