Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Projector Screen Margins #190

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c885875
Support margins via config file for custom coords
dallonf Jul 5, 2019
e114841
Apply margins to monitor display
dallonf Jul 5, 2019
69dedb2
Save display margins in a single property line
dallonf Jul 5, 2019
a613c44
Started adding margin settings UI
dallonf Jul 5, 2019
e1e2f9d
Add other margin fields
dallonf Jul 29, 2019
e9ec095
Only show margins UI for projector settings
dallonf Jul 29, 2019
0478cc6
Can now save margin from settings UI
dallonf Jul 29, 2019
a1b982a
Can now set margins via UI
dallonf Jul 31, 2019
50997e7
Rename "display margin" to "projector margin"
dallonf Jul 31, 2019
f90d81f
Use margin when updating bounds
dallonf Aug 7, 2019
1f89c6e
Start constraining margins to 99%
dallonf Aug 7, 2019
45edae7
Constrain all margin fields to a total of 99%
dallonf Aug 31, 2019
095a3dd
Merge branch 'master' into feature/margins-settings-ui
dallonf Aug 31, 2019
09d2568
Start adapting margin options to new options UI
dallonf Aug 31, 2019
26d4f7b
Refactor DisplayGroup so I can add new fields to it
dallonf Aug 31, 2019
09bd17c
Added marginTop
dallonf Sep 4, 2019
b09885e
Can now edit the full margin
dallonf Sep 4, 2019
44349d5
Correctly load margins from properties
dallonf Sep 4, 2019
1ce64cb
Validation for margin properties
dallonf Sep 6, 2019
b539b6c
Merge remote-tracking branch 'upstream/master' into feature/margins-s…
dallonf Sep 7, 2019
3068f57
Remove unused imports
dallonf Sep 10, 2019
e85aaaf
Refactor long DisplayGroup constructor
dallonf Sep 10, 2019
5a9061d
Use sliders for margin settings
dallonf Sep 10, 2019
ab863f5
Use PercentSliderControl for margin settings
dallonf Sep 10, 2019
0d2d1a3
Oops, one more unused import
dallonf Sep 10, 2019
1c8e07e
Merge remote-tracking branch 'upstream/master' into feature/margins-s…
dallonf Oct 18, 2019
436c3aa
Don't set fullscreen if margins are set
dallonf Oct 18, 2019
7bf77f3
Move margins check
dallonf Oct 19, 2019
930be83
Merge branch 'master' into feature/margins-settings-ui
berry120 Dec 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Quelea/languages/gb.lang
Original file line number Diff line number Diff line change
Expand Up @@ -716,4 +716,8 @@ filefilters.description.sunday.plus=Sunday plus songs
song.list=Song list
password.empty.label=Empty password found
password.empty.message=The server password cannot be empty. The default password "quelea" will be used unless you enter something in the password box.
projector.margin.top=Margin Top
projector.margin.right=Margin Right
projector.margin.bottom=Margin Bottom
projector.margin.left=Margin Left
slide.transition.label=Use fade transition between slides
77 changes: 77 additions & 0 deletions Quelea/src/main/java/org/quelea/services/utils/PercentMargins.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* This file is part of Quelea, free projection software for churches.
*
* Copyright (C) 2012 Michael Berry
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
package org.quelea.services.utils;

import javafx.geometry.BoundingBox;
import javafx.geometry.Bounds;

/**
* Percentage-based (0-1) margins to be applied to a display
* <p/>
* @author Dallon Feldner
*/
public class PercentMargins {

private double top;
private double right;
private double bottom;
private double left;

public PercentMargins(double top, double right, double bottom, double left) {
this.top = top;
this.right = right;
this.bottom = bottom;
this.left = left;
}

@Override
public String toString() {
return top + "," + right + "," + bottom + "," + left;
}

public double getTop() {
return top;
}

public double getRight() {
return right;
}

public double getBottom() {
return bottom;
}

public double getLeft() {
return left;
}

public Bounds applyMargins(Bounds coords) {
double leftMargin = left * coords.getWidth();
double topMargin = top * coords.getHeight();

return new BoundingBox(
coords.getMinX() + leftMargin,
coords.getMinY() + topMargin,
coords.getWidth() - leftMargin - right* coords.getWidth(),
coords.getHeight() - topMargin - bottom* coords.getHeight()
);
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Properties;
import java.util.logging.Level;

import com.sun.istack.NotNull;
import javafx.geometry.BoundingBox;
import javafx.geometry.Bounds;
import javafx.scene.paint.Color;
Expand Down Expand Up @@ -1124,6 +1125,10 @@ public Bounds getProjectorCoords() {
Integer.parseInt(prop[3]));
}

public Bounds getProjectorCoordsWithMargins() {
return applyProjectorMargin(getProjectorCoords());
}

/**
* Set the custom projector co-ordinates.
* <p>
Expand Down Expand Up @@ -2274,6 +2279,57 @@ public double getLyricHeightBounds() {
return Double.parseDouble(getProperty(lyricHeightBoundKey, "0.9"));
}

public PercentMargins getProjectorMargin() {
String[] parts = getProperty(projectorMarginKey, "0,0,0,0").split(",");
if (parts.length == 4) {
return new PercentMargins(
Double.parseDouble(parts[0]),
Double.parseDouble(parts[1]),
Double.parseDouble(parts[2]),
Double.parseDouble(parts[3])
);
} else {
return new PercentMargins(0,0,0,0);
}
}

public void setProjectorMargin(@NotNull PercentMargins margins) {
setProperty(projectorMarginKey, margins.toString());
}

public void setProjectorMarginTop(double value) {
PercentMargins prop = getProjectorMargin();
PercentMargins newProp = new PercentMargins(value, prop.getRight(), prop.getBottom(), prop.getLeft());
setProjectorMargin(newProp);
}

public void setProjectorMarginRight(double value) {
PercentMargins prop = getProjectorMargin();
PercentMargins newProp = new PercentMargins(prop.getTop(), value, prop.getBottom(), prop.getLeft());
setProjectorMargin(newProp);
}

public void setProjectorMarginBottom(double value) {
PercentMargins prop = getProjectorMargin();
PercentMargins newProp = new PercentMargins(prop.getTop(), prop.getRight(), value, prop.getLeft());
setProjectorMargin(newProp);
}

public void setProjectorMarginLeft(double value) {
PercentMargins prop = getProjectorMargin();
PercentMargins newProp = new PercentMargins(prop.getTop(), prop.getRight(), prop.getBottom(), value);
setProjectorMargin(newProp);
}

public boolean hasProjectorMargin() {
PercentMargins margins = getProjectorMargin();
return margins.getTop() > 0 || margins.getLeft() > 0 || margins.getBottom() > 0 || margins.getRight() > 0;
}

public Bounds applyProjectorMargin(Bounds coords) {
return getProjectorMargin().applyMargins(coords);
}

public boolean getDefaultSongDBUpdate() {
return Boolean.parseBoolean(getProperty(defaultSongDbUpdateKey, "true"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ public class QueleaPropertyKeys {
public static final String stageWCoordKey = "stage.width.coord";
public static final String stageHCoordKey = "stage.height.coord";
public static final String darkThemeKey = "use.dark.theme";
public static final String projectorMarginKey = "projector.margin";
public static final String projectorMarginTopKey = "projector.margin.top";
public static final String projectorMarginRightKey = "projector.margin.right";
public static final String projectorMarginBottomKey = "projector.margin.bottom";
public static final String projectorMarginLeftKey = "projector.margin.left";
public static final String useSlideTransitionKey = "use.fade";
public static final String slideTransitionInDurationKey = "slide.transition.duration.in";
public static final String slideTransitionOutDurationKey = "slide.transition.duration.out";
Expand Down
22 changes: 17 additions & 5 deletions Quelea/src/main/java/org/quelea/windows/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,31 @@ public void run() {
if (lyricsHidden) {
LOGGER.log(Level.INFO, "Hiding projector display on monitor 0 (base 0!)");
Platform.runLater(() -> {
fullScreenWindow = new DisplayStage(Utils.getBoundsFromRect2D(monitors.get(0).getVisualBounds()), false);
fullScreenWindow = new DisplayStage(
QueleaProperties.get().applyProjectorMargin(
Utils.getBoundsFromRect2D(monitors.get(0).getVisualBounds())
),
false
);
fullScreenWindow.hide();
});
} else if (QueleaProperties.get().isProjectorModeCoords()) {
LOGGER.log(Level.INFO, "Starting projector display: ", QueleaProperties.get().getProjectorCoords());
LOGGER.log(Level.INFO, "Starting projector display: ", QueleaProperties.get().getProjectorCoordsWithMargins());
Platform.runLater(() -> {
fullScreenWindow = new DisplayStage(QueleaProperties.get().getProjectorCoords(), false);
fullScreenWindow = new DisplayStage(QueleaProperties.get().getProjectorCoordsWithMargins(), false);
});
} else {
LOGGER.log(Level.INFO, "Starting projector display on monitor {0} (base 0!)", projectorScreen);
Platform.runLater(() -> {
fullScreenWindow = new DisplayStage(Utils.getBoundsFromRect2D(monitors.get(projectorScreen).getBounds()), false);
fullScreenWindow.setFullScreenAlwaysOnTop(true);
fullScreenWindow = new DisplayStage(
QueleaProperties.get().applyProjectorMargin(
Utils.getBoundsFromRect2D(monitors.get(projectorScreen).getBounds())
),
false
);
if (!QueleaProperties.get().hasProjectorMargin()) {
fullScreenWindow.setFullScreenAlwaysOnTop(true);
}
});
}

Expand Down
Loading