Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial revert of #141 and improved properties #142

Merged
merged 8 commits into from
Mar 24, 2023

Conversation

notEvil
Copy link

@notEvil notEvil commented Mar 12, 2023

Hi,

I didn't consider #141 final (#139 (comment)) so this PR partially reverts its changes.

Instead of having separate containers for id, style, layout(, state) as proposed, I found that improving the way changes are applied already provides better separation and fits previous conventions. Essentially

  • PropertiesProxy (previously StylePropertiesProxy) now triggers the changed event with name == null when multiple properties changed, and name != null && value == null when properties are deleted
  • PropertiesProxy.onChange is called by widgets instead of Styler
  • the change callback passes name and value to various functions: Styler.apply and WidgetHelper.applyLayoutParams
  • the functions either apply everything or only what is necessary

To review this, it is probably better to compare with 3c4024e and consider it a replacement for #141 which I consider inferior and less backwards compatible. Sorry!

If you agree, I would also add "content" (text, checked, ...) back to props.

Changes

  • reverted
    • removed id, x, y, w, h from props
    • PViewMethodsInterface: added method id()
    • PUI.getViewById: changed argument type from String to int
    • PViewsArea: removed method addView(PViewMethodsInterface)
  • api/widgets: renamed StylePropertiesProxy to PropertiesProxy
  • api/PUI: renamed getStyle to getProps
  • api/widgets/PropertiesProxy: changed methods remove, putAll, clear to trigger changed event
  • api/widgets/PropertiesProxy: added methods change() and change(String, Object)
  • api/widgets/PropertiesProxy: implemented methods has, delete, getIds, getDefaultValue, hasInstance
  • api/widgets/PropertiesProxy.containsValue: fixed bugs related to calls the wrong method
  • api/widgets/PropertiesProxy.put(String, Object): fixed bugs related to doesn't return the previous value
  • api/widgets/Styler: added methods apply(String, Object) and apply(String)
  • api/widgets/Styler: moved put id to PropertiesProxy()
  • api/widgets/Styler: moved methods fromTo and setProps to WidgetHelper
  • api/widgets/Styler: removed methods setX, setY, setWidth and setHeight in favor of WidgetHelper.applyLayoutParams
  • api/widgets/WidgetHelper: added method applyLayoutParams

notEvil added 3 commits March 12, 2023 12:13
  - removed id, x, y, w, h from props
  - PViewMethodsInterface: added method id()
  - PUI.getViewById: changed argument type from String to int
  - PViewsArea: removed method addView(PViewMethodsInterface)
- api/widgets: renamed StylePropertiesProxy to PropertiesProxy
- api/PUI: renamed getStyle to getProps
- api/widgets/PropertiesProxy: changed methods remove, putAll, clear to trigger changed event
- api/widgets/PropertiesProxy: added methods change() and change(String, Object)
- api/widgets/PropertiesProxy: implemented methods has, delete, getIds, getDefaultValue, hasInstance
- api/widgets/PropertiesProxy.containsValue: fixed bugs related to calls the wrong method
- api/widgets/PropertiesProxy.put(String, Object): fixed bugs related to doesn't return the previous value
- api/widgets/Styler: added methods apply(String, Object) and apply(String)
- api/widgets/Styler: moved put id to PropertiesProxy()
- api/widgets/Styler: moved methods fromTo and setProps to WidgetHelper
- api/widgets/Styler: removed methods setX, setY, setWidth and setHeight in favor of WidgetHelper.applyLayoutParams
- api/widgets/WidgetHelper: added method applyLayoutParams
…eturn this

- api/widgets/PLinearLayout.add: changed to behave like PAbsoluteLayout.addView
- api/widgets/PLinearLayout: added method add(View, String, Object, Object, float)
@notEvil
Copy link
Author

notEvil commented Mar 12, 2023

Hope you don't mind the regression fix for #137 and fix for #140 in here. The former is related insofar as the bug was introduced in the previous PR and the latter improves PLinearLayout with respect to properties w, h.

@victordiaz
Copy link
Owner

Hi!
Sorry for merging the previous PR too quickly. I thought it was ready to roll :)

I just had a quick read on the changes and this direction seems right to me.

If you agree, I would also add "content" (text, checked, ...) back to props.
Yes, that would be great!

I will refrain my self to approve and merge it too quickly this time :)

  - x, y, w, h, textAlign, textColor, textFont, textSize, textStyle, background, text
  - PImage: srcMode
  - PInput: hint, multiline
  - PKnob: decimals, from, to, value
  - PLinearLayout: orientation, horizontalAlign, verticalAlign
  - PList: columns, stackFromEnd
  - PMap: controls, maxZoom, minZoom, multitouch, online, zoom
  - PSlider: decimals, from, mode, to, value, vertical
  - PSpinner: align
  - PText: autoFit, scrollable
  - PToggle: checked, textOff, textOn
- api/widgets/PKnob: replaced class KnobStyler with method apply
- api/widgets/PSlider: replaced class SliderStyler with method apply
- api/widgets/PToggle: replaced class ToggleStyler with method apply
- api/widgets/Styler: changed to support custom textAlign, textColor, textFont, textStyle
- api/widgets/WidgetHelper: renamed method applyLayoutParams to applyViewParam
- api/widgets: added properties enabled, visibility
- api/PUI: changed to apply theme changes like props changes
- api/PUtil.sizeToPixels: changed to support constants
@notEvil
Copy link
Author

notEvil commented Mar 13, 2023

nP :)

The PR is ready to test and review now. I ran the GUI examples and my application, and they seem fine. The commit messages should summarize the changes for an easier review. If you have any doubts, let me know!

notEvil added 4 commits March 13, 2023 16:58
- examples: added example Linear Layout
  - PPlot: max, min, name
  - PTextList: autoScroll
- api/widgets/PPlot: replaced class PlotStyler with method apply
- api/widgets/PKnob: added property autoTextSize
Copy link
Owner

@victordiaz victordiaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@notEvil I'm approving and merging the PR.

The only think I might change at some point in the future is the example you added to simplify it a tiny bit. I really appreciate that you added!

Thanks so much for your effort!

@victordiaz victordiaz merged commit 1faa406 into victordiaz:develop Mar 24, 2023
@notEvil
Copy link
Author

notEvil commented Mar 24, 2023

Great :)

Just for reference:

  • I removed dead code that might have served a purpose in the past. It was mostly related to styling and sometimes behavior, API or design (elements).
  • The way properties are initialized is problematic for specializations because the base constructor doesn't cooperate, e.g. see CustomView and PPlot
  • Some widgets exist in code but aren't fully implemented, e.g. PCheckBox

So it might be worthwhile to revisit each widget and see if it fullfills its purpose and has all relevant properties. If you would write a list of things to improve, I'd certainly contribute! :)

The only think I might change at some point in the future is the example

I agree, its too complicated.

@victordiaz
Copy link
Owner

victordiaz commented Mar 24, 2023

I noticed the removed code. Thanks for doing it. Many things were intentions that never resolved :) So better removed for clarity.

Regarding the tasks, there is 4 things that I wanted to have since long time

  1. a visual UI builder.
  2. some machine learning for vision stuff. There is some working code already for training and detecting images using the camera. The pace of AI models is so fast that probably feels quite obsolete already. For this, the first action would be replacing the PCamera code which uses the old Camera API to CameraX API. Then see if it makes sense to keep using Tensorflow, Mediapipe or whatever new solution is there. I have some scripts working in case you are interested
  3. APK creation via an Android template where you can place your user scripts and build an standalone APK. This is something that worked long time ago but it got lost. Many people asked for this but I never found the time to get it done :/ If you see the project it is separated into 2 parts. The App and the AppRunner. So basically is just creating an Android module that loads an script and uses the AppRunner to execute it.
  4. Better documentation. I know you did some code parsing already :)

If there is something that interests you from this list (or something else) I'd be more than happy to support you in any way.

@notEvil
Copy link
Author

notEvil commented Mar 26, 2023

I meant improvements regarding widgets and layout, since this is where I can reuse the knowledge I have atm. For the other things I fear my knowledge (e.g. vue, ML on Android, app bundling) doesn't suffice and their absence don't bug me enough to commit to it. The documentation however is an area where you might see a PR in the future! (didn't start yet)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants