| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -185,7 +185,8 @@ run.options.bits.macosx = 32 | |||
| 185 | 185 | # Index of the display to use for running sketches (starts at 1). | |
| 186 | 186 | # Kept this 1-indexed because older vesions of Processing were setting | |
| 187 | 187 | # the preference even before it was being used. | |
| 188 | - run.display = 0 | ||
| 188 | + # -1 means the default display, 0 means all displays | ||
| 189 | + run.display = -1 | ||
| 189 | 190 | ||
| 190 | 191 | # set internally | |
| 191 | 192 | #run.window.bgcolor= | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -105,7 +105,6 @@ public class PApplet implements PConstants { | |||
| 105 | 105 | //{ | |
| 106 | 106 | /** | |
| 107 | 107 | * Full name of the Java version (i.e. 1.5.0_11). | |
| 108 | - * Prior to 0125, this was only the first three digits. | ||
| 109 | 108 | */ | |
| 110 | 109 | public static final String javaVersionName = | |
| 111 | 110 | System.getProperty("java.version"); | |
@@ -690,11 +689,11 @@ public class PApplet implements PConstants { | |||
| 690 | 689 | ||
| 691 | 690 | static public final String ARGS_DISPLAY = "--display"; | |
| 692 | 691 | ||
| 693 | - static public final String ARGS_BGCOLOR = "--bgcolor"; | ||
| 692 | + static public final String ARGS_SPAN_DISPLAYS = "--span"; | ||
| 694 | 693 | ||
| 695 | - static public final String ARGS_FULL_SCREEN = "--full-screen"; | ||
| 694 | + static public final String ARGS_WINDOW_COLOR = "--window-color"; | ||
| 696 | 695 | ||
| 697 | - static public final String ARGS_SPAN_SCREENS = "--span"; | ||
| 696 | + static public final String ARGS_PRESENT = "--present"; | ||
| 698 | 697 | ||
| 699 | 698 | static public final String ARGS_STOP_COLOR = "--stop-color"; | |
| 700 | 699 | ||
@@ -810,13 +809,20 @@ public void init() { | |||
| 810 | 809 | boolean insideSettings; | |
| 811 | 810 | ||
| 812 | 811 | String renderer = JAVA2D; | |
| 813 | - int quality = 2; | ||
| 812 | + // int quality = 2; | ||
| 813 | + int smooth = 1; | ||
| 814 | 814 | boolean fullScreen; | |
| 815 | - boolean spanDisplays; | ||
| 816 | - int displayIndex; | ||
| 815 | + // boolean spanDisplays; | ||
| 816 | + int display; // set to SPAN when using all displays | ||
| 817 | + | ||
| 817 | 818 | String outputPath; | |
| 818 | 819 | OutputStream outputStream; | |
| 819 | 820 | ||
| 821 | + // Background default needs to be different from the default value in | ||
| 822 | + // PGraphics.backgroundColor, otherwise size(100, 100) bg spills over. | ||
| 823 | + // https://github.com/processing/processing/issues/2297 | ||
| 824 | + int windowColor = 0xffDDDDDD; | ||
| 825 | + | ||
| 820 | 826 | ||
| 821 | 827 | boolean insideSettings(Object... args) { | |
| 822 | 828 | if (insideSettings) { | |
@@ -839,42 +845,48 @@ void handleSettings() { | |||
| 839 | 845 | insideSettings = true; | |
| 840 | 846 | ||
| 841 | 847 | // Workaround for https://github.com/processing/processing/issues/3295 | |
| 842 | - // until we resolved https://github.com/processing/processing/issues/3296 | ||
| 848 | + // until we resolve https://github.com/processing/processing/issues/3296 | ||
| 843 | 849 | GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); | |
| 844 | 850 | GraphicsDevice device = ge.getDefaultScreenDevice(); | |
| 845 | 851 | GraphicsDevice[] devices = ge.getScreenDevices(); | |
| 846 | - // default or unparsed will be -1 | ||
| 847 | - if (displayIndex >= 0 && displayIndex < devices.length) { | ||
| 848 | - device = devices[displayIndex]; | ||
| 852 | + | ||
| 853 | + // Default or unparsed will be -1, spanning will be 0, actual displays will | ||
| 854 | + // be numbered from 1 because it's too weird to say "display 0" in prefs. | ||
| 855 | + if (display > 0 && display <= devices.length) { | ||
| 856 | + device = devices[display-1]; | ||
| 849 | 857 | } | |
| 850 | 858 | DisplayMode displayMode = device.getDisplayMode(); | |
| 851 | 859 | displayWidth = displayMode.getWidth(); | |
| 852 | 860 | displayHeight = displayMode.getHeight(); | |
| 853 | 861 | ||
| 862 | + // Here's where size(), fullScreen(), smooth(N) and noSmooth() might | ||
| 863 | + // be called, conjuring up the demons of various rendering configurations. | ||
| 854 | 864 | settings(); | |
| 865 | + | ||
| 855 | 866 | insideSettings = false; | |
| 856 | 867 | } | |
| 857 | 868 | ||
| 858 | 869 | ||
| 859 | 870 | /** Override this method to call size() when not using the PDE. */ | |
| 860 | 871 | public void settings() { | |
| 861 | - size(DEFAULT_WIDTH, DEFAULT_HEIGHT, JAVA2D); | ||
| 872 | + // is this necessary? (doesn't appear to be, so removing) | ||
| 873 | + //size(DEFAULT_WIDTH, DEFAULT_HEIGHT, JAVA2D); | ||
| 862 | 874 | } | |
| 863 | 875 | ||
| 864 | 876 | ||
| 865 | - public int sketchWidth() { | ||
| 877 | + final public int sketchWidth() { | ||
| 866 | 878 | //return DEFAULT_WIDTH; | |
| 867 | 879 | return width; | |
| 868 | 880 | } | |
| 869 | 881 | ||
| 870 | 882 | ||
| 871 | - public int sketchHeight() { | ||
| 883 | + final public int sketchHeight() { | ||
| 872 | 884 | //return DEFAULT_HEIGHT; | |
| 873 | 885 | return height; | |
| 874 | 886 | } | |
| 875 | 887 | ||
| 876 | 888 | ||
| 877 | - public String sketchRenderer() { | ||
| 889 | + final public String sketchRenderer() { | ||
| 878 | 890 | //return JAVA2D; | |
| 879 | 891 | return renderer; | |
| 880 | 892 | } | |
@@ -887,46 +899,55 @@ public String sketchRenderer() { | |||
| 887 | 899 | // smoothing at any given time. It's also a bit like getFill() would return | |
| 888 | 900 | // true/false for whether fill was enabled, getFillColor() would return the | |
| 889 | 901 | // color itself. Or at least that's what I can recall at the moment. [fry] | |
| 890 | - public int sketchQuality() { | ||
| 891 | - //return 2; | ||
| 892 | - return quality; | ||
| 902 | + // public int sketchQuality() { | ||
| 903 | + // //return 2; | ||
| 904 | + // return quality; | ||
| 905 | + // } | ||
| 906 | + // smoothing 1 is default.. 0 is none.. 2,4,8 depend on renderer | ||
| 907 | + final public int sketchSmooth() { | ||
| 908 | + return smooth; | ||
| 893 | 909 | } | |
| 894 | 910 | ||
| 895 | 911 | ||
| 896 | - public boolean sketchFullScreen() { | ||
| 912 | + final public boolean sketchFullScreen() { | ||
| 897 | 913 | //return false; | |
| 898 | 914 | return fullScreen; | |
| 899 | 915 | } | |
| 900 | 916 | ||
| 901 | 917 | ||
| 902 | - // Could be named 'screen' instead of display since it's the people using | ||
| 903 | - // full screen who will be looking for it. On the other hand, screenX/Y/Z | ||
| 904 | - // makes things confusing, and if 'displayIndex' exists... | ||
| 905 | - public boolean sketchSpanDisplays() { | ||
| 906 | - //return false; | ||
| 907 | - return spanDisplays; | ||
| 908 | - } | ||
| 918 | + // // Could be named 'screen' instead of display since it's the people using | ||
| 919 | + // // full screen who will be looking for it. On the other hand, screenX/Y/Z | ||
| 920 | + // // makes things confusing, and if 'displayIndex' exists... | ||
| 921 | + // public boolean sketchSpanDisplays() { | ||
| 922 | + // //return false; | ||
| 923 | + // return spanDisplays; | ||
| 924 | + // } | ||
| 909 | 925 | ||
| 910 | 926 | ||
| 911 | - // Or should this be sketchDisplayNum instead of sketchDisplayIndex? | ||
| 912 | - // (Index seems weird, but we don't use 'num' anywhere.) | ||
| 913 | - public int sketchDisplayIndex() { | ||
| 914 | - return displayIndex; | ||
| 927 | + // Using num instead of index since the latter usually refers 0-indexed lists | ||
| 928 | + // SPAN is used when using all displays | ||
| 929 | + final public int sketchDisplay() { | ||
| 930 | + return display; | ||
| 915 | 931 | } | |
| 916 | 932 | ||
| 917 | 933 | ||
| 918 | - public String sketchOutputPath() { | ||
| 934 | + final public String sketchOutputPath() { | ||
| 919 | 935 | //return null; | |
| 920 | 936 | return outputPath; | |
| 921 | 937 | } | |
| 922 | 938 | ||
| 923 | 939 | ||
| 924 | - public OutputStream sketchOutputStream() { | ||
| 940 | + final public OutputStream sketchOutputStream() { | ||
| 925 | 941 | //return null; | |
| 926 | 942 | return outputStream; | |
| 927 | 943 | } | |
| 928 | 944 | ||
| 929 | 945 | ||
| 946 | + final public int sketchWindowColor() { | ||
| 947 | + return windowColor; | ||
| 948 | + } | ||
| 949 | + | ||
| 950 | + | ||
| 930 | 951 | // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | |
| 931 | 952 | ||
| 932 | 953 | ||
@@ -935,6 +956,7 @@ public PGraphics getGraphics() { | |||
| 935 | 956 | } | |
| 936 | 957 | ||
| 937 | 958 | ||
| 959 | + // TODO should this join the sketchXxxx() functions specific to settings()? | ||
| 938 | 960 | public void orientation(int which) { | |
| 939 | 961 | // ignore calls to the orientation command | |
| 940 | 962 | } | |
@@ -1485,6 +1507,16 @@ protected void resizeRenderer(int newWidth, int newHeight) { | |||
| 1485 | 1507 | */ | |
| 1486 | 1508 | ||
| 1487 | 1509 | ||
| 1510 | + public void fullScreen(String renderer) { | ||
| 1511 | + | ||
| 1512 | + } | ||
| 1513 | + | ||
| 1514 | + | ||
| 1515 | + public void fullScreen(String renderer, int display) { | ||
| 1516 | + | ||
| 1517 | + } | ||
| 1518 | + | ||
| 1519 | + | ||
| 1488 | 1520 | /** | |
| 1489 | 1521 | * ( begin auto-generated from size.xml ) | |
| 1490 | 1522 | * | |
@@ -9447,38 +9479,46 @@ void frameResized(int w, int h) { | |||
| 9447 | 9479 | * <PRE> | |
| 9448 | 9480 | * Parameters useful for launching or also used by the PDE: | |
| 9449 | 9481 | * | |
| 9450 | - * --location=x,y upper-lefthand corner of where the applet | ||
| 9451 | - * should appear on screen. if not used, | ||
| 9452 | - * the default is to center on the main screen. | ||
| 9482 | + * --location=x,y Upper-lefthand corner of where the applet | ||
| 9483 | + * should appear on screen. If not used, | ||
| 9484 | + * the default is to center on the main screen. | ||
| 9485 | + * | ||
| 9486 | + * --present Presentation mode: blanks the entire screen and | ||
| 9487 | + * shows the sketch by itself. If the sketch is | ||
| 9488 | + * smaller than the screen, the background around it | ||
| 9489 | + * will use the --window-color setting. | ||
| 9453 | 9490 | * | |
| 9454 | - * --full-screen put the applet into full screen "present" mode. | ||
| 9491 | + * --hide-stop Use to hide the stop button in situations where | ||
| 9492 | + * you don't want to allow users to exit. also | ||
| 9493 | + * see the FAQ on information for capturing the ESC | ||
| 9494 | + * key when running in presentation mode. | ||
| 9455 | 9495 | * | |
| 9456 | - * --hide-stop use to hide the stop button in situations where | ||
| 9457 | - * you don't want to allow users to exit. also | ||
| 9458 | - * see the FAQ on information for capturing the ESC | ||
| 9459 | - * key when running in presentation mode. | ||
| 9496 | + * --stop-color=#xxxxxx Color of the 'stop' text used to quit an | ||
| 9497 | + * sketch when it's in present mode. | ||
| 9460 | 9498 | * | |
| 9461 | - * --stop-color=#xxxxxx color of the 'stop' text used to quit an | ||
| 9462 | - * sketch when it's in present mode. | ||
| 9499 | + * --window-color=#xxxxxx Background color of the window. The color used | ||
| 9500 | + * around the sketch when it's smaller than the | ||
| 9501 | + * minimum window size for the OS, and the matte | ||
| 9502 | + * color when using 'present' mode. | ||
| 9463 | 9503 | * | |
| 9464 | - * --bgcolor=#xxxxxx background color of the window. | ||
| 9504 | + * --sketch-path location of where to save files from functions | ||
| 9505 | + * like saveStrings() or saveFrame(). defaults to | ||
| 9506 | + * the folder that the java application was | ||
| 9507 | + * launched from, which means if this isn't set by | ||
| 9508 | + * the pde, everything goes into the same folder | ||
| 9509 | + * as processing.exe. | ||
| 9465 | 9510 | * | |
| 9466 | - * --sketch-path location of where to save files from functions | ||
| 9467 | - * like saveStrings() or saveFrame(). defaults to | ||
| 9468 | - * the folder that the java application was | ||
| 9469 | - * launched from, which means if this isn't set by | ||
| 9470 | - * the pde, everything goes into the same folder | ||
| 9471 | - * as processing.exe. | ||
| 9511 | + * --display=n set what display should be used by this sketch. | ||
| 9512 | + * displays are numbered starting from 1. | ||
| 9472 | 9513 | * | |
| 9473 | - * --display=n set what display should be used by this sketch. | ||
| 9474 | - * displays are numbered starting from 0. | ||
| 9514 | + * --span Makes the sketch full screen across all displays. | ||
| 9475 | 9515 | * | |
| 9476 | 9516 | * Parameters used by Processing when running via the PDE | |
| 9477 | 9517 | * | |
| 9478 | - * --external set when the applet is being used by the PDE | ||
| 9518 | + * --external set when the applet is being used by the PDE | ||
| 9479 | 9519 | * | |
| 9480 | - * --editor-location=x,y position of the upper-lefthand corner of the | ||
| 9481 | - * editor window, for placement of applet window | ||
| 9520 | + * --editor-location=x,y position of the upper-lefthand corner of the | ||
| 9521 | + * editor window, for placement of applet window | ||
| 9482 | 9522 | * | |
| 9483 | 9523 | * All parameters *after* the sketch class name are passed to the sketch | |
| 9484 | 9524 | * itself and available from its 'args' array while the sketch is running. | |
@@ -9555,13 +9595,13 @@ static protected void runSketchEDT(final String[] args, | |||
| 9555 | 9595 | int[] editorLocation = null; | |
| 9556 | 9596 | ||
| 9557 | 9597 | String name = null; | |
| 9558 | - int backgroundColor = 0; | ||
| 9559 | - //int stopColor = java.awt.Color.GRAY.getRGB(); | ||
| 9598 | + int windowColor = 0; | ||
| 9560 | 9599 | int stopColor = 0xff808080; | |
| 9561 | 9600 | boolean hideStop = false; | |
| 9562 | 9601 | ||
| 9563 | - int displayIndex = -1; // -1 means use default, b/c numbered from 0 | ||
| 9564 | - boolean fullScreen = false; | ||
| 9602 | + int displayIndex = -1; // use default | ||
| 9603 | + // boolean fullScreen = false; | ||
| 9604 | + boolean present = false; | ||
| 9565 | 9605 | boolean spanDisplays = false; | |
| 9566 | 9606 | ||
| 9567 | 9607 | String param = null, value = null; | |
@@ -9584,12 +9624,12 @@ static protected void runSketchEDT(final String[] args, | |||
| 9584 | 9624 | System.err.println("Could not parse " + value + " for " + ARGS_DISPLAY); | |
| 9585 | 9625 | } | |
| 9586 | 9626 | ||
| 9587 | - } else if (param.equals(ARGS_BGCOLOR)) { | ||
| 9627 | + } else if (param.equals(ARGS_WINDOW_COLOR)) { | ||
| 9588 | 9628 | if (value.charAt(0) == '#' && value.length() == 7) { | |
| 9589 | 9629 | value = value.substring(1); | |
| 9590 | - backgroundColor = 0xff000000 | Integer.parseInt(value, 16); | ||
| 9630 | + windowColor = 0xff000000 | Integer.parseInt(value, 16); | ||
| 9591 | 9631 | } else { | |
| 9592 | - System.err.println(ARGS_BGCOLOR + " should be a # followed by six digits"); | ||
| 9632 | + System.err.println(ARGS_WINDOW_COLOR + " should be a # followed by six digits"); | ||
| 9593 | 9633 | } | |
| 9594 | 9634 | ||
| 9595 | 9635 | } else if (param.equals(ARGS_STOP_COLOR)) { | |
@@ -9608,10 +9648,10 @@ static protected void runSketchEDT(final String[] args, | |||
| 9608 | 9648 | } | |
| 9609 | 9649 | ||
| 9610 | 9650 | } else { | |
| 9611 | - if (args[argIndex].equals(ARGS_FULL_SCREEN)) { | ||
| 9612 | - fullScreen = true; | ||
| 9651 | + if (args[argIndex].equals(ARGS_PRESENT)) { | ||
| 9652 | + present = true; | ||
| 9613 | 9653 | ||
| 9614 | - } else if (args[argIndex].equals(ARGS_SPAN_SCREENS)) { | ||
| 9654 | + } else if (args[argIndex].equals(ARGS_SPAN_DISPLAYS)) { | ||
| 9615 | 9655 | spanDisplays = true; | |
| 9616 | 9656 | ||
| 9617 | 9657 | } else if (args[argIndex].equals(ARGS_HIDE_STOP)) { | |
@@ -9673,15 +9713,19 @@ static protected void runSketchEDT(final String[] args, | |||
| 9673 | 9713 | // A handful of things that need to be set before init/start. | |
| 9674 | 9714 | sketch.sketchPath = folder; | |
| 9675 | 9715 | ||
| 9676 | - sketch.spanDisplays = spanDisplays; | ||
| 9716 | + // sketch.spanDisplays = spanDisplays; | ||
| 9677 | 9717 | // If spanning screens, that means we're also full screen. | |
| 9678 | - fullScreen |= spanDisplays; | ||
| 9718 | + // fullScreen |= spanDisplays; | ||
| 9719 | + if (spanDisplays) { | ||
| 9720 | + displayIndex = SPAN; | ||
| 9721 | + // fullScreen = true; | ||
| 9722 | + } | ||
| 9679 | 9723 | ||
| 9680 | - // If the applet doesn't call for full screen, but the command line does, | ||
| 9681 | - // enable it. Conversely, if the command line does not, don't disable it. | ||
| 9682 | - // Query the applet to see if it wants to be full screen all the time. | ||
| 9683 | - //fullScreen |= sketch.sketchFullScreen(); | ||
| 9684 | - sketch.fullScreen |= fullScreen; | ||
| 9724 | + // // If the applet doesn't call for full screen, but the command line does, | ||
| 9725 | + // // enable it. Conversely, if the command line does not, don't disable it. | ||
| 9726 | + // // Query the applet to see if it wants to be full screen all the time. | ||
| 9727 | + // //fullScreen |= sketch.sketchFullScreen(); | ||
| 9728 | + // sketch.fullScreen |= fullScreen; | ||
| 9685 | 9729 | ||
| 9686 | 9730 | // Don't set 'args' to a zero-length array if it should be null [3.0a8] | |
| 9687 | 9731 | if (args.length != argIndex + 1) { | |
@@ -9692,8 +9736,12 @@ static protected void runSketchEDT(final String[] args, | |||
| 9692 | 9736 | ||
| 9693 | 9737 | sketch.external = external; | |
| 9694 | 9738 | ||
| 9695 | - PSurface surface = | ||
| 9696 | - sketch.initSurface(backgroundColor, displayIndex, fullScreen, spanDisplays); | ||
| 9739 | + if (windowColor != 0) { | ||
| 9740 | + sketch.windowColor = windowColor; | ||
| 9741 | + } | ||
| 9742 | + | ||
| 9743 | + PSurface surface = sketch.initSurface(); | ||
| 9744 | + // sketch.initSurface(windowColor, displayIndex, fullScreen, spanDisplays); | ||
| 9697 | 9745 | ||
| 9698 | 9746 | // Wait until the applet has figured out its width. In a static mode app, | |
| 9699 | 9747 | // everything happens inside setup(), so this will be after setup() has | |
@@ -9708,7 +9756,7 @@ static protected void runSketchEDT(final String[] args, | |||
| 9708 | 9756 | } | |
| 9709 | 9757 | } | |
| 9710 | 9758 | ||
| 9711 | - if (fullScreen) { | ||
| 9759 | + if (present) { | ||
| 9712 | 9760 | if (hideStop) { | |
| 9713 | 9761 | stopColor = 0; // they'll get the hint | |
| 9714 | 9762 | } | |
@@ -9723,8 +9771,8 @@ static protected void runSketchEDT(final String[] args, | |||
| 9723 | 9771 | } | |
| 9724 | 9772 | ||
| 9725 | 9773 | ||
| 9726 | - protected PSurface initSurface(int backgroundColor, int displayIndex, | ||
| 9727 | - boolean fullScreen, boolean spanDisplays) { | ||
| 9774 | + protected PSurface initSurface() {/*int backgroundColor, int displayNum, | ||
| 9775 | + boolean fullScreen, boolean spanDisplays) {*/ | ||
| 9728 | 9776 | g = createPrimaryGraphics(); | |
| 9729 | 9777 | surface = g.createSurface(); | |
| 9730 | 9778 | ||
@@ -9755,7 +9803,7 @@ private void deprecationWarning(String method) { | |||
| 9755 | 9803 | } | |
| 9756 | 9804 | }; | |
| 9757 | 9805 | ||
| 9758 | - surface.initFrame(this, backgroundColor, displayIndex, fullScreen, spanDisplays); | ||
| 9806 | + surface.initFrame(this); //, backgroundColor, displayNum, fullScreen, spanDisplays); | ||
| 9759 | 9807 | surface.setTitle(getClass().getName()); | |
| 9760 | 9808 | ||
| 9761 | 9809 | } else { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments