Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
d5628847
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d5628847
编写于
8月 03, 2019
作者:
P
pbansal
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8226964: [Yaru] GTK L&F: There is no difference between menu selected and de-selected
Reviewed-by: prr, kcr
上级
4a241d11
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
87 addition
and
0 deletion
+87
-0
src/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java
...share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java
+79
-0
src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java
src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java
+8
-0
未找到文件。
src/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java
浏览文件 @
d5628847
...
...
@@ -535,6 +535,34 @@ class GTKPainter extends SynthPainter {
}
}
private
int
getBrightness
(
Color
c
)
{
return
Math
.
max
(
c
.
getRed
(),
Math
.
max
(
c
.
getGreen
(),
c
.
getBlue
()));
}
private
int
getMaxColorDiff
(
Color
c1
,
Color
c2
)
{
return
Math
.
max
(
Math
.
abs
(
c1
.
getRed
()
-
c2
.
getRed
()),
Math
.
max
(
Math
.
abs
(
c1
.
getGreen
()
-
c2
.
getGreen
()),
Math
.
abs
(
c1
.
getBlue
()
-
c2
.
getBlue
())));
}
private
int
scaleColorComponent
(
int
color
,
double
scaleFactor
)
{
return
(
int
)(
color
+
color
*
scaleFactor
);
}
private
Color
deriveColor
(
Color
originalColor
,
int
originalBrightness
,
int
targetBrightness
)
{
int
r
,
g
,
b
;
if
(
originalBrightness
==
0
)
{
r
=
g
=
b
=
targetBrightness
;
}
else
{
double
scaleFactor
=
(
targetBrightness
-
originalBrightness
)
/
originalBrightness
;
r
=
scaleColorComponent
(
originalColor
.
getRed
(),
scaleFactor
);
g
=
scaleColorComponent
(
originalColor
.
getGreen
(),
scaleFactor
);
b
=
scaleColorComponent
(
originalColor
.
getBlue
(),
scaleFactor
);
}
return
new
Color
(
r
,
g
,
b
);
}
//
// MENU
//
...
...
@@ -551,6 +579,57 @@ class GTKPainter extends SynthPainter {
int
gtkState
=
GTKLookAndFeel
.
synthStateToGTKState
(
context
.
getRegion
(),
context
.
getComponentState
());
if
(
gtkState
==
SynthConstants
.
MOUSE_OVER
)
{
if
(
GTKLookAndFeel
.
is3
()
&&
context
.
getRegion
()
==
Region
.
MENU
)
{
GTKStyle
style
=
(
GTKStyle
)
context
.
getStyle
();
Color
highlightColor
=
style
.
getGTKColor
(
GTKEngine
.
WidgetType
.
MENU_ITEM
.
ordinal
(),
gtkState
,
ColorType
.
BACKGROUND
.
getID
());
Color
backgroundColor
=
style
.
getGTKColor
(
GTKEngine
.
WidgetType
.
MENU_BAR
.
ordinal
(),
SynthConstants
.
ENABLED
,
ColorType
.
BACKGROUND
.
getID
());
int
minBrightness
=
0
,
maxBrightness
=
255
;
int
minBrightnessDifference
=
100
;
int
actualBrightnessDifference
=
getMaxColorDiff
(
highlightColor
,
backgroundColor
);
if
(
actualBrightnessDifference
<
minBrightnessDifference
)
{
int
highlightBrightness
=
getBrightness
(
highlightColor
);
int
backgroundBrightness
=
getBrightness
(
backgroundColor
);
int
originalHighlightBrightness
=
highlightBrightness
;
if
(
highlightBrightness
>=
backgroundBrightness
)
{
if
(
backgroundBrightness
+
minBrightnessDifference
<=
maxBrightness
)
{
highlightBrightness
=
backgroundBrightness
+
minBrightnessDifference
;
}
else
{
highlightBrightness
=
backgroundBrightness
-
minBrightnessDifference
;
}
}
else
{
if
(
backgroundBrightness
-
minBrightnessDifference
>=
minBrightness
)
{
highlightBrightness
=
backgroundBrightness
-
minBrightnessDifference
;
}
else
{
highlightBrightness
=
backgroundBrightness
+
minBrightnessDifference
;
}
}
g
.
setColor
(
deriveColor
(
highlightColor
,
originalHighlightBrightness
,
highlightBrightness
));
g
.
fillRect
(
x
,
y
,
w
,
h
);
return
;
}
}
Region
id
=
Region
.
MENU_ITEM
;
synchronized
(
UNIXToolkit
.
GTK_LOCK
)
{
if
(!
ENGINE
.
paintCachedImage
(
g
,
x
,
y
,
w
,
h
,
id
))
{
...
...
src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java
浏览文件 @
d5628847
...
...
@@ -201,6 +201,14 @@ class GTKStyle extends SynthStyle implements GTKConstants {
return
getGTKColor
(
null
,
state
,
type
);
}
Color
getGTKColor
(
int
widgetType
,
int
state
,
int
colorType
)
{
synchronized
(
sun
.
awt
.
UNIXToolkit
.
GTK_LOCK
)
{
int
rgb
=
nativeGetColorForState
(
widgetType
,
state
,
colorType
);
return
new
ColorUIResource
(
rgb
);
}
}
/**
* Returns the color for the specified state.
*
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录