TheMonsterFromTheDeep / vague

Java-based image editor
0 stars 0 forks source link

Improve parenting system #6

Closed TheMonsterFromTheDeep closed 8 years ago

TheMonsterFromTheDeep commented 9 years ago

The parenting system, as I have mentioned previously (talking to myself, of course, in this desolate and lonely repo), is sort of messy.

There are something like 5 draw methods in the module component that do a combination of drawing just the parent, drawing just the child, drawing just a giant smiley face, etc.

This is a real problem because each draw method is named something really ambiguous and therefore it is extremely difficult to distinguish between them.

Part of the reason the parenting system is so ugly is because many of the draw methods are made so that unnecessary graphics processing isn't required. Another reason is because a few of the draw methods are overloaded abstractly or something inside some of the code in Window.java.

A really big problem with the parenting and graphics system is that things are being drawn correctly and I have no idea why.

TheMonsterFromTheDeep commented 9 years ago

A new update: images are now all stores in the static member data of ImageData of type ImageData.

Also, the pane system is going to be updated as such: There will be a general Container class subclassed from Module and two classes: a vertical ModulePane and a horizontal ModulePane that are subclassed from Container.

TheMonsterFromTheDeep commented 9 years ago

The Container class is working moderately well now. It overloads resizeComponent, but it doesn't do it very well because the Container class makes no assumptions about position, so two child modules can supposedly be intersecting each other. In that case, calculating position doesn't necessarily make sense.

However, I think I will update it to update position similarly to size, so in that way it will at least sort of make sense.

TheMonsterFromTheDeep commented 9 years ago

The Container class now works much better. I would like to go through all the module-related code and optimize all drawing code, but aside from that everything is going very well. Resizing works well enough for now, and modules are now relocated properly when the window is resized. Focus also now automatically changes when the mouse is moved and the active child isn't retaining focus.

However, when focus is changed, behavior is strange when there are overlapping modules or no modules underneath the mouse. This is because the Container class requires a module to be active in order to work. I may make the Container focus on a Dummy module if there is no active module. However, behavior is still unpredictable with overlapping modules because the one later in the array that contains the Container's children will become active because of how the for loop works. However, there is no intuitive method for selecting modules, so this works well enough.

TheMonsterFromTheDeep commented 9 years ago

The Container class is now very complete. I've changed how drawing code works a slight bit and I'm going to look through to see if I can prune some redundant methods.

Next I need to make the VerticalModulePane and HorizontalModulePane. I might also make make the Module class no longer abstract so that there is no need for a dummy class and each module doesn't necessarily have to overload every method.

TheMonsterFromTheDeep commented 8 years ago

So the parenting system now works. I am going to close this and merge the branches.