CM3: Add support for dark themes

84a66d82d3 added support for light and
dark themes, but dark themes weren't enabled, as diff styles have
to be adjusted to correspond with dark colors.

101a8c4b65 reverted the preparation
for dark themes support.

This change enables support for subset of dark themes and switch
dynamicaly the diff styles to dark colors, when dark theme was
selected.

Change-Id: Ic220baf8f19366c04520b61e893a0d11912805ef
This commit is contained in:
David Ostrovsky
2014-02-22 11:00:56 +01:00
parent f985847c38
commit 51b373679e
6 changed files with 49 additions and 1 deletions

View File

@@ -39,6 +39,7 @@ class DiffTable extends Composite {
interface DiffTableStyle extends CssResource {
String fullscreen();
String intralineBg();
String dark();
String diff();
String noIntraline();
String activeLine();
@@ -68,7 +69,8 @@ class DiffTable extends Composite {
private SideBySide2 parent;
private boolean headerVisible;
DiffTable(SideBySide2 parent, PatchSet.Id base, PatchSet.Id revision, String path) {
DiffTable(SideBySide2 parent, PatchSet.Id base, PatchSet.Id revision,
String path) {
patchSetSelectBoxA = new PatchSetSelectBox2(
parent, DisplaySide.A, revision.getParentKey(), base, path);
patchSetSelectBoxB = new PatchSetSelectBox2(

View File

@@ -79,6 +79,14 @@ limitations under the License.
.noIntraline .a .intralineBg { background-color: #faa; }
.noIntraline .b .intralineBg { background-color: #9f9; }
.dark .a .diff { background-color: #400; }
.dark .b .diff { background-color: #444; }
.dark .a .intralineBg { background-color: #888; }
.dark .b .intralineBg { background-color: #bbb; }
.dark .noIntraline .a .intralineBg { background-color: #400; }
.dark .noIntraline .b .intralineBg { background-color: #444; }
.patchSetNav {
background-color: #f7f7f7;
line-height: 1;

View File

@@ -302,6 +302,7 @@ class PreferencesBox extends Composite {
@UiHandler("theme")
void onTheme(ChangeEvent e) {
prefs.theme(Theme.valueOf(theme.getValue(theme.getSelectedIndex())));
view.setThemeStyles(prefs.theme().isDark());
view.operation(new Runnable() {
@Override
public void run() {
@@ -397,5 +398,14 @@ class PreferencesBox extends Composite {
theme.addItem(
Theme.NEAT.name().toLowerCase(),
Theme.NEAT.name());
theme.addItem(
Theme.MIDNIGHT.name().toLowerCase(),
Theme.MIDNIGHT.name());
theme.addItem(
Theme.NIGHT.name().toLowerCase(),
Theme.NIGHT.name());
theme.addItem(
Theme.TWILIGHT.name().toLowerCase(),
Theme.TWILIGHT.name());
}
}

View File

@@ -482,6 +482,7 @@ public class SideBySide2 extends Screen {
}
private void display(final CommentsCollections comments) {
setThemeStyles(prefs.theme().isDark());
setShowTabs(prefs.showTabs());
setShowIntraline(prefs.intralineDifference());
if (prefs.showLineNumbers()) {
@@ -560,6 +561,14 @@ public class SideBySide2 extends Screen {
return diff.intraline_status();
}
void setThemeStyles(boolean d) {
if (d) {
diffTable.addStyleName(DiffTable.style.dark());
} else {
diffTable.removeStyleName(DiffTable.style.dark());
}
}
void setShowTabs(boolean b) {
if (b) {
diffTable.addStyleName(DiffTable.style.showTabs());

View File

@@ -56,10 +56,26 @@ public class AccountDiffPreference {
}
public static enum Theme {
// Light themes
DEFAULT,
ECLIPSE,
ELEGANT,
NEAT,
// Dark themes
MIDNIGHT,
NIGHT,
TWILIGHT;
public boolean isDark() {
switch (this) {
case MIDNIGHT:
case NIGHT:
case TWILIGHT:
return true;
default:
return false;
}
}
}
public static AccountDiffPreference createDefault(Account.Id accountId) {

View File

@@ -6,7 +6,10 @@ CM3_CSS = [
CM3_THEMES = [
'theme/eclipse.css',
'theme/elegant.css',
'theme/midnight.css',
'theme/neat.css',
'theme/night.css',
'theme/twilight.css',
]
CM3_JS = [