EditorFactory - Module for object management in a Canvas

Share your advanced PureBasic knowledge/code with the community.
ShadowStorm
Enthusiast
Enthusiast
Posts: 237
Joined: Tue Feb 14, 2017 12:07 pm

Re: EditorFactory - Module for object management in a Canvas

Post by ShadowStorm »

ChrisR, please describe what you want with explicit images, because I don't really understand what you want.
Well it was not planned all this and it delays us for the rest but ok why not :)
I think we need to simplify all this.
I am French, I do not speak English.
My apologies for the mistakes.

I have sometimes problems of expression
I am sometimes quite clumsy, please excuse me and let me know.
User avatar
STARGÅTE
Addict
Addict
Posts: 2063
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: EditorFactory - Module for object management in a Canvas

Post by STARGÅTE »

Any comments to the second part of my last post? viewtopic.php?p=565760#p565760
STARGÅTE wrote:As I can see, you want to use the images of PB gadget as object images, but for now you have no access to interact with this images (like clicking on the scroll bar or on a panel tab). Up to now I'm not sure how I/we can handle this without program the whole gadget itself, which is not the purpose of this include.
Would it help if I include an additional callback, which is called during the event handling? In this callback you would then have access to the local mouse cursor position and mouse events to check for clicks and hovers.
But how do you know the metrics/dimensions of the scrollbar or a tab in a panel gadget?
@ChrisR: In case of a panel gadget: Is Panel_ItemWidth, Panel_ItemHeight needed? Isn't it just parent width - 3 and parent height - 25 ?
Defining the frame properties during adding is a good idea. However, you need to widths and heights right?
The view port size (with out scrollbars) and the inner frame size?
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
ChrisR
Addict
Addict
Posts: 1124
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: EditorFactory - Module for object management in a Canvas

Post by ChrisR »

With a little delay,
For the Panel, I use
. the Left border and GetGadgetAttribute(Gadget, #PB_Panel_ItemWidth)
. the Top border and GetGadgetAttribute(Gadget, #PB_Panel_ItemHeight)

It might be useful if a frame could be defined with (Left OffSet, Top OffSet, InnerWidth, InnerHeight)
To define the Frame offset and also the child boundary from iX=0, iY=0 to the Inner size.

Image

Same for the ScrollAreaGadget and then you have to play with SetObjectFrameClipping according to GadgetWidth(Height) and if Scroll Bar are displayed or not.

Code: Select all

If (GetWindowLongPtr_(GadgetID(Gadget), #GWL_STYLE) & #WS_VSCROLL) => GetSystemMetrics_(#SM_CXVSCROLL)
If (GetWindowLongPtr_(GadgetID(Gadget), #GWL_STYLE) & #WM_HSCROLL) => GetSystemMetrics_(#SM_CYHSCROLL)
Otherwise, I don't know what to think about your additional callback idea.
It would probably be a bit complicated to use the mouse position and all the metrics to simulate the clicks and movement of the Scroll Bar.
It is much easier by using AddObjectHandle to add the arrows.
User avatar
STARGÅTE
Addict
Addict
Posts: 2063
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: EditorFactory - Module for object management in a Canvas

Post by STARGÅTE »

For the PanelGadget the definition of (Left OffSet, Top OffSet, InnerWidth, InnerHeight) and you picture is clear,
because in a PanelGadget the inner area is not smaller or larger, meaning no scrollbars included.
But in case of a ScrollAreaGadget you have on one hand the offset and inner size (the visible area) and on the other hand the content offset and content area size.

Here the image what I mean:

Image

So in principal you would need:
AddObjectFrame(Object, FrameIndex, ViewBoxX, ViewBoxY, ViewBoxWidth, ViewBoxHeight, InnerAreaX, InnerAreaY, InnerAreaWidth, InnerAreaHeight).

In case of a PanelGadget:
ViewBoxX = 3, ViewBoxY = 25, ViewBoxWidth = "#PB_Panel_ItemWidth", and ViewBoxHeight = "#PB_Panel_ItemHeight"
InnerAreaX = 0, InnerAreaY = 0, InnerAreaWidth = ViewBoxWidth, and InnerAreaHeight = ViewBoxWidth
Should it be then possible to move an inner object over the border?

In case of a ScrollAreaGadget:
ViewBoxX = 3, ViewBoxY = 3, ViewBoxWidth = ..., and ViewBoxHeight = ...
InnerAreaX = "#PB_ScrollArea_X", InnerAreaY = "#PB_ScrollArea_Y", InnerAreaWidth = "#PB_ScrollArea_InnerWidth", and InnerAreaHeight = "#PB_ScrollArea_InnerHeight"
Same here: should it be then possible to move an inner object over this inner size border, or should it be blocked by the boundary?
Last edited by STARGÅTE on Fri Mar 05, 2021 12:27 am, edited 1 time in total.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1243
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: EditorFactory - Module for object management in a Canvas

Post by Paul »

@STARGÅTE ... this is off topic ;)
Not sure if anyone else has this problem but none of the images you link to are viewable here. Even your avatar image is a broken link. Maybe it has to do with the forum being https and your links are http ??
Image Image
User avatar
STARGÅTE
Addict
Addict
Posts: 2063
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: EditorFactory - Module for object management in a Canvas

Post by STARGÅTE »

Good point Paul. I fixed these issues now. Did it work for you?
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Axolotl
Enthusiast
Enthusiast
Posts: 432
Joined: Wed Dec 31, 2008 3:36 pm

Re: EditorFactory - Module for object management in a Canvas

Post by Axolotl »

sorry for jumping in. Everything looks perfect here.
Mostly running PureBasic <latest stable version and current alpha/beta> (x64) on Windows 11 Home
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1243
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: EditorFactory - Module for object management in a Canvas

Post by Paul »

STARGÅTE wrote:Good point Paul. I fixed these issues now. Did it work for you?
Perfect! :D
Image Image
ShadowStorm
Enthusiast
Enthusiast
Posts: 237
Joined: Tue Feb 14, 2017 12:07 pm

Re: EditorFactory - Module for object management in a Canvas

Post by ShadowStorm »

Hello, could you answer to Stargate, the project is at the stop because it has no answer :( , we take delay, thank you :wink:
I am French, I do not speak English.
My apologies for the mistakes.

I have sometimes problems of expression
I am sometimes quite clumsy, please excuse me and let me know.
User avatar
ChrisR
Addict
Addict
Posts: 1124
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: EditorFactory - Module for object management in a Canvas

Post by ChrisR »

STARGÅTE wrote:Should it be then possible to move an inner object over the border?

Same here: should it be then possible to move an inner object over this inner size border, or should it be blocked by the boundary?
For my part, I do not have the answer and Stargate knows better.

For me, an inner object should be blocked by its border, its boundary
But maybe I am wrong, Windows allows to go beyond the borders. In this case, it displays only the part of the object inside the internal area (#PB_Panel_ItemWidth(Height) for a panel). The other part is cut out, not drawn as it is done by using SetObjectFrameClipping() in Editor Factory.
for a designer, I would tend to say that it would be better to respect the borders that serve as boundaries.

Code: Select all

OpenWindow(0, 0, 0, 320, 240, "", #PB_Window_SystemMenu)
PanelGadget(0, 0, 0, 320, 240)
AddGadgetItem(0, -1, "Tab 1")
ButtonGadget(1, -20, -20, 100, 40, "MyButton1")
ButtonGadget(2, 240, 190, 100, 40, "MyButton2")
CloseGadgetList()

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
User avatar
STARGÅTE
Addict
Addict
Posts: 2063
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: EditorFactory - Module for object management in a Canvas

Post by STARGÅTE »

Ok, but you are fine with such definition?

Code: Select all

AddObjectFrame(Object, FrameIndex, ViewBoxX, ViewBoxY, ViewBoxWidth, ViewBoxHeight, InnerAreaX, InnerAreaY, InnerAreaWidth, InnerAreaHeight).
However the last parameters are optionally like:

Code: Select all

AddObjectFrame(Object[, FrameIndex[, ViewBoxX, ViewBoxY, ViewBoxWidth, ViewBoxHeight[, InnerAreaX, InnerAreaY, InnerAreaWidth, InnerAreaHeight]]]).
meaning:
- if no InnerArea is defined, it has the size of the parent object
- if no ViewBox is defined, is become the size of the parent object.
- if no FrameIndex is defined, a frame at the end is added.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
ChrisR
Addict
Addict
Posts: 1124
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: EditorFactory - Module for object management in a Canvas

Post by ChrisR »

That sounds good to me except for InnerAreaX(Y) which I don't really see the use for Windows controls. It is, in this case, the same as ViewBoxX(Y)

Code: Select all

AddObjectFrame(Object, FrameIndex [, ViewBoxX, ViewBoxY, ViewBoxWidth, ViewBoxHeight [, InnerAreaWidth, InnerAreaHeight]])
But it may be a good to keep these 2 values for other cases, Splitter for example or for other uses than in a Designer.
So it looks good with your definition

Code: Select all

AddObjectFrame(Object[, FrameIndex[, ViewBoxX, ViewBoxY, ViewBoxWidth, ViewBoxHeight[, InnerAreaX, InnerAreaY, InnerAreaWidth, InnerAreaHeight]]])
It's in conditional, I'm not sure that I'm the right guy to answer, there are a lot of guys much more experienced than me around, starting with you, of course :wink:
User avatar
ChrisR
Addict
Addict
Posts: 1124
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: EditorFactory - Module for object management in a Canvas

Post by ChrisR »

Unrelated!
An idea to mature for the future of your module, if you wish, would be to have the borders of one object that serve as boundaries for other objects with the overlap prohibited.
I am thinking for example of kitchen design tools
User avatar
STARGÅTE
Addict
Addict
Posts: 2063
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: EditorFactory - Module for object management in a Canvas

Post by STARGÅTE »

Now I can hear ShadowStorm laughing, because he had also suggested it during a discussion with me.
I will go forward and finalize the frame stuff first.

Thank for your contribution.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
ShadowStorm
Enthusiast
Enthusiast
Posts: 237
Joined: Tue Feb 14, 2017 12:07 pm

Re: EditorFactory - Module for object management in a Canvas

Post by ShadowStorm »

ChrisR wrote:Unrelated!
An idea to mature for the future of your module, if you wish, would be to have the borders of one object that serve as boundaries for other objects with the overlap prohibited.
I am thinking for example of kitchen design tools
Indeed, I had asked this too.

But even better, decide with which object it can or cannot collide (overlap).

For example, Object A can't overlap with Object B.
Of course Object B can't overlap Object A either.

And I would also have liked to set up a system of magnetization of objects.

For example when an object approaches another, from a certain distance (configurable), the two objects are attracted (stuck), like magnets.

We can imagine for example to make puzzles or then graphic elements to make for example graphic language, in the style of "Scratch".

I also had the idea to be able to link objects with the "links", in this kind of way:
https://www.purebasic.fr/french/viewtop ... =3&t=17751

But there, it may become a little more complicated, to see.
There are still a lot of things to set up.

In short, beautiful things to come if Stargate wants it.
I am French, I do not speak English.
My apologies for the mistakes.

I have sometimes problems of expression
I am sometimes quite clumsy, please excuse me and let me know.
Post Reply