{"id":51635130,"url":"https://github.com/elcritch/merenda","last_synced_at":"2026-07-13T13:03:07.677Z","repository":{"id":366984076,"uuid":"1160267921","full_name":"elcritch/merenda","owner":"elcritch","description":"Cocoa flavored GUI with a dash of QT sprinkled in written in pure Nim","archived":false,"fork":false,"pushed_at":"2026-07-10T17:29:32.000Z","size":9223,"stargazers_count":21,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-07-10T18:13:30.905Z","etag":null,"topics":["cocoa","gnustep","graphical-user-interface","gui","nim","object-c","openstep","smalltalk","themes","ui"],"latest_commit_sha":null,"homepage":"","language":"Nim","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elcritch.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-02-17T18:33:07.000Z","updated_at":"2026-07-10T16:53:47.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/elcritch/merenda","commit_stats":null,"previous_names":["elcritch/merenda"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/elcritch/merenda","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elcritch%2Fmerenda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elcritch%2Fmerenda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elcritch%2Fmerenda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elcritch%2Fmerenda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elcritch","download_url":"https://codeload.github.com/elcritch/merenda/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elcritch%2Fmerenda/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35423100,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-13T02:00:06.543Z","response_time":119,"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":["cocoa","gnustep","graphical-user-interface","gui","nim","object-c","openstep","smalltalk","themes","ui"],"created_at":"2026-07-13T13:03:06.997Z","updated_at":"2026-07-13T13:03:07.669Z","avatar_url":"https://github.com/elcritch.png","language":"Nim","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Merenda\n\n\u003cimg width=\"2172\" height=\"724\" alt=\"merenda-github-banner-robot-chocolate\" src=\"https://github.com/user-attachments/assets/f0a429f0-c5b5-49a4-819b-32d2cc454ac7\" /\u003e\n\nMerenda is a modern desktop GUI toolkit based on Cocoa and OpenStep, written in pure Nim. It uses [FigDraw](https://github.com/elcritch/figdraw/) for fast 2D rendering with shadows and gloss, and [siwin](https://github.com/levovix0/siwin) for cross-platform windowing and events. It currently aims to support macOS, FreeBSD, Linux, and Windows.\n\nThe main public module is `merenda/nimkit`. NimKit is designed around [Sigils](https://github.com/elcritch/sigils), which provides Objective-C-style dynamic selectors and protocols along with Qt-style signals and slots. NimKit uses selectors to build Cocoa-style responder/action patterns, while signals and slots cover observable control events. It also provides model controllers, a theme system, and custom chrome for desktop application workflows.\n\n\u003cimg width=\"400\"  alt=\"Screenshot 2026-06-23 at 9 49 13 PM\" src=\"https://github.com/user-attachments/assets/8737afcd-bbcf-4ad1-a7d7-8e5574406c54\" /\u003e \u003cimg width=\"400\" alt=\"Screenshot 2026-06-23 at 9 43 10 PM\" src=\"https://github.com/user-attachments/assets/24514943-f0fa-46cd-a6fd-feb2327ad81c\" /\u003e\n\n## Why Try It?\n\n- **Native Nim**: The power and structure of Cocoa and OpenStep, implemented in a modern systems language.\n- **Useful controls already work**: buttons, toggle buttons, checkboxes, radio\n  buttons, text fields, combo boxes, menus, sliders, steppers, switches,\n  scroll views, tabs, tables, outlines, collection views, matrices, and\n  document tabs.\n- **Model-backed views**: array, tree, and selection controllers can drive\n  tables, outlines, cascading views, combo boxes, document tabs, menus, and\n  matrices.\n- **Custom chrome and theming**: built-in controls use theme rules and chrome\n  modules to support first-class visual customization.\n- **OpenStep based interaction model**: target/action, responders, first\n  responder, key-view tabbing, focus rings, and platform key bindings are built in.\n- **Custom drawing is direct**: views can provide their own draw hook and render into a `DrawContext`.\n- **FigDraw rendering**: controls render into a FigDraw tree, making drawing\n  testable and portable across supported FigDraw backends.\n- **Cassowary constraint engine**: [kiwiberry](https://github.com/elcritch/kiwiberry) is a full port of the Kiwi C++ Cassowary engine. NimKit provides a convenient layout DSL on top.\n\n## Install\n\nAdd Merenda to your package:\n\n```nim\nrequires \"https://github.com/elcritch/merenda\"\n```\n\nThen install dependencies with Atlas:\n\n```sh\natlas install --update\n```\n\nNote: You'll want to install the most recent [Atlas](https://github.com/nim-lang/atlas#installation), where curl install is the easiest. Nimble should also work but it's not tested currently.\n\n## Quick Start\n\n```nim\nimport merenda/nimkit\nimport sigils/selectors\n\nlet\n  app = sharedApplication()\n  window = newWindow(\"Counter\", frame = rect(100, 100, 320, 220))\n  root = newView()\n  layout = newStackView(laVertical)\n  label = newStatusLabel(\"Clicked 0 times\")\n  button = newButton(\"Click\")\n  clickAction = actionSelector(\"counterClicked\")\n\nvar clicks = 0\n\nproc onClick(sender: DynamicAgent) =\n  if not sender.isNil:\n    inc clicks\n    label.text = \"Clicked \" \u0026 $clicks \u0026 \" times\"\n\nbutton.target = newActionTarget(clickAction, onClick)\nbutton.action = clickAction\n\nlayout.spacing = 12.0\nlayout.alignment = svaFill\nlayout.addArrangedSubview(label, button)\n\nroot.addSubview(layout)\nlayout.pinEdges(\n  toGuide = root.contentLayoutGuide(insets(44.0, 44.0, 0.0, 44.0)),\n  edges = {leLeft, leTop, leRight},\n)\n\napp.runWindow(window, root)\n```\n\nThe same example lives in `examples/quick_start.nim` and can be run with:\n\n```sh\nnim r examples/quick_start.nim\n```\n\nUse `app.showWindow(window, root)` instead when you want to install and show a\nwindow without entering the application run loop. Pass an initial responder as\nthe third argument, such as `app.runWindow(window, root, textField)`, when a\nspecific control should receive focus first.\n\nMerenda apps automatically use the native window content scale. To force a\nspecific UI scale for development or display debugging, set `UISCALE` or\n`NIMKIT_UISCALE`:\n\n```sh\nUISCALE=1.5 nim r examples/quick_start.nim\n```\n\n`NIMKIT_UISCALE` and `MERENDA_UISCALE` take priority over `UISCALE`, and\nFigDraw's legacy `HDI` variable remains a fallback.\n\nText rendering and measurement use the active theme's `StyleFontName` and\n`StyleFontSize` values. To seed those theme defaults from the command line, set\n`NIMKIT_FONT` to a bundled font name, system font name, or font file path. Set\n`NIMKIT_FONT_SIZE` to override the default font size used by text and `em`\nlayout lengths:\n\n```sh\nNIMKIT_FONT=HackNerdFont-Regular.ttf NIMKIT_FONT_SIZE=15 nim r examples/quick_start.nim\n```\n\n`NIMKIT_FONT` and `NIMKIT_FONT_SIZE` take priority over `MERENDA_FONT` and\n`MERENDA_FONT_SIZE`. If the font override cannot be resolved, NimKit falls back\nto its bundled default font list. Per-role or per-class theme rules can override\nthe same values with `StyleFontName` and `StyleFontSize`.\n\nFor a flatter, modern macOS-style appearance, select the built-in `macos` theme\nat startup or construct it directly:\n\n```sh\nNIMKIT_THEME=macos nim r examples/controls_showcase.nim\n```\n\n```nim\nroot.appearance = initAppearance(initMacOSTheme())\n```\n\nThe `mac` and `modern-macos` names are aliases. The theme is platform-neutral,\nso Linux applications can use the same look while macOS continues to use its\nnative application menu bar.\n\nCompose Finder-style icon rows with `IconLabel`. The icon is a Unicode glyph,\nrendered through the same FigDraw glyph atlas as other text, and can have an\nindependent semantic tint:\n\n```nim\nlet downloads = newIconLabel(\"↓\", \"Downloads\", color(0.04, 0.52, 1.0))\nlet shared = newIconLabel(\"⌘\", \"Shared\", color(0.0, 0.62, 0.78))\n```\n\nOmit the color to use the active theme's icon accent.\n\n## Controls\n\nNimKit ships the core controls needed for desktop-style interfaces:\n\n- Windows and views: `newApplication`, `sharedApplication`, `newWindow`, `newView`\n- Layout and containers: `newStackView`, `newGridView`, `newFormView`, `newSplitView`, `newScrollView`, `newTabView`, `newBox`, `newGroupBox`, `newSeparatorBox`\n- Text: `newTextField`, `newLabel`, `newTitleLabel`, `newStatusLabel`, `newTextEditor`, `newMonoTextEditor`\n- Buttons and choices: `newButton`, `newCheckBox`, `newRadioButton`, `newComboBox`, `newPopupMenuButton`, `newMenu`, `newMenuItem`\n- Value and status controls: `newSlider`, `newStepper`, `newSwitchButton`, `newProgressIndicator`\n- Data and navigation views: `newTableView`, `newOutlineView`, `newCascadingView`, `newCollectionView`, `newDocumentTabs`, `newButtonMatrix`, `newRadioMatrix`\n\nControls use Cocoa-style target/action for commands:\n\n```nim\nlet action = actionSelector(\"saveClicked\")\n\nproc save(sender: DynamicAgent) =\n  if not sender.isNil:\n    echo \"save\"\n\nbutton.target = newActionTarget(action, save)\nbutton.action = action\n```\n\nApplication menus use the same `Menu` and `MenuItem` tree on every platform.\nAssigning the tree to `app.mainMenu` publishes a native menu in the macOS menu\nbar, including submenus, separators, validation, state, and key equivalents.\nThe default `mmpAutomatic` presentation uses that native menu when available.\nApplications can switch `app.mainMenuPresentation` at runtime between\n`mmpNative` and `mmpInWindow`; `app.usesNativeMainMenu()` reports the effective\nchoice. For a standard window, wrap its content with\n`newMenuRootView(app.mainMenu(), content)`. The root owns a `MenuBar` and hides\nor shows it as the presentation changes. Standalone `newMenuBar` presenters\nfollow the same policy, and layout containers such as `StackView` automatically\nomit the hidden menu bar.\n\nButtons can behave as push, toggle, checkbox, or radio controls:\n\n```nim\nlet toggle = newButton(\"Enable Sync\")\ntoggle.buttonType = btToggle\ntoggle.allowsMixedState = true\ntoggle.state = bsOn\n```\n\nControls that expose continuous state can also emit signals:\n\n```nim\nlet volume = newSlider(0.0, 100.0, 42.0)\nlet label = newStatusLabel(\"Volume: 42\")\n\nproc updateVolume(slider: Slider, sender: DynamicAgent) {.slot.} =\n  discard sender\n  label.text = \"Volume: \" \u0026 $slider.value.int\n\nvolume.connect(actionDidSend, volume, updateVolume)\n```\n\nTables and choice controls can share `ArrayController` data:\n\n```nim\nlet\n  items = @[\n    initModelItem(\n      \"ada\",\n      objectValue = toObj(\"Ada\"),\n      fields = [\n        modelField(\"name\", toObj(\"Ada\")),\n        modelField(\"score\", toObj(31)),\n      ],\n    ),\n    initModelItem(\n      \"grace\",\n      objectValue = toObj(\"Grace\"),\n      fields = [\n        modelField(\"name\", toObj(\"Grace\")),\n        modelField(\"score\", toObj(45)),\n      ],\n    ),\n  ]\n  columns = @[\n    modelColumn(\"person\", \"Person\", \"name\", 120.0),\n    modelColumn(\"rank\", \"Score\", \"score\", 64.0),\n  ]\n  controller = newArrayController(items, columns)\n  table = newTableView()\n  combo = newComboBox()\n\nbindTableView(table, controller)\nbindComboBox(combo, controller)\n```\n\nFor larger examples, see:\n\n- `examples/controls_showcase.nim`\n- `examples/modelcontrollers_demo.nim`\n- `examples/preferences_demo.nim`\n- `examples/table_demo.nim`\n- `examples/tabview_demo.nim`\n\n## Keyboard And Focus\n\nNimKit supports first responder focus, tab navigation, and platform-aware text\nediting shortcuts. macOS defaults to Cocoa-style bindings such as control-A,\ncontrol-E, option-left, and option-right. Windows and Linux/BSD use their own\ndefault binding profiles.\n\n```nim\ndiscard window.selectNextKeyView()\ndiscard window.makeFirstResponder(textField)\n```\n\nButtons can be tab-selected and activated from the keyboard.\n\n## Styling\n\nUse an `Appearance` to override theme tokens or style selectors. Views can carry\nstyle classes, giving the theme system stable targets without requiring CSS.\n\n```nim\nlet titleStyle = initStyleSelector(srTextField, classes = @[\"title\"])\nvar appearance = initAppearance()\n\nappearance.setStyle(titleStyle, StyleFill, fill(color(0.88, 0.92, 0.98)))\nappearance.setStyle(titleStyle, StyleTextColor, color(0.09, 0.14, 0.26))\nappearance.setStyle(titleStyle, StyleCornerRadius, 6.0)\n\ntitle.styleClasses = [\"title\"]\nroot.appearance = appearance\n```\n\nAppearance inherits through the app, window, and view hierarchy, so local\noverrides can be scoped to a whole window or a single subtree.\n\n## Drawing\n\nCustom views draw through a `DrawContext`, which wraps the active FigDraw render\nlist, local bounds, visible rect, and coordinate conversion helpers.\n\n```nim\ntype BadgeView = ref object of View\n\nprotocol BadgeDrawing of ViewDrawingProtocol:\n  method draw(view: BadgeView, context: DrawContext) =\n    context.addRectangle(\n      rect(0, 0, 120, 32),\n      fill(color(0.18, 0.32, 0.55)),\n    )\n    context.addText(\n      rect(12, 0, 96, 32),\n      \"Ready\",\n      color(1, 1, 1),\n      taCenter,\n    )\n\nproc newBadgeView(frame: Rect): BadgeView =\n  result = BadgeView()\n  initViewFields(result, frame)\n  discard result.withProtocol(BadgeDrawing)\n```\n\n## Examples\n\nRun the combined controls demo:\n\n```sh\nnim r examples/controls_showcase.nim\n```\n\nCurrent examples are mirrored by `examples/all_compile.nim`:\n\n- Basics: `quick_start`, `hello`, `button_counter`, `button_demo`, `todo_basic`, `todo_stack_drag`, `todo_table`, `controls_showcase`\n- Controls: `textfield_demo`, `checkbox_demo`, `radio_demo`, `combobox_demo`, `combo_scroll_demo`, `stepper_demo`, `progress_indicator_demo`\n- Layout and containers: `box_demo`, `splitview_demo`, `scrollview_demo`, `tabview_demo`, `layout_showcase`, `constraint_playground_demo`, `grid_preferences`\n- Data and models: `table_demo`, `outline_demo`, `cascading_demo`, `collectionview_demo`, `documenttabs_demo`, `matrix_demo`, `menu_demo`, `modelcontrollers_demo`\n- Application workflows: `panel_demo`, `document_workspace_demo`, `preferences_demo`, `viewcontroller_demo`, `view_inspector_demo`, `image_resources_demo`\n- Text and animation: `texteditor_demo`, `synedit_demo`, `monotext_demo`, `animation_demo`\n\nRun any focused example with:\n\n```sh\nnim r examples/\u003cname\u003e.nim\n```\n\n## Tests\n\nRun the NimKit test suite through Atlas:\n\n```sh\natlas-run tests\n```\n\nCompile-check the example import bundle with:\n\n```sh\natlas-run tests --compile-only examples/all_compile.nim\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felcritch%2Fmerenda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felcritch%2Fmerenda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felcritch%2Fmerenda/lists"}