simonkrauter / NiGui

Cross-platform desktop GUI toolkit written in Nim
MIT License
718 stars 51 forks source link

Code organization #92

Open matdhart opened 4 years ago

matdhart commented 4 years ago

The nigui.nim file is 2750 lines of code. Portions of the file would be easy to abstract away (into another file). I believe this would help code organization and make contributing much less intimidating

simonkrauter commented 4 years ago

You're right, good point.

shoaib-mi commented 2 years ago

If you don't mind, I would like to suggest some changes that may organize the code better. I have already done that and it caused no changes in the code's performance.

In the file nigui.nim:

    Move Lines 219 and 220 to line 10 after the line `template useGtk(): bool = not useWindows()`

    Move Lines 11 to 453 to two other files named `All_Types_Linux` and `ALL_Types_Windows`

    put below lines in line 14 after the line `const inactiveTimer* = 0`
        # Platform-specific extension of Window and Control:
        when useWindows(): include "All_Types_Windows"
        when useGtk():     include "All_Types_Linux"

    Move lines 455 to 1133 to another file named `Predeclared_Procedures`

    Add line `include "Predeclared_Procedures"` at line 18 

    the rest of the file remained unchanged except for removing some blank lines

In the file All_Types_Linux:

    Remove all `type` keywords that separated the different types, so that now all the types are defined with one keyword `type`. 

    Modify all `enum` types from multiline discription into single line

    Replace the lines
        when useWindows(): include "nigui/private/windows/platform_types1"
        when useGtk():     include "nigui/private/gtk3/platform_types1"

        when useWindows(): include "nigui/private/windows/platform_types2"
        when useGtk():     include "nigui/private/gtk3/platform_types2"

        when useWindows(): include "nigui/private/windows/platform_types3"
        when useGtk():     include "nigui/private/gtk3/platform_types3"

    with contents of files `platform_types1`, `platform_types2` and `platform_types3`, and offcourse removing keyword `type`.

    Move below lines before definition of `NativeTextArea`
         TextArea* = ref object of NativeTextBox
            fWrap: bool