u/jjstyle99

▲ 34 r/nim+1 crossposts

Merenda: Pure Nim GUI toolkit based on Cocoa/OpenStep

Merenda is a new pure Nim GUI framework based on OpenStep and Cocoa with a splash of QT! It's fast, GPU rendered, with themes and look and feel along with a full suite of OpenStep/Cocoa style widgets and an accessibility layer. Support for BIDI and Harffbuzz are coming soon!

It's already implements a substantial amount of the core functionality of OpenStep and Cocoa. It's not a one-to-one implementation, but generally the APIs try to follow Cocoa's design patterns. Though cleaned up to take advantage of Nim's stronger type system than Objective-C.

For example here's the table demo showing a table view backed by a data model:

https://preview.redd.it/3fkwnmj1k7bh1.png?width=800&format=png&auto=webp&s=5868173b5ccd91c5d36c7164d500e3cb48827df0

Overall Merenda is based on several years of working on and experimenting with GUIs. I worked Figuro and was happy with many aspects of it. However the object model ran into limitations when building more complex widgets. Things like:

https://preview.redd.it/cjjq89z3l7bh1.png?width=987&format=png&auto=webp&s=1a939d0eb814befb00bc92fbf4db330659f1caf8

Merenda solves this by adopting Cocoa's dynamic methods and protocols. These are provided by Sigils. The ability for objects to adopt protocols at runtime enables implementing the rich behavior and functionality seen in Cocoa and iOS.

The implementation of this is called NimKit, mirroring Cocoa's AppKit. NimKit ships the core controls needed for desktop-style interfaces:

  • Windows and views: newApplication, sharedApplication, newWindow, newView
  • Layout and containers: newStackView, newGridView, newFormView, newSplitView, newScrollView, newTabView, newBox, newGroupBox, newSeparatorBox
  • Text: newTextField, newLabel, newTitleLabel, newStatusLabel, newTextEditor, newMonoTextEditor
  • Buttons and choices: newButton, newCheckBox, newRadioButton, newComboBox, newPopupMenuButton, newMenu, newMenuItem
  • Value and status controls: newSlider, newStepper, newSwitchButton, newProgressIndicator
  • Data and navigation views: newTableView, newOutlineView, newCascadingView, newCollectionView, newDocumentTabs, newButtonMatrix, newRadioMatrix

It's been my hobby work the last few months. I've been building and testing all of these, item by item!

Yes it's mostly built with Codex + GPT-5.5 but I continuously review the generated code and refactor and simplify it. Plus more importantly it's based on solid architectural components I've been building for years. It's definitely not what I'd call vibe coded.

https://preview.redd.it/irwz2j76l7bh1.png?width=800&format=png&auto=webp&s=408a5e7b7e3bddf2c5535fae4b85d75a07f06ea0

reddit.com
u/jjstyle99 — 2 days ago
▲ 21 r/nim

FigDraw + Harfbuzz for beautiful font shaping! 😍

FigDraw 0.25.0 now has optional support for Harfbuzz, the premier open source font shaping library!

The font backends will be swappable between Pixie and Harfbuzz at compile time. FigDraw's text API is mostly unchanged, however internally it tracks all the extra work needed for languages with complex scripts. This also includes support for BIDI and right-to-left scripts! I'm not sure about top-to-bottom languages (for now).

See the README for usage details.

https://preview.redd.it/vbw9obp9068h1.jpg?width=2784&format=pjpg&auto=webp&s=4a91d160c8ef1f460d09837d97a73c05f4352774

reddit.com
u/jjstyle99 — 17 days ago
▲ 17 r/nim

Kiwiberry: Nim port of Kiwi Cassowary Linear Constraint Solver

Kiwiberry is a pure Nim port of Kiwi which is a fast implementation of the Cassowary constraint solving algorithm using floating points for more general solving. E.g. it's a fast linear constraint solver that supports cycles.

It's what MacOSX and iOS for autolayout as well as other UIs. Original Cassowary paper.

Benchmark against the original C++ version which is pretty highly optimized is reasonable: Kiwiberry `0.280824 ms/iter` vs Kiwi `0.160790 ms/iter`. The port was done with Codex GPT-5.5 with the Kiwi tests used as verification.


## Example

import kiwiberry



var solver = initSolver()

let width = vars"width"



solver\[width\] = Strong

solver.constraint(width >= 100)

solver.suggest(width, 240)

solver.update()



doAssert width.value == 240.KiwiScalar

You can do more complex constraints like x1 + 3 \* x2 <= 4 \* x3 + 2.

u/jjstyle99 — 27 days ago