{"id":21083724,"url":"https://github.com/tgfrerer/ofxwidget","last_synced_at":"2025-09-21T00:38:24.853Z","repository":{"id":139105780,"uuid":"45563001","full_name":"tgfrerer/ofxWidget","owner":"tgfrerer","description":"A basic widget component that gives its hosts GUI superpowers. All through composition.","archived":false,"fork":false,"pushed_at":"2022-10-15T05:53:08.000Z","size":60,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-05T05:24:20.549Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tgfrerer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2015-11-04T19:42:53.000Z","updated_at":"2016-02-19T16:50:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"d42e7275-e095-4c89-873a-0f389d3ab134","html_url":"https://github.com/tgfrerer/ofxWidget","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tgfrerer/ofxWidget","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgfrerer%2FofxWidget","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgfrerer%2FofxWidget/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgfrerer%2FofxWidget/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgfrerer%2FofxWidget/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tgfrerer","download_url":"https://codeload.github.com/tgfrerer/ofxWidget/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgfrerer%2FofxWidget/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276179849,"owners_count":25598570,"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","status":"online","status_checked_at":"2025-09-20T02:00:10.207Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-19T20:19:38.882Z","updated_at":"2025-09-21T00:38:24.806Z","avatar_url":"https://github.com/tgfrerer.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ofxWidget\n\nA basic widget component that gives host classes superpowers\nthrough composition.\n\nOk. I exaggerate. It allows its host to respond to\nmouse and keyboard events, though. It also does z-ordering.\nAnd draws the host objects in the correct order.\nAs if that wasn't enough. It's useful for GUIs.\n\nA widget knows the screen-space rectangle it is allowed to draw into. \n\nIt also (optionally) holds function objects to:\n\n  + draw\n  + respond to mouse events\n  + respond to keyboard events\n\nwhich you can bind to from the host. With \"host\", I mean a \nclass that \"has a\" widget, holding it with a shared pointer.\n\n## Caveat\n\n**IMPORTANT**: Once the host object has bound methods, IT MAY \nNOT MOVE ADDRESS (that is, `this` must remain constant). \n\nIf the object is held by a container for example, any re-allocation \nor re-ordering will invalidate any bound function calls, and\nlead to segfaults. YOU CAN MAKE SURE THIS DOESN'T HAPPEN BY\nHOLDING YOUR OBJECTS USING SHARED_PTRS. THIS WILL GUARANTEE\nTHE DATA LOCALITY OF THE OBJECT.\n\nALSO: if the host element is held in a list, or a map, your're\nfine, too. The idea is to make sure the underlying references \nand iterators cannot be invalidated, which is the case with\nmap and list.\n\nSee also: http://kera.name/articles/2011/06/iterator-invalidation-rules-c0x/\n\n## How it works\n\nWidgets automatically register for mouse events, and for keyboard\nevents. Only active widgets will receive event notification. This is \noptimised \u0026 very fast.\n\nWhen the static `Wiget::draw()` method is called, all wigets\nwhich are visible will get drawn, and drawn in the correct \norder, so that the topmost widget will cover any other \nwidgets.\n\nIf a mouse event is registered, the list of widgets is walked\nthrough, and the widget that is under the mouse will be called\nwith its (optional) `mouseEvent()`. \n\nIf a keyboard event is registered, the widget currently holding\nthe focus will receive the keyboard event. Focus is given either\nmanually, or by retrieving the last clicked widget.\n\nIf the widget has no events bound, no events will get called.\n\nWidgets can have exactly one parent, and unlimited children. \nWidget hierarchies are taken into account when deleting widgets, \nand when re-ordering widgets.\n\n## Debug View\n\nPress the right control key on your keyboard to see widget layers \ndrawn, with z-order indices.\n\n-------------------------------------------------------------\n\n## INTERNAL WIDGET LIST STORE SYSTEM (`sAllWidgets`)\n\n\u003cpre\u003e\n| w0.1 | w0.2 | w0 | w1.0 | w1.1 | w1 | w | ...\n\\__________________|\\_________________|\t  |\n\\_________________________________________|\n\u003c/pre\u003e\n\nWidgets are stored so that the front most widget is at the front,\nall other widgets (including its parent (and its parent parent) are\nbehind. Widgets have a numChildren count, which is cumulative, so \nthe sum total of all generations of children.\n\nThis storage method allows for optimisation when walking through \nwidget hierarchies.\n\n-------------------------------------------------------------\n\n## DISCUSSION\n\nQ: Can a widget be held by an unique_ptr?\n\nA: No. The book-keeping for Widgets is internally done through\n   `weak_ptr's`. There is no way a weak_ptr may reference a \n   unique_ptr, since `lock()` ing the weak_ptr would violate the \n   invariant that unique_ptrs are unique.\n\nQ: How do we deal with parent widgets? Should these receive \n   user input from their children? \n\nA: No. User input is routed exclusively to the widget in focus,\n   Unless there is a \"mouse down\" event, which means that \n   the focus may move to another widget.\n\t\t\t\t\t\t\t\t \n   Children may, however, bubble user input to their parents.\n\nQ: Do we want to accelerate the hit testing for widgets any \n   further?\n\nA: At the moment hit testing only happens when we click, and \n   appears to be fast enough. If we wanted to send enter/exit\n   events to wigets which have not yet received the focus, \n   we would have to do hit-testing for every position change.\n   At this point it will become interesting to think about \n   spatial hashes, etc.\n\nQ: Is there a way to stop events form being further processed?\n\nA: Yes. If the eventResponder uses the bool return type overload,\n   the return value controls whether an event will be notified \n   further. Currently, all events that are caught by any widget\n   will not further be notified. This means, if you interact with\n   a widget, the event will only be notified on the widget.\n\nQ: Is there a way to bubble events from child widgets to their\n   parents?\n\nA: Yes. Look at parentExample. The idea is to grab the parent,\n   And then call the parent's event responder with the current\n   event arguments. It is for the parent to decide what to do \n   with the event.\n\n------------------------------------------------------------\n\n# MIT Licensed\n\n\u003cpre\u003e\n     _____    ___     \n    /    /   /  /     ofxWidget\n   /  __/ * /  /__    (c) ponies \u0026 light ltd., 2015-2016. \n  /__/     /_____/    poniesandlight.co.uk\n\n  ofxWidget\n  Created by @tgfrerer 2015.\n  \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n THE SOFTWARE.\n\n\u003c/pre\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftgfrerer%2Fofxwidget","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftgfrerer%2Fofxwidget","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftgfrerer%2Fofxwidget/lists"}