Page 11 of 15
Re: EditorFactory - Module for object management in a Canvas
Posted: Fri Jan 20, 2023 7:19 am
by STARGÅTE
I will take a look this weekend.
Re: EditorFactory - Module for object management in a Canvas
Posted: Sat Jan 21, 2023 2:47 pm
by STARGÅTE
Writing an SaveObject/LoadObject is not that easy.
Storing all static or numeric properties is no problem, but there is a problem when you use callbacks, custom cursors, or objects with frames:
- In case of callbacks, I cannot save just the callback pointer, how it is stored during runtime. Because, such pointer become invalid after restarting the program. So, callbacks have to stored by names, but then you (or we) need the Runtime-Library of PureBasic and define callbacks via "Runtime Procedure RuntimeProcedure()" to have access via GetRuntimeInteger("RuntimeProcedure()"). Here, the string can be then saved in a file. This way would be fine for me.
- In case of custom cursors for the objects and the handles, I have no idea how to store such information into the file. The only why I see here, is to save the corresponding image as base64 encoded data.
- In case of objects with frames, the question is, if child objects should saved as well. And if, should they keep their object numbers? Or should they have new unique numbers after loading.
Re: EditorFactory - Module for object management in a Canvas
Posted: Sun Jan 22, 2023 1:15 am
by superadnim
1) I thought the structure would be simpler but the project is quite complex for me I did notice pointers could be an issue if strings could be used to reference them in this way then that's a viable solution!
2) The idea of using base64 is fine you could also just have the path to the file and recognize when the string is a base64 data set by reading the first token just as they do in html. the cool thing about base64 images is that everything becomes self-contained but it may not be the ideal choice for some programs.
3) I would imagine all created objects should be stored and loaded properly retaining all of the original information.
all of this is easier said than done!
Re: EditorFactory - Module for object management in a Canvas
Posted: Sun Jan 29, 2023 5:15 pm
by STARGÅTE
Short intermediate verbal update:
- I have changed the callback functions to string arguments:
Code: Select all
Runtime Procedure Callback_Function(Object.i, Width.i, Height.i, iData.i)
EndProcedure
;...
SetObjectDrawingCallback(#Object, "Callback_Function()")
With this, it is possible to save such a string during object export. During runtime, a normal callback pointer is save as well via GetRuntimeInteger(CallbackName). This method works fine without performance drawbacks.
- In case of handles with images, the images are stored as base64 strings within the JSON. Works fine as well. However, currently all images are saved individually, even if they have the same sources, making the export size huge. This has to be optimized.
- SaveObject() can be used in future to save single objects, all selected objects or all object within a canvas.
- LoadObject() can be used in future to load single objects (while defining a new object id) or multiple objects (while used their exported object IDs).
After some more improvements, I think I can publish this feature next weekend.
Re: EditorFactory - Module for object management in a Canvas
Posted: Mon Jan 30, 2023 12:55 am
by ShadowStorm
so now it will be possible to create its own function of cancellation and restoration of objects, very nice work!
But how to do it ?
For example, only certain objects, or the selected objects if it has some, or all the objects.
And how to do, for example, as soon as there is a change, make a backup....
Not simple but I trust you for that.
great work STARGÅTE

Re: EditorFactory - Module for object management in a Canvas
Posted: Sat Feb 04, 2023 4:34 pm
by STARGÅTE
Dear all,
here is the feature request update for a load and save function for objects.
@superadnim: Please check out, if this works for you. Any feedback is welcome.
New Version 1.18.01
- Added: LoadObject and SaveObject
- Added: Example #7: Example07_SaveAndLoad.pb
- Changed: SetObjectDrawingCallback() needs now the string name of the callback function and keyword Runtime befor Procedure is needed.
Download:
EditorFactory.pbi (Version 1.18.01, 2023-02-04)
EditorFactory-1-18-01.zip (Archive with include and examples)
The include is shared under the CC BY-NC 4.0 licence.
Re: EditorFactory - Module for object management in a Canvas
Posted: Sun Feb 05, 2023 3:32 am
by punak
Thanks for the new version. I hope you will add the (actual design of the splitter object), redo and undo in the future versions.
Re: EditorFactory - Module for object management in a Canvas
Posted: Sun Feb 05, 2023 9:51 pm
by ShadowStorm
punak wrote: Sun Feb 05, 2023 3:32 am
Thanks for the new version. I hope you will add the (
actual design of the splitter object), redo and undo in the future versions.
Hello, cancel and restore is already possible with these functions !
for your request, I may have misunderstood, but I do not think it is useful ?
Can you give some examples ?
Re: EditorFactory - Module for object management in a Canvas
Posted: Thu Feb 09, 2023 6:44 pm
by ShadowStorm
Although it is possible to do it, it is not as simple as that, so maybe your idea will be integrated later but it will take a lot of work.
Re: EditorFactory - Module for object management in a Canvas
Posted: Thu Feb 09, 2023 6:48 pm
by ShadowStorm
A new version should be available soon with some corrections.
Re: EditorFactory - Module for object management in a Canvas
Posted: Wed Feb 22, 2023 12:27 am
by superadnim
fantastic!
one note: when testing the save/load example it somehow removes the top element whenever I load the json file
otherwise it all seems to work fine
I think this feature ties the whole lib together
Re: EditorFactory - Module for object management in a Canvas
Posted: Wed Feb 22, 2023 9:41 am
by STARGÅTE
superadnim wrote: Wed Feb 22, 2023 12:27 am
one note: when testing the save/load example it somehow removes the top element whenever I load the json file
Yes that is right (and a feature). The top element has a fixed ID (1) which is also saved in the JSON file. If you now load this file, EditorFactory creates new elements, but overrights the element with number 1 similar to CreateObject.
However, I will also publish a small bug-fix version soon to fix related issues.
Re: EditorFactory - Module for object management in a Canvas
Posted: Fri Feb 24, 2023 2:02 am
by ShadowStorm
Hello, I am working on some examples, but they will be in French.
- Saving and loading objects in a canvas. = finished
- Undo and restore changes in the editor. = finished
- Cut, copy, paste objects in the editor. = finished
- Creating a small object editor with code generation. = finished
Re: EditorFactory - Module for object management in a Canvas
Posted: Wed Mar 01, 2023 6:16 am
by mestnyi
ShadowStorm wrote: Fri Feb 24, 2023 2:02 am
Hello, I am working on some examples, but they will be in French.
- Saving and loading objects in a canvas. = finished
- Undo and restore changes in the editor. = finished
- Cut, copy, paste objects in the editor. = finished
- Creating a small object editor with code generation. = finished
where are these examples?
Re: EditorFactory - Module for object management in a Canvas
Posted: Wed Mar 01, 2023 11:57 am
by ShadowStorm
Hello mestnyi,
These examples are not yet shared at this time, moreover they are in French as I said.
I have many other examples to give and all are in French but I need to clean up and reorganize them.
Moreover, some of the new examples will have to be revised as soon as certain functionalities that I asked for will be added, I think in a short time depending on the availability of Stargate, that's why I'm waiting a little.
I think I will put the new examples the day of the release of a new version of Editor Factory, Stargate didn't have time to see them too.
And since people don't seem to be interested, I'll wait too.
I want to say that the examples I make are always very well documented in comments, trying to make good examples, it takes time but I like when things are well done.
I'm also looking for people who would be interested in translating my examples from French to English and correcting spelling in the process.