mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
finish removing apple.jar, roll ThinkDifferent into MacPlatform
This commit is contained in:
@@ -28,9 +28,13 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
|
||||
import processing.app.Base;
|
||||
import processing.app.Messages;
|
||||
import processing.app.platform.DefaultPlatform;
|
||||
import processing.app.ui.About;
|
||||
|
||||
|
||||
/**
|
||||
@@ -54,8 +58,42 @@ public class MacPlatform extends DefaultPlatform {
|
||||
|
||||
public void initBase(Base base) {
|
||||
super.initBase(base);
|
||||
|
||||
final Desktop desktop = Desktop.getDesktop();
|
||||
|
||||
System.setProperty("apple.laf.useScreenMenuBar", "true");
|
||||
ThinkDifferent.init(base);
|
||||
|
||||
// Set the menu bar to be used when nothing else is open.
|
||||
JMenuBar defaultMenuBar = new JMenuBar();
|
||||
JMenu fileMenu = base.initDefaultFileMenu();
|
||||
defaultMenuBar.add(fileMenu);
|
||||
desktop.setDefaultMenuBar(defaultMenuBar);
|
||||
|
||||
desktop.setAboutHandler((event) -> {
|
||||
new About(null);
|
||||
});
|
||||
|
||||
desktop.setPreferencesHandler((event) -> {
|
||||
base.handlePrefs();
|
||||
});
|
||||
|
||||
desktop.setOpenFileHandler((event) -> {
|
||||
for (File file : event.getFiles()) {
|
||||
base.handleOpen(file.getAbsolutePath());
|
||||
}
|
||||
});
|
||||
|
||||
desktop.setPrintFileHandler((event) -> {
|
||||
// TODO not yet implemented
|
||||
});
|
||||
|
||||
desktop.setQuitHandler((event, quitResponse) -> {
|
||||
if (base.handleQuit()) {
|
||||
quitResponse.performQuit();
|
||||
} else {
|
||||
quitResponse.cancelQuit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2012-2014 The Processing Foundation
|
||||
Copyright (c) 2007-2012 Ben Fry and Casey Reas
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
version 2, as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.app.platform;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
|
||||
import processing.app.Base;
|
||||
import processing.app.ui.About;
|
||||
|
||||
|
||||
/**
|
||||
* Deal with issues related to thinking differently. This handles the basic
|
||||
* Mac OS X menu commands (and apple events) for open, about, prefs, etc.
|
||||
*
|
||||
* As of 0140, this code need not be built on platforms other than OS X,
|
||||
* because of the new platform structure which isolates through reflection.
|
||||
*
|
||||
* Rewritten for 0232 to remove deprecation issues, per the message
|
||||
* <a href="http://lists.apple.com/archives/java-dev/2012/Jan/msg00101.html">here</a>.
|
||||
* (We're able to do this now because we're dropping older Java versions.)
|
||||
*/
|
||||
public class ThinkDifferent {
|
||||
|
||||
static private ThinkDifferent adapter;
|
||||
|
||||
|
||||
static protected void init(final Base base) {
|
||||
final Desktop desktop = Desktop.getDesktop();
|
||||
|
||||
if (adapter == null) {
|
||||
adapter = new ThinkDifferent();
|
||||
}
|
||||
|
||||
desktop.setAboutHandler((event) -> {
|
||||
new About(null);
|
||||
});
|
||||
|
||||
desktop.setPreferencesHandler((event) -> {
|
||||
base.handlePrefs();
|
||||
});
|
||||
|
||||
desktop.setOpenFileHandler((event) -> {
|
||||
for (File file : event.getFiles()) {
|
||||
base.handleOpen(file.getAbsolutePath());
|
||||
}
|
||||
});
|
||||
|
||||
desktop.setPrintFileHandler((event) -> {
|
||||
// TODO not yet implemented
|
||||
});
|
||||
|
||||
desktop.setQuitHandler((event, quitResponse) -> {
|
||||
if (base.handleQuit()) {
|
||||
quitResponse.performQuit();
|
||||
} else {
|
||||
quitResponse.cancelQuit();
|
||||
}
|
||||
});
|
||||
|
||||
// Set the menu bar to be used when nothing else is open.
|
||||
JMenuBar defaultMenuBar = new JMenuBar();
|
||||
JMenu fileMenu = base.initDefaultFileMenu();
|
||||
defaultMenuBar.add(fileMenu);
|
||||
desktop.setDefaultMenuBar(defaultMenuBar);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="library/jogl-all.jar"/>
|
||||
<classpathentry kind="lib" path="library/gluegen-rt.jar"/>
|
||||
<classpathentry kind="lib" path="apple.jar"/>
|
||||
<classpathentry kind="lib" path="library/javafx.graphics.jar"/>
|
||||
<classpathentry kind="lib" path="library/javafx.base.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/JavaFX11"/>
|
||||
|
||||
@@ -9,6 +9,7 @@ after the JDK 11 update
|
||||
X use a new pref for the sketchbook folder location for 4.x
|
||||
X finish porting ThinkDifferent to use Desktop APIs
|
||||
X http://openjdk.java.net/jeps/272
|
||||
X also roll it into MacPlatform, since less platform-specific code needed
|
||||
_ Implement reliable getLibraryFolder() and getDocumentsFolder() methods in MacPlatform
|
||||
_ https://github.com/processing/processing4/issues/9
|
||||
|
||||
|
||||
Reference in New Issue
Block a user