Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
keyescgm
jadx
提交
9a67b199
J
jadx
项目概览
keyescgm
/
jadx
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jadx
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
9a67b199
编写于
3月 11, 2022
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(gui): add zoom in/out actions (#1403)
上级
95c75bed
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
107 addition
and
0 deletion
+107
-0
jadx-gui/src/main/java/jadx/gui/ui/codearea/AbstractCodeArea.java
.../src/main/java/jadx/gui/ui/codearea/AbstractCodeArea.java
+3
-0
jadx-gui/src/main/java/jadx/gui/ui/panel/HtmlPanel.java
jadx-gui/src/main/java/jadx/gui/ui/panel/HtmlPanel.java
+3
-0
jadx-gui/src/main/java/jadx/gui/utils/FontUtils.java
jadx-gui/src/main/java/jadx/gui/utils/FontUtils.java
+3
-0
jadx-gui/src/main/java/jadx/gui/utils/ui/ActionHandler.java
jadx-gui/src/main/java/jadx/gui/utils/ui/ActionHandler.java
+20
-0
jadx-gui/src/main/java/jadx/gui/utils/ui/ZoomActions.java
jadx-gui/src/main/java/jadx/gui/utils/ui/ZoomActions.java
+78
-0
未找到文件。
jadx-gui/src/main/java/jadx/gui/ui/codearea/AbstractCodeArea.java
浏览文件 @
9a67b199
...
...
@@ -40,6 +40,7 @@ import jadx.gui.utils.DefaultPopupMenuListener;
import
jadx.gui.utils.JumpPosition
;
import
jadx.gui.utils.NLS
;
import
jadx.gui.utils.UiUtils
;
import
jadx.gui.utils.ui.ZoomActions
;
public
abstract
class
AbstractCodeArea
extends
RSyntaxTextArea
{
private
static
final
long
serialVersionUID
=
-
3980354865216031972L
;
...
...
@@ -67,6 +68,8 @@ public abstract class AbstractCodeArea extends RSyntaxTextArea {
addCaretActions
();
addFastCopyAction
();
ZoomActions
.
register
(
this
,
settings
,
this
::
loadSettings
);
}
private
void
addWrapLineMenuAction
(
JadxSettings
settings
)
{
...
...
jadx-gui/src/main/java/jadx/gui/ui/panel/HtmlPanel.java
浏览文件 @
9a67b199
...
...
@@ -11,6 +11,7 @@ import javax.swing.JScrollPane;
import
jadx.gui.settings.JadxSettings
;
import
jadx.gui.treemodel.JNode
;
import
jadx.gui.ui.TabbedPane
;
import
jadx.gui.utils.ui.ZoomActions
;
public
final
class
HtmlPanel
extends
ContentPanel
{
private
static
final
long
serialVersionUID
=
-
6251262855835426245L
;
...
...
@@ -27,6 +28,8 @@ public final class HtmlPanel extends ContentPanel {
textArea
.
setEditable
(
false
);
JScrollPane
sp
=
new
JScrollPane
(
textArea
);
add
(
sp
);
ZoomActions
.
register
(
textArea
,
panel
.
getMainWindow
().
getSettings
(),
this
::
loadSettings
);
}
@Override
...
...
jadx-gui/src/main/java/jadx/gui/utils/FontUtils.java
浏览文件 @
9a67b199
...
...
@@ -42,6 +42,9 @@ public class FontUtils {
}
public
static
String
convertToStr
(
Font
font
)
{
if
(
font
.
getSize
()
<
1
)
{
throw
new
JadxRuntimeException
(
"Bad font size: "
+
font
.
getSize
());
}
return
font
.
getFontName
()
+
'/'
+
convertFontStyleToString
(
font
.
getStyle
())
+
'/'
+
font
.
getSize
();
...
...
jadx-gui/src/main/java/jadx/gui/utils/ui/ActionHandler.java
0 → 100644
浏览文件 @
9a67b199
package
jadx.gui.utils.ui
;
import
java.awt.event.ActionEvent
;
import
java.util.function.Consumer
;
import
javax.swing.AbstractAction
;
public
class
ActionHandler
extends
AbstractAction
{
private
final
Consumer
<
ActionEvent
>
consumer
;
public
ActionHandler
(
Consumer
<
ActionEvent
>
consumer
)
{
this
.
consumer
=
consumer
;
}
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
consumer
.
accept
(
e
);
}
}
jadx-gui/src/main/java/jadx/gui/utils/ui/ZoomActions.java
0 → 100644
浏览文件 @
9a67b199
package
jadx.gui.utils.ui
;
import
java.awt.Container
;
import
java.awt.Font
;
import
java.awt.event.KeyEvent
;
import
javax.swing.ActionMap
;
import
javax.swing.InputMap
;
import
javax.swing.JComponent
;
import
javax.swing.KeyStroke
;
import
jadx.gui.settings.JadxSettings
;
import
jadx.gui.utils.UiUtils
;
public
class
ZoomActions
{
private
final
JComponent
component
;
private
final
JadxSettings
settings
;
private
final
Runnable
update
;
public
static
void
register
(
JComponent
component
,
JadxSettings
settings
,
Runnable
update
)
{
ZoomActions
actions
=
new
ZoomActions
(
component
,
settings
,
update
);
actions
.
register
();
}
private
ZoomActions
(
JComponent
component
,
JadxSettings
settings
,
Runnable
update
)
{
this
.
component
=
component
;
this
.
settings
=
settings
;
this
.
update
=
update
;
}
private
void
register
()
{
String
zoomIn
=
"TextZoomIn"
;
String
zoomOut
=
"TextZoomOut"
;
int
ctrlButton
=
UiUtils
.
ctrlButton
();
InputMap
inputMap
=
component
.
getInputMap
();
inputMap
.
put
(
KeyStroke
.
getKeyStroke
(
KeyEvent
.
VK_PLUS
,
ctrlButton
),
zoomIn
);
inputMap
.
put
(
KeyStroke
.
getKeyStroke
(
KeyEvent
.
VK_EQUALS
,
ctrlButton
),
zoomIn
);
inputMap
.
put
(
KeyStroke
.
getKeyStroke
(
KeyEvent
.
VK_ADD
,
ctrlButton
),
zoomIn
);
inputMap
.
put
(
KeyStroke
.
getKeyStroke
(
KeyEvent
.
VK_MINUS
,
ctrlButton
),
zoomOut
);
inputMap
.
put
(
KeyStroke
.
getKeyStroke
(
KeyEvent
.
VK_SUBTRACT
,
ctrlButton
),
zoomOut
);
ActionMap
actionMap
=
component
.
getActionMap
();
actionMap
.
put
(
zoomIn
,
new
ActionHandler
(
e
->
textZoom
(
1
)));
actionMap
.
put
(
zoomOut
,
new
ActionHandler
(
e
->
textZoom
(-
1
)));
component
.
addMouseWheelListener
(
e
->
{
if
(
e
.
getModifiersEx
()
==
UiUtils
.
ctrlButton
())
{
textZoom
(
e
.
getWheelRotation
()
<
0
?
1
:
-
1
);
e
.
consume
();
}
else
{
// pass event to parent component, needed for scroll in JScrollPane
Container
parent
=
component
.
getParent
();
if
(
parent
!=
null
)
{
parent
.
dispatchEvent
(
e
);
}
}
});
}
private
void
textZoom
(
int
change
)
{
Font
font
=
settings
.
getFont
();
if
(
component
.
getFont
().
equals
(
font
))
{
settings
.
setFont
(
changeFontSize
(
font
,
change
));
}
else
{
settings
.
setSmaliFont
(
changeFontSize
(
settings
.
getSmaliFont
(),
change
));
}
settings
.
sync
();
update
.
run
();
}
private
Font
changeFontSize
(
Font
font
,
int
change
)
{
float
newSize
=
font
.
getSize
()
+
change
;
if
(
newSize
<
2
)
{
// ignore change
return
font
;
}
return
font
.
deriveFont
(
newSize
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录