Skip to content

Commit

Permalink
Merge pull request #37 from progrium/pruning
Browse files Browse the repository at this point in the history
Pruning bridge and schema code
  • Loading branch information
progrium authored Apr 1, 2021
2 parents 295658d + 3f471f9 commit 87b2fbe
Show file tree
Hide file tree
Showing 35 changed files with 2 additions and 4,812 deletions.
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,3 @@ notification: ## build and run notification example
pomodoro: ## build and run pomodoro example
$(GOEXE) run ./examples/pomodoro
.PHONY: pomodoro

bridgehost: ## build and run bridgehost example
$(GOEXE) install ./cmd/macbridge
$(GOEXE) run ./examples/bridgehost
.PHONY: bridgehost
67 changes: 1 addition & 66 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Native Mac APIs for Golang!

------

MacDriver is a toolkit for working with Apple/Mac APIs and frameworks in Go. It currently has 3 "layers":
MacDriver is a toolkit for working with Apple/Mac APIs and frameworks in Go. It currently has 2 parts:

## 1. Bindings for Objective-C
The `objc` package wraps the [Objective-C runtime](https://developer.apple.com/documentation/objectivec/objective-c_runtime?language=objc) to dynamically interact with Objective-C objects and classes:
Expand Down Expand Up @@ -83,71 +83,6 @@ func main() {

**NEW**: See [progrium/topframe](https://github.com/progrium/topframe) for a more fully-featured standalone version!

## 3. Bridge System
Lastly, a common case for this toolkit is not just building full native apps, but integrating Go applications
with Mac systems, like windows, native menus, status icons (systray), etc.
One-off libraries for some of these exist, but besides often limiting what you can do,
they're also just not composable. They all want to own the main thread!

For this and other reasons, we often run the above kind of code in a separate process altogether from our
Go application. This might seem like a step backwards, but it is safer and more robust in a way.

The `bridge` package takes advantage of this situation to create a higher-level abstraction more aligned with a potential
cross-platform toolkit. You can declaratively describe and modify structs that can be copied to the bridge process and applied to the Objective-C
objects in a manner similar to configuration management:

```go
package main

import (
"os"

"github.com/progrium/macdriver/bridge"
)

func main() {
// start a bridge subprocess
host := bridge.NewHost(os.Stderr)
go host.Run()

// create a window
window := bridge.Window{
Title: "My Title",
Size: bridge.Size{W: 480, H: 240},
Position: bridge.Point{X: 200, Y: 200},
Closable: true,
Minimizable: false,
Resizable: false,
Borderless: false,
AlwaysOnTop: true,
Background: &bridge.Color{R: 1, G: 1, B: 1, A: 0.5},
}
host.Sync(&window)

// change its title
window.Title = "My New Title"
host.Sync(&window)

// destroy the window
host.Release(&window)
}

```
This is the most WIP part of the project, but once developed further we can take this API and build a bridge
system with the same resources for Windows and Linux, making a cross-platform OS "driver". We'll see.

* Current bridge types available:
* Window
* StatusItem (systray)
* Menu

## Development Notes

As far as we know, due to limitations of Go modules, we often need to add `replace` directives to our `go.mod` during development
to work against a local checkout of some dependency (like qtalk). However, these should not be versioned, so for now we encourage
you to use `git update-index --skip-worktree go.mod` on your checkout if you need to add `replace` directives. When updates need to
be checked in, `git update-index --no-skip-worktree go.mod` can be used to reverse this on your local repo to commit changes and then re-enable.

#### Generating wrappers

Eventually we can generate most of the wrapper APIs using bridgesupport and/or doc schemas. However, the number of APIs
Expand Down
227 changes: 0 additions & 227 deletions bridge/bridge.go

This file was deleted.

44 changes: 0 additions & 44 deletions bridge/host.go

This file was deleted.

Loading

0 comments on commit 87b2fbe

Please sign in to comment.