Skip to content

Commit c4ea291

Browse files
committed
Compute blend color for tabs and switcher separately
1 parent 7136c44 commit c4ea291

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

platform/core.multitabs/nbproject/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
javac.source=1.8
17+
javac.release=11
1818
javac.compilerargs=-Xlint -Xlint:-serial
1919
javadoc.arch=${basedir}/arch.xml
2020
nbm.needs.restart=true

platform/core.multitabs/src/org/netbeans/core/multitabs/impl/DocumentSwitcherTable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public DocumentSwitcherTable( Controller controller, SwitcherTableItem[] items,
8080
projectColorTabDecorator = null;
8181
}
8282
if( Settings.getDefault().isShowFolderName() ) {
83-
folderNameDecorator = new FolderNameTabDecorator();
83+
folderNameDecorator = new FolderNameTabDecorator(this);
8484
} else {
8585
folderNameDecorator = null;
8686
}

platform/core.multitabs/src/org/netbeans/core/multitabs/impl/FolderNameTabDecorator.java

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,20 @@
2121
import java.awt.Color;
2222
import java.awt.Graphics;
2323
import java.awt.Rectangle;
24+
import java.io.File;
2425
import javax.swing.Icon;
2526
import javax.swing.UIManager;
2627
import org.netbeans.core.multitabs.TabDecorator;
2728
import org.netbeans.core.multitabs.prefs.SettingsImpl;
29+
import org.netbeans.swing.popupswitcher.SwitcherTable;
2830
import org.netbeans.swing.tabcontrol.TabData;
2931
import org.openide.filesystems.FileObject;
3032
import org.openide.loaders.DataObject;
3133
import org.openide.util.lookup.ServiceProvider;
3234
import org.openide.windows.TopComponent;
3335

36+
import static java.util.Objects.requireNonNullElse;
37+
3438
/**
3539
* Show the name of parent folder in tab's title.
3640
* http://netbeans.org/bugzilla/show_bug.cgi?id=222696
@@ -41,9 +45,24 @@
4145
public class FolderNameTabDecorator extends TabDecorator {
4246

4347
private final SettingsImpl settings = new SettingsImpl();
44-
private static final String pathSeparator = System.getProperty( "file.separator", "/" ); //NOI18N
45-
private static final String FONT_COLOR = "<font color=\"" + hiddenColor() + "\">"; //NOI18N
46-
private static final String FONT_COLOR_END = "</font>"; //NOI18N
48+
private final String fadeColor;
49+
50+
/**
51+
* Decorator used for tabs
52+
*/
53+
public FolderNameTabDecorator() {
54+
fadeColor = fadeColor(
55+
requireNonNullElse(UIManager.getColor("nb.multitabs.foreground"), UIManager.getColor("TabbedPane.foreground")), //NOI18N
56+
requireNonNullElse(UIManager.getColor("nb.multitabs.background"), UIManager.getColor("TabbedPane.background")) //NOI18N
57+
);
58+
}
59+
60+
/**
61+
* Decorator used for switcher
62+
*/
63+
FolderNameTabDecorator(SwitcherTable switcher) {
64+
fadeColor = fadeColor(switcher.getForeground(), switcher.getBackground());
65+
}
4766

4867
@Override
4968
public String getText( TabData tab ) {
@@ -57,7 +76,7 @@ public String getText( TabData tab ) {
5776
if( fo.isData() ) {
5877
FileObject folder = fo.getParent();
5978
if( null != folder ) {
60-
String folderName = FONT_COLOR + folder.getNameExt() + pathSeparator + FONT_COLOR_END;
79+
String folderName = "<font color=\"" + fadeColor + "\">" + folder.getNameExt() + File.separator + "</font>"; //NOI18N
6180
String defaultText = tab.getText();
6281

6382
return merge( folderName, defaultText );
@@ -104,17 +123,8 @@ private static String merge( String prefix, String baseText ) {
104123
return res.toString();
105124
}
106125

107-
private static String hiddenColor() {
108-
float a = 0.6f;
109-
110-
Color b = UIManager.getColor("nb.multitabs.background"); //NOI18N
111-
Color f = UIManager.getColor("nb.multitabs.foreground"); //NOI18N
112-
113-
if (b == null || f == null) {
114-
f = UIManager.getColor("TabbedPane.foreground"); //NOI18N
115-
b = UIManager.getColor("TabbedPane.background"); //NOI18N
116-
}
117-
126+
private String fadeColor(Color f, Color b) {
127+
float a = 0.7f;
118128
return String.format("#%02x%02x%02x", //NOI18N
119129
(int)(b.getRed() + a * (f.getRed() - b.getRed())),
120130
(int)(b.getGreen() + a * (f.getGreen() - b.getGreen())),

0 commit comments

Comments
 (0)