Compare commits

..
Author SHA1 Message Date
daboe01andGitHub c58c5554f9 Merge pull request #2018 from vidinoti/patch-1
Changing a CALayer in a menu callback doesn't trigger re-draw
2024-12-30 13:57:56 +01:00
daboe01andGitHub 16ae7b7e74 Merge pull request #1372 from kjamieson/scroll-fixes
If target view of a drag and drop is a CPTableView, set inset bounds based on the row height of the table
2024-12-30 13:51:00 +01:00
Mathieu Monney c528421a8e Added unit test for pull request #2018 2014-12-19 13:42:40 +01:00
Mathieu Monney 0cfb53cea4 Changing a CALayer in a menu callback doesn't trigger re-draw / re-layout 2013-11-18 15:29:41 +01:00
Kevin Jamieson b349f0a2fb If target view of a drag is a CPTableView, set inset bounds based on the row height of the table 2011-10-03 22:13:41 -07:00
13 changed files with 470 additions and 111 deletions
+11 -2
View File
@@ -261,10 +261,19 @@ var CPDraggingSource_draggedImage_movedTo_ = 1 << 0,
{
var contentView = [scrollView contentView],
bounds = [contentView bounds],
insetBounds = CGRectInset(bounds, 30, 30),
eventLocation = [contentView convertPoint:_draggingLocation fromView:nil],
deltaX = 0,
deltaY = 0;
deltaY = 0,
insetSize = 30;
if ([contentView respondsToSelector:@selector(documentView)] &&
[[contentView documentView] respondsToSelector:@selector(rowHeight)])
{
// Adjust inset bounds based on CPTableView row height
insetSize = MAX(insetSize, [[contentView documentView] rowHeight]);
}
var insetBounds = CGRectInset(bounds, insetSize, insetSize);
if (!CGRectContainsPoint(insetBounds, eventLocation))
{
+5
View File
@@ -27,6 +27,7 @@
@import "CPKeyValueBinding.j"
@import "CPMenuItem.j"
@import "CALayer.j"
@global CPApp
@@ -1016,6 +1017,10 @@ var _CPMenuBarVisible = NO,
// an additional mouse move after all this, but not in other browsers.
// This will be fixed correctly with the coming run loop changes.
[_CPDisplayServer run];
// If layers are updated within the menu callback, the re-draw & re-layout doesn't occur until a mouse move.
// We force the update here.
[CALayer runLoopUpdateLayers];
}
/* @ignore */
+4 -5
View File
@@ -561,11 +561,10 @@ CPSegmentSwitchTrackingMomentary = 2;
}
else if (aName === "right-segment-bezel")
{
// we have to FLOOR the coordinates to prevent a 1px glitch in Safari
return CGRectMake(FLOOR(CGRectGetWidth([self bounds]) - contentInset.right),
FLOOR(bezelInset.top),
FLOOR(contentInset.right),
FLOOR(height));
return CGRectMake(CGRectGetWidth([self bounds]) - contentInset.right,
bezelInset.top,
contentInset.right,
height);
}
else if (aName.indexOf("segment-bezel") === 0)
{
-6
View File
@@ -312,12 +312,6 @@ var AFFINITY = 5;
if (!trackRect || CGRectIsEmpty(trackRect))
trackRect = bounds;
if (_allowsTickMarkValuesOnly)
{
[self closestTickMarkValueToValue:[self doubleValue]]; // we only need the side effect …
_currentTickMarkSegment = _closestTickMarkIndex;
}
if (_isCircular)
{
var angle = 3 * PI_2 - (1.0 - [self doubleValue] - _minValue) / (_maxValue - _minValue) * PI2,
+2
View File
@@ -2718,6 +2718,8 @@ var _CPCopyPlaceholder = '-';
if (![currentFirstResponder respondsToSelector:@selector(_activateNativeInputElement:)])
return false; // prevent the default behaviour
var charCode = _CPNativeInputField.innerHTML.charCodeAt(0);
// chrome-trigger: keypressed is omitted for deadkeys
if (!_CPNativeInputFieldActive && _CPNativeInputFieldKeyPressedCalled == NO && _CPNativeInputField.innerHTML.length && _CPNativeInputField.innerHTML != _CPCopyPlaceholder && _CPNativeInputField.innerHTML.length < 3)
{
+69 -98
View File
@@ -2,19 +2,27 @@
[![Join the chat at https://gitter.im/cappuccino/cappuccino](https://badges.gitter.im/cappuccino/cappuccino.svg)](
https://gitter.im/cappuccino/cappuccino?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
# Welcome to Cappuccino!
Welcome to Cappuccino!
======================
Cappuccino, a open-source web application framework in Objective-J (*a superset of JavaScript which is transpiled for deployment but can also run in the browser directly*), enhances app development by faithfully implementing the NeXTSTEP/Apple Cocoa® APIs for browsers as web browser restrictions permit. Leveraging this well-established architecture, Cappuccino facilitates scalable application development for those usage cases requiring developer productivity, reliability and sophisticated interaction support. Resulting applications are served from any web server and deployed to any modern web browser - without plugins or extensions of any kind. Cappuccino has been developed continuously since 2008 and is licensed under the LGPL version 2.
Cappuccino, a web application framework in Objective-J, a superset of JavaScript, enhances web development by implementing the NeXTSTEP/Apple Cocoa APIs for web browsers. This integration supports the creation of sophisticated, desktop-class applications without imposing arbitrary complexity limits. Leveraging Cocoas well-established architecture, Cappuccino facilitates scalable and reliable application development. Applications can be served from any web server and deployed to any modern web browser without dependencies, offering a streamlined solution for developers.
### Benefits of Cappuccino for Application Development:
* Developer productivity a rich palette of interface controls and robust event managment APIs go well beyond the functionality provided by current browser standards, allowing rich applications to quickly be built up using high-level constructs that are designed to work well together.
* Consistency predictable behavior across different platforms with desktop-class usability and user experience.
* Stability use of time-tested APIs means an absense of the churn which is all too common in the browser-app ecosystem found elsewhere.
* Cross-platform development any programmer's text editor or IDE is sufficient. The compiler and other parts of the toolchain (used to prepare applications for deployment) are hosted by Node.js.
* Extensibility custom interface controls can reliably build on framework-included controls, when extended or new functionality is required.
* Objective-J's [message-passing architecture](https://en.wikipedia.org/wiki/Message_passing), which the Cappuccino APIs leverage, promotes loose coupling of an app's component functionality — making large scale development more managable.
* Comprehensive documentation for Objective-J is supplemented by over two decades of resources for Objective-C and Cocoa®. Additionally, a large public catalog of native Objective-C applications offers valuable guidance for development. Translation of such sample code to Objective-J is often trivial (see below).
Introduction
------------
Cappuccino is an open-source framework in continuous development since 2008 and released under the LGPL2 license. It implements as much of the proven NeXTStep/Apple Cocoa API as practicable in the modern web browser environment. Resulting applications are served as HTML, JavaScript, and CSS, allowing deployment from any web host.
Benefits of Cappuccino's Cocoa implementation:
* Cross-platform development any programmer's text editor or IDE is sufficient. The compiler and other parts of the toolchain required to prepare applications for deployment are hosted by Node.js.
* Cocoa's rich range of interface controls are abstracted to HTML, CSS, and JavaScript. These go well beyond the functionality provided by current browser standards, and only require minimal HTML5 support.
* These design patterns and APIs provide a solid foundation for application development. The APIs have been proven over forty years and provide browser-independent functionality which is a superset of current browser capabilities.
* Custom interface controls can reliably build on basic Cocoa controls if extended or new functionality is required.
* Robust event-handling mechanisms, a superset of those provided by current browsers, ensure responsive and interactive applications.
* Internationalization and localization technologies simplify global deployment.
* Consistent and predictable behavior across different platforms enhances reliability and user experience.
* Objective-J's [message-passing architecture](https://en.wikipedia.org/wiki/Message_passing), which the Cocoa APIs leverage, promote loose coupling of an app's component functionality — making large scale development more managable.
* Comprehensive documentation for Objective-J is supplemented by over two decades of resources for Objective-C and Cocoa. Additionally, a large public catalog of Objective-C Cocoa applications offers valuable guidance for development. Translation of such sample code to Objective-J is often trivial.
* Toolchain stability use of time-tested APIs means an absense of the churn which is all too common in the current generic browser-app ecosystem.
* The first web browser and server were written in 1990 by a single person using the APIs which Apple later re-branded and extended as Cocoa. Beyond being a testament to their productivity, it doesn't seem out of place to write application software using the same APIs.
Check out a [live demo of the standard interface controls provided by Cappuccino](https://cappuccino-testbook.5apps.com/#ThemeKitchenSink)
@@ -30,17 +38,27 @@ For more information, see the
Bugs and enhancement requrests can be reported by [creating a Github issue](http://github.com/cappuccino/cappuccino/issues).
## System Requirements
* Any modern web browser can run Cappuccino applications.
* Any web server can serve Cappuccino applications.
System Requirements
-------------------
* A minimally HTML5-compliant web browser is the only requirement for running Cappuccino applications.
They are served as standard HTML, Javascript, CSS and images from any web server.
* Any programmer's editor can be used for coding.
* macOS users can use Xcode - which leverages the visual development tools from Apple for creation of complex applications with minimal coding.
## Installation instructions
To try Cappuccino:
Notes on the transition of Cappuccino from the Narwhal Javascript engine to Node.js
------------------
1. Install Node.js and npm from the [Node.js website](https://nodejs.org/download/) or the OS-specific package manager of your choice. Long-term Support (LTS) versions are tested although others will probably work as intended.
Cappuccino compiles source code files written in Objective-J or Javascript to pure HTML/Javascript/CSS.
A desktop Javascript engine with CommonJS for accessing local resources is required for the compilation phase.
Historically, this engine was [Narwhal](https://narwhaljs.org/).
A transition to [Node.js](https://nodejs.org) is being finalized.
The results of this transition are available as a Release Candidate.
While a formal production release is scheduled for early-autumn 2024, it should be considered production-ready as-is. Multiple production deployments over the last twelve months have confirmed this.
In addition to the Node.js-based toolchain, the next formal release will include multiple maintenance improvements and enhancements to the API.
To try Cappuccino using the Node.js version, do the following:
1. Install Node.js and npm from the [Node.js website](https://nodejs.org/download/) or the OS-specific package manager of your choice. Long-term Support (LTS) versions are supported although others will probably work as intended.
2. Run `npm set prefix ~/.npm`. This will set the default install location for npm to `~/.npm`. The reasoning behind
this is outlined in the section about permission issues below.
@@ -54,7 +72,13 @@ this is outlined in the section about permission issues below.
5. Run `npm install -g @objj/cappuccino`.
6. Done! See below for basic usage.
6. Done! See below for basic usage.
### Permisson issues
By default npm uses `/usr/local/lib/node_modules` as the install location for globally installed packages. This causes
problems since users typically lack write permissions there. It is therefore recommended to either use a version
manager, or change npm's default install location manually (which is what we did above with the `npm set prefix…` command). For more details see [this article](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally).
### Basic usage
@@ -63,29 +87,11 @@ On successful installation, follow these steps to create a basic and fully-funct
1. `capp gen HelloWorld`
2. `cd HelloWorld`
3. `python3 -m http.server` (any local http server can be used)
4. Open [http://localhost:8000](http://localhost:8000) (any modern browser can be used)
### Technical notes
Cappuccino compiles source code files written in Objective-J to pure Javascript but can also run Objective-J directly in the browser. Pure Javascript code can be intermixed with Objective-J, just as Objective-C allows pure C code. This is because each language is a strict superset of its base language.
For app compilation and running other toolchain components in preparation for deployment to production, a desktop Javascript engine supporting CommonJS for accessing local resources is required.
Historically, this engine was [Narwhal](https://narwhaljs.org/).
A transition to [Node.js](https://nodejs.org) is being finalized.
The results of this transition are available as a **Release Candidate**.
While an official production release is scheduled for early-autumn 2024, it should be considered production-ready as-is. Multiple production deployments over the last twelve months have confirmed this.
In addition to the Node.js-based toolchain, the next formal release will include both maintenance improvements and enhancements to the API.
### Permisson issues
By default npm uses `/usr/local/lib/node_modules` as the install location for globally installed packages. This causes
problems since users typically lack write permissions there. It is therefore recommended to either use a version
manager, or change npm's default install location manually (which is what we did above with the `npm set prefix…` command). For more details see [this article](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally).
4. Go to `localhost:8000` in your web browser.
### Building Cappuccino from source
To build Cappuccino from source (for the latest version, including un-released changes) clone the GitHub repository at
To build Cappuccino from source clone the GitHub repository at
https://github.com/cappuccino/cappuccino/ and checkout the `main` branch. Use the command
`jake install` to install the Cappuccino frameworks and toolchain locally.
@@ -95,86 +101,51 @@ To build from source, do:
2. `cd cappuccino`
3. `npm install`. Cappuccino source currently uses the release distribution from npm to bootstrap the toolchain.
3. `git checkout node`
4. `npm install`
5. Make any desired changes to the codebase.
4. Make sure the environment variable `CAPP_BUILD` is set. This is done by adding the line
6. Make sure the environment variable `CAPP_BUILD` is set. This is done by adding the line
```bash
export CAPP_BUILD="/path/to/cappuccino/build/directory"
```
to your `.zshrc` or equivalent config file and of course changing the path to where you want to build Cappuccino.
5. Run `jake build` to build Cappuccino.
6. Run `jake dist` to install the toolchain, as just compiled from source. This step may require elevated permissions.
7. Run `jake install` to build and install Cappuccino.
Beware that building and installing Cappuccino from source will overwrite the binaries installed from npm. To undo this,
simply run `npm install -g @objj/cappuccino` again.
## FAQs
**Q: What is meant by desktop-class apps?**
**A:** Desktop-class apps refer to web applications that offer the same level of functionality, complexity, and user experience as traditional desktop applications. These apps leverage keyboard navigation, advanced user interface components, rich graphics, and responsive interactions. Cappuccino is ideally suited for developing line-of-business applications, which are essential tools used within a company for its operations. Such applications often require robust data handling, complex workflows, and a high degree of reliability. Cappuccinos comprehensive framework, modeled after the Cocoa® APIs, ensures that web applications can match the capabilities and performance of native desktop software.
**Q: I don't see any support for touch-screen devices like tablets and phones. Is this supported?**
**A:** Cappuccino applications can be adapted to support touch-screen devices, including tablets and phones. The framework primarily targets large, information-dense displays typical of desktop environments. Achieving a seamless experience across desktops, tablets, and phones requires additional effort, such as incorporating touch event handling and responsive design. However, with the right adjustments, Cappuccino applications can deliver a consistent user experience on a variety of devices.
For those looking to extend Cappuccino for touch applications, one option worth exploring is the open source Objective-C framework ["Chameleon"](https://github.com/BigZaphod/Chameleon). This predates Apple's Catalyst efforts and ports many UIKit classes to AppKit, allowing for a seamless integration of touch features. See below for porting Objective-C code to Objective-J, something which is mostly a search-and-replace operation.
**Q: How easy is it to port Objective-C code to Objective-J?**
**A:** Porting Objective-C code to Objective-J is mostly a search-and-replace operation, primarily focusing on adapting pointer syntax and class names to fit the Objective-J framework.
Here is a summary of the process:
1. **Replace class prefixes**: Objective-C classes using the 'NS' prefix need to be replaced with 'CP'. Objective-C(J) does not support formal namespaces - class prefixes are used to overcome this ('NS' for Apple/NeXTSTEP, 'CP' for Cappuccino). Third-party code may use something else - or none at all. For example:
`NSString` becomes `CPString`, `NSArray` becomes `CPArray`, and `NSDictionary` becomes `CPDictionary`
2. **Remove pointer references:** Objective-C uses pointers, indicated by the * symbol, which are not used in Objective-J. See example below.
3. **Adapt memory management:** Objective-C's manual memory management and automatic reference counting (ARC) do not apply to Objective-J. Thus, methods like retain, release, and autorelease are removed. Objective-J relies on JavaScript's garbage collection - interaction with it is not supported by any browser.
4. **Modify code with no direct equivalent in Objective-J:** The most common is the C language `enum` construct. Javascript and Objective-J provide no direct equivalent - replace with Javascript objects or functions.
**A simple example:**
*Objective-C:*
```objc
NSString *greeting = [NSString stringWithFormat:@"Hello, %@!", name];
```
*Objective-J:*
```objj
let greeting = [CPString stringWithFormat:@"Hello, %@!", name];
```
FAQs
----
**Q: Can I use Cappuccino on Windows/Linux?**
**A:** Yes - while Cappuccino technology is inspired by Apple's framework, it is inherently platform-independent. As long as you have a modern web browser and a compatible development environment (An LTS version of Node.js, a text editor, and an http server), Cappuccino applications can be developed on and deployed from other operating systems without any issues.
**A:** Yes, Cappuccino can be used on Windows or Linux. While Cappuccino technology is inspired by Apple's Cocoa framework, it is designed to be platform-independent. As long as you have a modern web browser and a compatible development environment (An LTS version of Node.js and an http server), you can develop and deploy Cappuccino applications on other operating systems without any issues.
**Q: Hasn't Apple moved away from Objective-C and AppKit, making them obsolete?**
**A:** While Apple has indeed introduced Swift as a modern programming language and shifted its focus to frameworks like SwiftUI, Objective-C and AppKit are still widely used and supported. Apple's most sophisticated user applications are written either entirely or substantially in Objective-C and will continue to be for the foreseeable future.
**Q: Has Apple not moved away from Objective-C and Cocoa, making this a dead end?**
**A:** While Apple has introduced Swift as a modern language and shifted focus to frameworks like SwiftUI, Objective-C and Cocoa remain widely used and supported. Cappuccino leverages the mature and proven Cocoa architecture, which continues to be relevant for many applications. Additionally, Cappuccinos design abstracts these technologies to the web, ensuring that developers can create robust web applications regardless of Apples evolving ecosystem.
**Q: What is with the funny syntax of Objective-J and its brackets? I've never seen a language like this how can anyone be productive with something so strange?**
**A:** Objective-Js syntax, with its brackets, is inspired by Objective-C, which is a small superset of C. The brackets may seem unusual initially, but provide a powerful way to structure code and manage objects while keeping full compatibility with C. Similarly, Objective-J is a small superset of JavaScript. Developers familiar with Objective-C will find it intuitive, and those new to it can leverage extensive documentation and community resources. The initial learning curve is offset by the productivity gains in building complex, maintainable web applications with the option to mix and match from the vast repository of JavaScript code directly even within Objective-J classes.
**A:** Objective-Js syntax, with its brackets, is inspired by Objective-C, which has been used for decades in developing macOS and iOS applications. While it may seem unusual initially, it provides a powerful way to structure code and manage objects. Developers familiar with Objective-C will find it intuitive, and those new to it can leverage extensive documentation and community resources. The initial learning curve is offset by the productivity gains in building complex, maintainable web applications.
**Q: I have my own HTML, JavaScript, and CSS which I would like to use in a larger app. I don't see any JavaScript, HTML, or CSS in the available sample code. How do I do this?**
**A:** Cappuccino abstracts much of the DOM to align with Cocoa®'s model. Existing framework controls can be extended or new ones built from scratch to meet specific requirements. The Cappuccino APIs follow a classic object-oriented programming model most necessary functionality will be inherited from the Cappuccino base class one is starting with. The [CPWebView](https://www.cappuccino.dev/learn/documentation/interface_c_p_web_view.html) control can also be used to embed either HTML/Javascript/CSS fragments or entire web pages. Javascript can be intermixed with Objective-J code.
**Q: I have my own HTML, JavaScript, and CSS I'd like to use in a larger app. I don't see any JavaScript, HTML, or CSS in the sample code available. How do I modify the DOM?**
**A:** Cappuccino abstracts much of the DOM to align with Cocoa's model. Existing Cocoa controls can be extended or new ones built from scratch to meet specific requirements. The Cocoa APIs follow a classic object-oriented programming model most necessary functionality will be inherited from the Cappuccino base class one is starting with. The [CPWebView](https://www.cappuccino.dev/learn/documentation/interface_c_p_web_view.html) control can also be used to embed either HTML/Javascript/CSS fragments or entire web pages.
**Q: What are the advantages of Cappuccino over libraries and frameworks like React and Vue?**
**A:** Cappuccino offers several advantages:
* Cocoa®/NeXTSTEP Architecture: Leverages the mature and robust APIs developed originally by NeXTSETP in the 1980s and extended by Apple, providing a time-tested and solid foundation for complex applications.
* Message-Passing Object-Oriented Approach: Uses Objective-J, which extends JavaScript with powerful object-oriented capabilities. This is used to provide a loosely-coupled component architecture, allowing better opportunities for keeping functionality tightly grouped - enhancing testability, reliability and large-scale development.
* Desktop-Class Usability: Complex controls, coherent keyboard navigation and undo/redo out of the box.
* Unified Framework: Integrated UI components, event handling, and data management in one cohesive package, well beyond what React and Vue provide.
* Legacy and Stability: Continuously in development since 2008.
* Cocoa Architecture: Leverages the mature and robust Cocoa APIs, providing a solid foundation for complex applications.
* Object-Oriented Approach: Uses Objective-J, which extends JavaScript with powerful object-oriented capabilities.
* Desktop-Class Applications: Designed for creating rich, desktop-like applications that run in web browsers.
* Unified Framework: Integrates UI components, event handling, and data management in a cohesive package.
* Legacy and Stability: Continuous development since 2008 (1986, if going back to the inception of Objective-C and Cocoa) ensures stability and reliability.
**Q: Does the license permit non-opensource development?**
**A:** Yes, Cappuccino is released under the Lesser General Public License (LGPL) version 2. This allows developers to use, modify, and distribute Cappuccino for both open-source and closed-source applications. Commercial and proprietary software can be developed with Cappuccino without the obligation to release source code, provided the terms of the LGPL are adhered to. This means any modifications to the Cappuccino framework itself must be made available under the same LGPL license, but your own application code remains proprietary.
**Q: I've heard claims about Objective-C and Cocoa providing increased productivity how true is this?**.
**A:** Objective-C and Cocoa are designed for efficiency and ease of use. Their mature, well-documented APIs and comprehensive frameworks enable rapid development of robust applications. The object-oriented nature of Objective-C promotes code reuse and modularity, while Cocoas design patterns streamline common tasks. Developers often find that these features collectively lead to increased productivity, especially for complex, desktop-class applications.
Cocoa® is a registered trademark of Apple Inc., covering a series of computer APIs for software user interfaces.
## License
License
-------
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option)
@@ -0,0 +1,75 @@
/*
* AppController.j
* CPMenuCALayerTest
*
* Created by Mathieu Monney on December 19, 2014.
* Copyright 2014, Vidinoti SA, All rights reserved.
*/
@import <Foundation/CPObject.j>
@implementation MyLayer : CALayer
{
}
- (void)drawInContext:(CGContext)aContext {
CGContextSetFillColor(aContext, [CPColor blackColor]);
CGContextFillRect(aContext, _bounds);
}
@end
@implementation AppController : CPObject
{
MyLayer layer;
}
-(void)changeSize:(id)sender {
var scale = [[sender selectedItem] title];
scale = scale.substr(0,scale.length-1);
// Change the affine transform of the layer to make sure it is updated due to
// https://github.com/cappuccino/cappuccino/pull/2018
var af = CGAffineTransformMakeScale(scale/100.0,scale/100.0);
[layer setAffineTransform:af];
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView],
popupButton = [[CPPopUpButton alloc] initWithFrame:CGRectMakeZero()];
// Changing the button should change the size of the layer if #2018 is fixed.
[popupButton addItemsWithTitles:[@"100%",@"50%",@"25%"]];
[popupButton sizeToFit];
[popupButton setAction:@selector(changeSize:)];
[popupButton setTarget:self];
[popupButton setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
[popupButton setCenter:[contentView center]];
[contentView addSubview:popupButton];
[theWindow orderFront:self];
var layerRoot = [[CALayer alloc ] init];
[layerRoot setBounds:CGRectMake(0,0,[contentView bounds].size.width,[contentView bounds].size.height)];
[layerRoot setPosition:CGPointMake(0,0)];
[contentView setWantsLayer:YES];
[contentView setLayer:layerRoot];
layer = [[MyLayer alloc ] init];
[layer setBounds:CGRectMake(0,0,100,100)];
[layer setPosition:CGPointMake([contentView bounds].size.width/2,[contentView bounds].size.height/2-100)];
[layer setNeedsDisplay];
[layerRoot addSublayer:layer];
// Uncomment the following line to turn on the standard menu bar.
//[CPMenu setMenuBarVisible:YES];
}
@end
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CPApplicationDelegateClass</key>
<string>AppController</string>
<key>CPBundleName</key>
<string>CPMenuCALayerTest</string>
<key>CPPrincipalClass</key>
<string>CPApplication</string>
</dict>
</plist>
+93
View File
@@ -0,0 +1,93 @@
/*
* Jakefile
* CPMenuCALayerTest
*
* Created by Mathieu Monney on December 19, 2014.
* Copyright 2014, Vidinoti SA, All rights reserved.
*/
var ENV = require("system").env,
FILE = require("file"),
JAKE = require("jake"),
task = JAKE.task,
FileList = JAKE.FileList,
app = require("cappuccino/jake").app,
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug",
OS = require("os");
app ("CPMenuCALayerTest", function(task)
{
task.setBuildIntermediatesPath(FILE.join("Build", "CPMenuCALayerTest.build", configuration));
task.setBuildPath(FILE.join("Build", configuration));
task.setProductName("CPMenuCALayerTest");
task.setIdentifier("com.yourcompany.CPMenuCALayerTest");
task.setVersion("1.0");
task.setAuthor("WireLoad, LLC");
task.setEmail("feedback @nospam@ yourcompany.com");
task.setSummary("CPMenuCALayerTest");
task.setSources((new FileList("**/*.j")).exclude(FILE.join("Build", "**")));
task.setResources(new FileList("Resources/**"));
task.setIndexFilePath("index.html");
task.setInfoPlistPath("Info.plist");
if (configuration === "Debug")
task.setCompilerFlags("-DDEBUG -g");
else
task.setCompilerFlags("-O");
});
task ("default", ["CPMenuCALayerTest"], function()
{
printResults(configuration);
});
task ("build", ["default"]);
task ("debug", function()
{
ENV["CONFIGURATION"] = "Debug";
JAKE.subjake(["."], "build", ENV);
});
task ("release", function()
{
ENV["CONFIGURATION"] = "Release";
JAKE.subjake(["."], "build", ENV);
});
task ("run", ["debug"], function()
{
OS.system(["open", FILE.join("Build", "Debug", "CPMenuCALayerTest", "index.html")]);
});
task ("run-release", ["release"], function()
{
OS.system(["open", FILE.join("Build", "Release", "CPMenuCALayerTest", "index.html")]);
});
task ("deploy", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Deployment", "CPMenuCALayerTest"));
OS.system(["press", "-f", FILE.join("Build", "Release", "CPMenuCALayerTest"), FILE.join("Build", "Deployment", "CPMenuCALayerTest")]);
printResults("Deployment")
});
task ("desktop", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Desktop", "CPMenuCALayerTest"));
require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "CPMenuCALayerTest"), FILE.join("Build", "Desktop", "CPMenuCALayerTest", "CPMenuCALayerTest.app"));
printResults("Desktop")
});
task ("run-desktop", ["desktop"], function()
{
OS.system([FILE.join("Build", "Desktop", "CPMenuCALayerTest", "CPMenuCALayerTest.app", "Contents", "MacOS", "NativeHost"), "-i"]);
});
function printResults(configuration)
{
print("----------------------------");
print(configuration+" app built at path: "+FILE.join("Build", configuration, "CPMenuCALayerTest"));
print("----------------------------");
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

@@ -0,0 +1,103 @@
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
index-debug.html
CPMenuCALayerTest
Created by Mathieu Monney on December 19, 2014.
Copyright 2014, Vidinoti SA, All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="Resources/icon.png" />
<link rel="apple-touch-startup-image" href="Resources/default.png" />
<title>CPMenuCALayerTest</title>
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
</script>
<script src="Frameworks/Debug/Objective-J/Objective-J.js" type="text/javascript" charset="UTF-8"></script>
<script type="text/javascript">
objj_msgSend_reset();
// DEBUG OPTIONS:
// Uncomment to enable printing of backtraces on exceptions:
//objj_msgSend_decorate(objj_backtrace_decorator);
// Uncomment to supress exceptions that take place inside a message
//objj_msgSend_decorate(objj_supress_exceptions_decorator)
// Uncomment to enable runtime type checking:
//objj_msgSend_decorate(objj_typecheck_decorator);
// Uncomment (along with both above) to print backtraces on type check errors:
//objj_typecheck_prints_backtrace = true;
// Uncomment to disable the default logger (CPLogConsole if window.console exists, CPLogPopup otherwise):
//CPLogUnregister(CPLogDefault);
// Uncomment to enable a specific logger:
//CPLogRegister(CPLogConsole);
//CPLogRegister(CPLogPopup);
</script>
<style type="text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
</style>
<!--[if lt IE 7]>
<STYLE type="text/css">
#container { position: relative; top: 50%; }
#content { position: relative;}
</STYLE>
<![endif]-->
</head>
<body style="">
<div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type="text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading CPMenuCALayerTest...</p></div>");
</script>
<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino-project.org/noscript">Show me how to enable JavaScript</a></p>
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
</ul>
</div>
</div>
</noscript>
</div>
</div>
</body>
</html>
+78
View File
@@ -0,0 +1,78 @@
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
index.html
CPMenuCALayerTest
Created by Mathieu Monney on December 19, 2014.
Copyright 2014, Vidinoti SA, All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="Resources/icon.png" />
<link rel="apple-touch-startup-image" href="Resources/default.png" />
<title>CPMenuCALayerTest</title>
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
</script>
<script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>
<style type="text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
</style>
<!--[if lt IE 7]>
<STYLE type="text/css">
#container { position: relative; top: 50%; }
#content { position: relative;}
</STYLE>
<![endif]-->
</head>
<body style="">
<div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type="text/javascript">
document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading CPMenuCALayerTest...</p></div>");
</script>
<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino-project.org/noscript">Show me how to enable JavaScript</a></p>
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
</ul>
</div>
</div>
</noscript>
</div>
</div>
</body>
</html>
+18
View File
@@ -0,0 +1,18 @@
/*
* AppController.j
* CPMenuCALayerTest
*
* Created by Mathieu Monney on December 19, 2014.
* Copyright 2014, Vidinoti SA, All rights reserved.
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@import "AppController.j"
function main(args, namedArgs)
{
CPApplicationMain(args, namedArgs);
}