burhanrashid52 / PhotoEditor

A Photo Editor library with simple, easy support for image editing using paints,text,filters,emoji and Sticker like stories.
MIT License
4.13k stars 991 forks source link

Allow access to objects from outside (remove some private's) #371

Closed anderbytes closed 3 years ago

anderbytes commented 3 years ago

Would it be possible to let be public the array of Views created inside the editor?

Sometimes we need to customize an added text or another object in a way that your current methods doesn't support, and creating SEVERAL methods inside your app just to do some simple changes isn't very productive.

burhanrashid52 commented 3 years ago

Can you share a usecase or example ?

anderbytes commented 3 years ago

Can you share a usecase or example ?

Providing an array of the TextViews, ImageViews, etc from inside the editor would make it possible for us developers to widely customize their behaviour, content, etc without having to create withText this witText that...

if the editor would provide a simple List and List and other as such, and made their objects public, we devs would be responsible for any visual customization, instead of making you responsible for creating those "doors".

If what I think was possible, wouldn't be any need of withTextShadow, withTextColor, withTextFont, etc etc etc... we would just control it as a regular object.

As is it today, it just seems that the editor , for some reason, "needs" to intermediate those simple customization that these views and widgets already.

Instead of TextStyleBuilder class, we would edit color of a text as simple as:

val texts = PhotoEditorViewObject.Texts
for (t in texts) {
    t.textColor = R.color.some_color
}

that above would be enough to change all the text colors to one specific color. Or the dev could use "ifs" to change a specific one, or even put "t" object in another variable and work across the code, doesn't matter.

burhanrashid52 commented 3 years ago

We have this discussion before. Doing this will exposing too much.

Internally PhotoEditor set touche listeners on views to scale and rotate and some state saves inside view object. If we expose views to the client they can change or remove all the listener and state on the view which will break PhotoEditor and causes expected bugs. https://github.com/burhanrashid52/PhotoEditor/issues/280#issuecomment-711985683

It's not advisable, but If you want to customize on that level you can excess those views PhotEditotView.getChildren() method which will return all the views.

anderbytes commented 3 years ago

Got it... I just managed to used getChildren to do some customizing already, it's not as flexible and structured as hoped, but it works. Thanks!