{"id":22757440,"url":"https://github.com/clemapfel/rg_backup_0623","last_synced_at":"2025-03-30T08:15:12.739Z","repository":{"id":267157797,"uuid":"614536853","full_name":"Clemapfel/rg_backup_0623","owner":"Clemapfel","description":null,"archived":false,"fork":false,"pushed_at":"2023-04-18T00:07:55.000Z","size":695,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T19:51:17.392Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Clemapfel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-15T19:39:27.000Z","updated_at":"2023-06-11T14:55:17.000Z","dependencies_parsed_at":"2024-12-12T22:38:19.030Z","dependency_job_id":null,"html_url":"https://github.com/Clemapfel/rg_backup_0623","commit_stats":null,"previous_names":["clemapfel/rg_backup_0623"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clemapfel%2Frg_backup_0623","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clemapfel%2Frg_backup_0623/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clemapfel%2Frg_backup_0623/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clemapfel%2Frg_backup_0623/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Clemapfel","download_url":"https://codeload.github.com/Clemapfel/rg_backup_0623/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246290720,"owners_count":20753735,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-11T07:18:23.488Z","updated_at":"2025-03-30T08:15:12.718Z","avatar_url":"https://github.com/Clemapfel.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mousetrap\n\n\n# refacotr:\n+ FileMonitor\n+ shape, texture, rendertexture, render_area, render_task, shader\n+ music, sound, soundbuffer\n\u003e \u003e This repo is under rapid active development and should not be interacted with by the public. Licensed CC-BY-SA-NC\n\nGTK4 is well optimized, incredibly powerful and utterly inscrutable. It has hundreds of thousands of lines of code and with functionality split between GTK, GDK, Glib and more,\nlearning the library tsake weeks, meaning many user will feel overwhelmed and never try at all. Mousetrap aims to address this, by\nwrapping GTK4 in a way that is much easier to understand and use, allowing beginners to start developing applications within minutes instead of days.\n\n## Advantages of mousetrap over GTK4\n+ automatic memory management, `new` is unnecessary to be called\n+ complex widgets like `ColumnView` or `TreeView` can be initialized with exactly one line\n+ Adds Image- and Sound-processing utilities, including natively playing sounds at runtime\n+ Adds high-level, fully abstracted OpenGL functionality, such as native 2d shapes, textures, render textures, shaders, blend-modes, transforms and more\n+ Input of funtions are sanity checked and verbose warnings are printed before something breaks, this speeds up \n  debugging and prevents potential bugs\n+ Documentation is in one single place, tutorial introduces readers gently step-by-step\n\n## Disadvantages over GTK4\n+ many of the gio and glib functionality is not yet exposed, file I/O and anything related to images is present in \n  mousetrap, however\n+ GTK Builder was ommitted completely, all objects are defined and initializes in a C++ file\n+ mnemonics of any kind were ommitted\n+ a hand-full of widgets are not yet exposed, or where intentionally ommitted, the latter category includes `FlowBox`,\n  `ScaleButton`, and any widget marked for deprecation since GTK4.10\n\nThe main disadvantage of mousetrap is that not every GTK4 functionality is imported, making mousetrap somewhat less flexible. However, **every non-deprecated GTK4-widget is available**, \nmeaning there is no limiation put upon the actual graphical user interface.\n\n# TODO\n+ Search Bar\n+ FontDialog\n+ Allow multiple tick callbacks for widget\n+ Make ListView, GridView, ColumnView filterable\n+ Add search bar to DropDown\n+ Expose TextView widget insertion\n+ Refactor ColumnView to be a tree\n+ Expose GTK_DEBUG interface\n+ Action: allow changing shortcut triggers during runtime\n+ Clipboard: allow arbitrary datatypes\n+ Sound: Make SoundBuffer data mutable\n+ Expose GResource interface\n\n# Design Goals\n\n\n## Widgets can only contain Widgets\n\nIf a widget is a container, only other widgets can be added to it. For example, we cannot add a string to a `ListView`, \ninstead, we have to first construct a label for that string, then add that label instead:\n\n```cpp\nauto text = \"text\";\nauto label = Label(text);\n\nauto list = ListView(Orientation::HORIZONTAL);\nlist.push_back(\u0026label);\n```\n\nThis fully abstracts away the [factory-pattern](https://docs.gtk.org/gtk4/class.ListItemFactory.html) and \n[model-view-pattern](https://docs.gtk.org/gtk4/method.ListView.set_model.html) used by many of the more complex GTK \nwidgets such as `ListView`, `GridView` and `ColumnView`, all of which can be initialized in exactly one line in mousetrap.\n\nWhile vastly simplfying the interface, it allows for the same flexiblity, as, similar to a `Box`, any type of object can \nbe added to the container. Adding an `ImageDisplay` to a `GridView` is the same 1-line process as adding another `GridView` \nto a `GridView`.\n\nMutating widgets that area already inserted is also made easier this way. If we create a `ListView` containing\n10 `Label`s, we will first have to create the 10 labels ourself. By keeping a reference to them, if we want to change \nthe text displayed by the `ListView`, we can simply call `set_text` on each label. Because the `ListView` does not \nconstruct the string-displaying widget for us, we keep full control over them.\n\n## Lambdas instead of static C functions\n\nOne of C++s most convenient feature are lambdas. In pure GTK4, we are unable to for example connect a runtime-created\nlambda to a signal directly. Through employing clever wrapping, in mousetrap connecting to a signal handler is possible\nusing both lambdas and regular C functions:\n\n```cpp\nauto window = Window();\nwindow.connect_signal_close_request([]() -\u003e bool {\n    std::cout \u003c\u003c \"window closed\" \u003c\u003c std::endl;\n    return false; // do not prevent window from closing\n});\n```\n\nThrough code generation, most of GTK4s macros were wrapped with a more expressive, explicitly defined function. Compare:\n\n```cpp\nwindow.connect_signal(\"close-request\", // ...\nwindow.connect_signal_close_request( // ...\n```\n\nThe latter has the advantage of a) not allowing user to use an incorrect or misspelled signal id and b) asserts that \nthe function connected to the signal handler is of the correct signature. In GTK4, due to the way C function pointers work,\na function of any signature can be connected to any signal, which allows for data corruption and possible side-effects,\nboth of which were eliminated with the explicit signal notation above.\n\n## OpenGL instead of Cairo\n\nGtk4 now supports native OpenGL, removing the performance penatly it used to incur by having to move the OpenGL \nframebuffer to display it using cairo. mousetrap offers `RenderArea` which abstracts away any manual OpenGL tasks such\nas initializing the state or keeping track of GPU-side memory. Similar to a library like [SFML](https://www.sfml-dev.org/),\nmousetrap offers easy to initialize and manipulate objects for shapes, shaders, transforms and blendmodes. Rendering a \ntriangle in mousetrap only takes a few lines:\n\n```cpp\n\nauto triangle = Shape();\nshape.as_triangle({0.25, 0.25}, {0.75, 0.75})\n\nauto render_area = RenderArea();\nTODO\n```\n\n## There is only one library\n\nWhile extremely powerful, the way GTK4 is split between GTK, GDK and Gio / Glib makes it hard to form a cohesive picture\nof the library as sometimes, a single task such as constructing a list displaying images requires calls from all three\ndifferent libraries who are documented on three different internet domains. mousetrap aims to unify both documentation \nand code usage, keeping everything in one place by abstracting away any gdk or glib functionality.\n\n# Hello World\n\n```cpp\n#include \u003cinclude/mousetrap.hpp\u003e\n\nusing namespace mousetrap;\n\n// global state, holds persistent widgets for the duration of runtime\ninline struct State\n{\n    Window window;\n    Label hello_world_label = Label(\"hello world\");\n    \n}* state;\n\nint main()\n{\n    auto app = Application(\"app.hello_world\");\n\n    app.connect_signal_activate([\u0026](Application*)\n    {\n        // initialize\n        state = new State{Window(app)};\n        state-\u003ewindow.set_child(\u0026state-\u003ehello_world_label);\n        state-\u003ewindow.present();\n    });\n\n    app.connect_signal_shutdown([](Application*)\n    {\n        // shut down\n        delete state;\n    });\n\n    return app.run(); // main render loop\n}\n```\n\n```jl\nbegin test end break\n```\n\ncmake\ngit\nlibglew-dev\nlibsfml-dev\nlibglm-dev\n\ngit clone https://github.com/Clemapfel/mousetrap\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclemapfel%2Frg_backup_0623","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclemapfel%2Frg_backup_0623","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclemapfel%2Frg_backup_0623/lists"}