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

Added graying out for UI options as in #3755 #3761

Merged
merged 5 commits into from
Mar 23, 2016
Merged
Changes from 3 commits
Commits
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
78 changes: 57 additions & 21 deletions Apps/Sandcastle/gallery/development/Shadows.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,36 +33,36 @@
<div id="toolbar">
<table><tbody>
<tr>
<td>Light Horizon</td>
<td data-bind="style: { color: lightHorizonEnabled ? '' : 'gray'}">Light Horizon</td>
<td>
<input type="range" min="0" max="90" step="1.0" data-bind="value: lightHorizon, valueUpdate: 'input'">
<input type="text" size="2" data-bind="value: lightHorizon">
<input type="range" min="0" max="90" step="1.0" data-bind="value: lightHorizon, valueUpdate: 'input', enable: lightHorizonEnabled">
<input type="text" size="2" data-bind="value: lightHorizon, enable: lightHorizonEnabled">
</td>
</tr>
<tr>
<td>Light Angle</td>
<td data-bind="style: { color: lightAngleEnabled ? '' : 'gray'}">Light Angle</td>
<td>
<input type="range" min="0" max="360" step="1.0" data-bind="value: lightAngle, valueUpdate: 'input'">
<input type="text" size="2" data-bind="value: lightAngle">
<input type="range" min="0" max="360" step="1.0" data-bind="value: lightAngle, valueUpdate: 'input', enable: lightAngleEnabled">
<input type="text" size="2" data-bind="value: lightAngle, enable: lightAngleEnabled">
</td>
</tr>
<tr>
<td>Distance Limit</td>
<td data-bind="style: { color: distanceEnabled ? '' : 'gray'}">Distance Limit</td>
<td>
<input type="range" min="100.0" max="10000.0" step="1.0" data-bind="value: distance, valueUpdate: 'input'">
<input type="text" size="2" data-bind="value: distance">
<input type="range" min="100.0" max="10000.0" step="1.0" data-bind="value: distance, valueUpdate: 'input', enable: distanceEnabled">
<input type="text" size="2" data-bind="value: distance, enable: distanceEnabled">
</td>
</tr>
<tr>
<td>Radius</td>
<td data-bind="style: { color: radiusEnabled ? '' : 'gray'}">Radius</td>
<td>
<input type="range" min="10.0" max="1000.0" step="1.0" data-bind="value: radius, valueUpdate: 'input'">
<input type="text" size="2" data-bind="value: radius">
<input type="range" min="10.0" max="1000.0" step="1.0" data-bind="value: radius, valueUpdate: 'input', enable: radiusEnabled">
<input type="text" size="2" data-bind="value: radius, enable: radiusEnabled">
</td>
</tr>
<tr>
<td>Cascades</td>
<td><select data-bind="options: cascadeOptions, value: cascades"/></td>
<td data-bind="style: { color: cascadesEnabled ? '' : 'gray'}">Cascades</td>
<td><select data-bind="options: cascadeOptions, value: cascades, enabled: cascadesEnabled"/></td>
</tr>
<tr>
<td>Light Source</td>
Expand All @@ -77,8 +77,8 @@
<td><input type="checkbox" data-bind="checked: shadows"/></td>
</tr>
<tr>
<td>Terrain Cast</td>
<td><input type="checkbox" data-bind="checked: terrainCast"/></td>
<td data-bind="style: { color: terrainCastEnabled ? '' : 'gray'}">Terrain Cast</td>
<td><input type="checkbox" data-bind="checked: terrainCast, enabled: terrainCastEnabled"/></td>
</tr>
<tr>
<td>Show debug</td>
Expand All @@ -89,12 +89,16 @@
<td><input type="checkbox" data-bind="checked: freeze"/></td>
</tr>
<tr>
<td>Cascade colors</td>
<td><input type="checkbox" data-bind="checked: cascadeColors"/></td>
<td data-bind="style: { color: cascadeColorsEnabled ? '' : 'gray'}">Cascade colors</td>
<td><input type="checkbox" data-bind="checked: cascadeColors, enabled: cascadeColorsEnabled"/></td>
</tr>
<tr>
<td>Fit near/far</td>
<td><input type="checkbox" data-bind="checked: fitNearFar"/></td>
<td data-bind="style: { color: fitNearFarEnabled ? '' : 'gray'}">Fit near/far</td>
<td><input type="checkbox" data-bind="checked: fitNearFar, enabled: fitNearFarEnabled"/></td>
</tr>
<tr>
<td data-bind="style: { color: softShadowsEnabled ? '' : 'gray'}">Soft shadows</td>
<td><input type="checkbox" data-bind="checked: softShadows, enabled: softShadowsEnabled"/></td>
</tr>
<tr>
<td>Soft shadows</td>
Expand All @@ -109,23 +113,42 @@

var viewModel = {
lightAngle : 0.0,
lightAngleEnabled : true,
lightHorizon : 0.0,
lightHorizonEnabled : true,
distance : 1000.0,
distanceEnabled : true,
radius : 200.0,
radiusEnabled : true,
shadows : true,
terrainCast : false,
terrainCastEnabled : true,
debug : true,
freeze : false,
cascadeColors : false,
cascadeColorsEnabled : true,
fitNearFar : true,
fitNearFarEnabled : true,
softShadows : false,
softShadowsEnabled : true,
cascadeOptions : [1, 4],
cascades : 4,
cascadesEnabled : true,
lightSourceOptions : ['Freeform', 'Sun', 'Fixed', 'Point'],
lightSource : 'Freeform',
sizeOptions : [256, 512, 1024, 2048],
size : 1024
size : 1024,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comma.

};

var uiOptions = {
all : ['lightHorizon', 'lightAngle', 'distance', 'radius', 'terrainCast', 'cascades', 'cascadeColors', 'fitNearFar', 'softShadows'],
disable : {
'Freeform' : ['radius'],
'Sun' : ['lightHorizon', 'lightAngle', 'radius'],
'Fixed' : ['lightHorizon', 'lightAngle', 'distance', 'radius', 'cascades', 'cascadeColors', 'fitNearFar'],
'Point' : ['lightHorizon', 'lightAngle', 'distance', 'cascades', 'cascadeColors', 'fitNearFar', 'softShadows']
}
}

Cesium.knockout.track(viewModel);
var toolbar = document.getElementById('toolbar');
Expand All @@ -144,6 +167,7 @@
Cesium.knockout.getObservable(viewModel, 'cascades').subscribe(updateShadows);
Cesium.knockout.getObservable(viewModel, 'lightSource').subscribe(updateShadows);
Cesium.knockout.getObservable(viewModel, 'size').subscribe(updateSettings);
Cesium.knockout.getObservable(viewModel, 'softShadows').subscribe(updateShadows);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest shadows code that you merged in also added this line above, so you can remove this.


var offset = new Cesium.Cartesian3();

Expand Down Expand Up @@ -215,6 +239,18 @@
}

updateSettings();
updateUI();
}

function updateUI() {
uiOptions.all.forEach(function(setting) {
if (uiOptions.disable[viewModel.lightSource].indexOf(setting) > -1) {
viewModel[setting + 'Enabled'] = false;
}
else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small thing, but we usually put the else on the same line.

viewModel[setting + 'Enabled'] = true;
}
});
}

var globeVisible = true;
Expand Down