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

ISSUE#1977. AModule implements module actions call #2019

Merged
merged 1 commit into from
Mar 1, 2023

Conversation

LukashonakV
Copy link
Contributor

@LukashonakV LukashonakV commented Feb 20, 2023

Hi @Alexays
This PR is based on the #1977
The main idea - to stop of the code duplication in every modules when the module has to extend it's functionality via internal module member-functions.
So

  1. IModule interface is extended by the doAction method
  2. AModule has got it's own base doAction: 1. defines internal mapping between event name and module action name. 2. Calls override doAction.
  3. Each module can provide it's own doAction which actually calls internal module functionality. Module action name is provided through function parameter
  4. If Module overrides doAction and implements all necessary functionality via member-functions and has got internal mapping ... it could drop override handleToggle and handleScroll methods.

Es an example... module Clock now provides all necessary functionality and implement doAction which provide to user an ability to redefine events for intenral actions.(If PR is OK, all actions will be described in WIKI)

 "clock": {
        "format": "{:%H:%M}  ",
        "format-alt": "{:%A, %B %d, %Y (%R)}  ",
        "tooltip-format": "\n<small><tt>{calendar}</tt></small>",
        "calendar": {
                    "mode"          : "year",
                    "mode-mon-col"  : 3,
                    "weeks-pos"     : "right",
                    "on-scroll"     : 1,
                    "format": {
                              "months":     "<span color='#ffead3'><b>{}</b></span>",
                              "days":       "<span color='#ecc6d9'><b>{}</b></span>",
                              "weeks":      "<span color='#99ffdd'><b>W{}</b></span>",
                              "weekdays":   "<span color='#ffcc66'><b>{}</b></span>",
                              "today":      "<span color='#ff6699'><b><u>{}</u></b></span>"
                              }
                    },
        "actions": {
                   "on-click-right": "mode",
                   "on-click-forward": "tz_up",
                   "on-click-backward": "tz_down",
                   "on-scroll-up": "shift_up",
                   "on-scroll-down": "shift_down"
                    }

So for now:

  1. AModule is responsible for config parsing ("actions" section)
  2. AModule handles users events (press buttons, wheel)
  3. AModule when it needs calls module doAction in order to call module action
  4. Clock got from the AModule which action should be executed
  5. Clock defines internal function through function pointer and executes necessary functionality

This PR provides an opportunity to any module to focus on internal action implementation. And don't care about event functionality implementation via overriding of the handleToggle, handleScroll functions

@LukashonakV
Copy link
Contributor Author

Hi @Alexays , any update here?

@LukashonakV
Copy link
Contributor Author

LukashonakV commented Feb 28, 2023

@Alexays , up ) If you've got any concerns please let me know )

Signed-off-by: Viktar Lukashonak <myxabeer@gmail.com>
@Alexays
Copy link
Owner

Alexays commented Mar 1, 2023

Sorry for the delay, LGTM thx :)

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.

2 participants