Giter VIP home page Giter VIP logo

rubrail-rs's Introduction

Rubrail

Build Status

Rubrail is a Rust library for building Touch Bar interfaces for Mac OS X.

It creates a persistent icon in the 'Control Strip' region on the right side of the touchbar. This lets you access a Touch Bar menu of your design at any time, regardless of which application is currently active.

Using a pure-Rust API, you can create Touch Bar UIs with the most common items: Buttons, Labels, Sliders, Scrubbers (horizontally scrolling text selections), and recursive menus.

Source for following screencast in examples/example.rs

Run the example

$ cargo test && cargo run --example example

Cargo Crate

Crates.io Version

Documentation

Rubrail API documentation

Information

Warning -- Private APIs

Note that access to the Control Strip is forbidden by Apple's guidelines. Rubrail uses private APIs to create its menus, and thus is not suitable for distribution through the App Store. A 'dummy' implementation is provided for apps that want to provide Touch Bar support, but want the ability to avoid linking against private frameworks when distributing. Build with the --no-default-features Cargo flag to get a dummy implementation that does nothing.

Note -- App bundle required

To communicate with the Touch Bar service, apps using Rubrail must be executed from an app bundle (.app). Running the executable directly will not crash, but the icon will not be registered with the Touch Bar service, so your Touch Bar UI will be unavailable.

The included example uses the fruitbasket crate to automatically re-launch itself as an OS X app bundle.

Limitations

There is no support for changing the UI of an existing bar. To change the UI layout, you must create a new bar and completely replace the old one. Scrubbers are an exception: their contents are managed by callbacks, but they do not live-refresh when the bar is visible. The user must close and re-open the bar to see scrubber content changes.

The Touch Bar API supports doing just about anything with custom views. Rubrail does not. Only a very limited set of UI options are exposed.

Linking

Rubrail links against the private Apple framework DFRFoundation.framework. This is handled by adding the private framework path in build.rs. Applications that use Rubrail do not need to link against it themselves, but should be aware that a dependency does.

Linking requires an XCode version high enough to support the Touch Bar and the private framework. The only tested version of XCode is version 8.3. Applications that use Rubrail must build with a new enough XCode version. If using Travis-CI, this means adding a line like this to your .travis.yml:

osx_image: xcode8.3

rubrail-rs's People

Contributors

mrmekon avatar iphands avatar

Stargazers

MoeinDanA avatar 秋城落叶 avatar  avatar Andrei Morozov avatar May avatar  avatar David.Gao avatar  avatar Yevgnen avatar George Kaklamanos avatar RaisCui avatar annie avatar Justin Garcia avatar Bence Czufor avatar  avatar Ayomide avatar drbh avatar Chris Lin avatar ik5 avatar iamazy avatar cssivision avatar  avatar xqq avatar imspace avatar momo avatar Cindy Wu avatar sam bacha avatar  avatar Daniil Naumetc avatar  avatar Coor avatar Lee Siong Chan avatar Florentin DUBOIS avatar Nithesh Mittapally avatar Alex Adewole avatar tg-z avatar Sora Morimoto avatar Yuki Kodama avatar Alfin S. avatar Squirrel avatar Dominic Bauer avatar Alexander Koz. avatar Andrejs Agejevs avatar Zouhir ⚡️ avatar Jacob LeGrone avatar Yalin Gunayer avatar Manuel H. avatar Dylan Frankland avatar Oliver Hofkens avatar  avatar Ryan Lopopolo avatar ricky avatar Jonathan Dizdarevic avatar Benedikt Terhechte avatar Alexey Aleshkov avatar Dan Kaplun avatar Adrian Kumpf avatar Russell Daly avatar Alin Panaitiu avatar Channing avatar Joni Hasanen avatar Tristan Hume avatar Tejumola Pelumi avatar Rust avatar cybai (Haku) avatar wangcong avatar Márk Bartos avatar Damian Mazurkiewicz avatar messense avatar Gabriel Corado avatar Rick Wong avatar Marco Gallo avatar  avatar Adrian Falleiro avatar Esteban Kuber avatar Zaki Manian avatar Denis Denisov avatar Tim Ryan avatar Nikolay Kolev avatar Will Franzen avatar Chris A. avatar Jarek Samic avatar Timo Sulg avatar William Ho avatar Gregory Loscombe avatar Val Packett avatar Adelar da Silva Queiróz avatar  avatar Sean Huber avatar Kent Gruber avatar Tony Arcieri avatar

Watchers

Zaki Manian avatar  avatar James Cloos avatar  avatar

rubrail-rs's Issues

Example failed

I ran the example app but things didn't go to plan alas.

pwd: rubrail-rs/target/rubrail_example.app

The 'bar' button appeared but when I pressed it this happened (Mojave):

2019-01-02 06:14:51.773 rubrail_example[89303:8819466] +[NSTouchBar presentSystemModalFunctionBar:systemTrayItemIdentifier:]: unrecognized selector sent to class 0x7fffa179e6c0
thread 'main' panicked at 'Uncaught exception <NSException: 0x7fc96745a8a0>', src/touchbar.rs:1203:32
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
1: std::sys_common::backtrace::_print
2: std::panicking::default_hook::{{closure}}
3: std::panicking::default_hook
4: std::panicking::rust_panic_with_hook
5: std::panicking::continue_panic_fmt
6: std::panicking::begin_panic_fmt
7: <rubrail::touchbar::ObjcAppDelegate as objc_foundation::object::INSObject>::class::{{closure}}::objc_present
8: -[NSApplication(NSResponder) sendAction:to:from:]
9: -[NSControl sendAction:to:]
10: __26-[NSCell _sendActionFrom:]_block_invoke
11: -[NSCell _sendActionFrom:]
12: -[NSButtonCell _sendActionFrom:]
13: -[NSCell touchEndedAt:inView:]
14: -[NSButtonCell touchEndedAt:inView:]
15: -[NSControl _touchEnded:]
16: -[NSControl touchesEndedWithEvent:]
17: _NSSendTouchEventToViews
18: ___NSSendDirectTouchesEvent_block_invoke
19: -[NSTouchDevice _preventFlushingContextID:during:]
20: _NSSendDirectTouchesEvent
21: _NSSendEventToDequeuingObservers
22: -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
23: <(A, B, C, D) as objc::message::MessageArguments>::invoke
24: objc::message::platform::send_unverified::{{closure}}
25: objc_exception::try::{{closure}}
26: objc_exception::try_no_ret::try_objc_execute_closure
27: RustObjCExceptionTryCatch
28: objc_exception::try_no_ret
29: objc_exception::try
30: objc::exception::try
31: objc::message::platform::send_unverified
32: fruitbasket::osx::FruitApp::run
33: example::main
34: std::rt::lang_start::{{closure}}
35: std::panicking::try::do_call
36: __rust_maybe_catch_panic
37: std::rt::lang_start_internal
38: std::rt::lang_start
39: main

XCode 9.3 path differs

Hi! I just compiled rubrail and found that the private framework has moved directories, at least with my version of XCode (9.3). The new version is this, if anyone is looking:

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/PrivateFrameworks/DFRFoundation.framework/

I edited build.rs and was able to get this compiling.

Is this project still maintained?

I am able to execute the test and build:

Compiler complains:

error[E0282]: type annotations needed
   --> src/touchbar.rs:824:25
    |
824 |                         msg_send![cls, minimizeSystemModalTouchBar: old_bar];
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ consider giving `result` a type
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

I tried to fix it with let _: () = ...

Now it does compile without any problem, artifacts and .app were generated successfully.

Result of cargo run --release

Process not bundled.  Self-bundling and relaunching.
Install dir: "/Users/admin/Documents/Private/rubrail-rs/target"
Bundle dir: "/Users/admin/Documents/Private/rubrail-rs/target/rubrail_example.app"
Current exe: "/Users/admin/Documents/Private/rubrail-rs/target/debug/examples/example"
Copy "/Users/admin/Documents/Private/rubrail-rs/target/debug/examples/example" to "/Users/admin/Documents/Private/rubrail-rs/target/rubrail_example.app/Contents/MacOS/rubrail_example"
Copy "/Users/admin/Documents/Private/rubrail-rs/examples/icon.png" to "/Users/admin/Documents/Private/rubrail-rs/target/rubrail_example.app/Contents/Resources/icon.png"
Launching: /Users/admin/Documents/Private/rubrail-rs/target/rubrail_example.app
Parent process exited.

But when I tried to open it, no magic appears on my TOUCHBAR..

open target/rubrail_example.app

Some additional info:

macOS 10.15.7

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.