Skip to content

Commit b164288

Browse files
authored
Adjust the icon alignments (#141)
1 parent 93073ca commit b164288

File tree

8 files changed

+144
-48
lines changed

8 files changed

+144
-48
lines changed

compose-stability-analyzer-idea/src/main/kotlin/com/skydoves/compose/stability/idea/cascade/CascadePanel.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.AnAction
2222
import com.intellij.openapi.actionSystem.AnActionEvent
2323
import com.intellij.openapi.actionSystem.DefaultActionGroup
2424
import com.intellij.openapi.application.ApplicationManager
25+
import com.skydoves.compose.stability.idea.toolwindow.combineToolbars
2526
import com.intellij.openapi.editor.ScrollType
2627
import com.intellij.openapi.fileEditor.FileEditorManager
2728
import com.intellij.openapi.progress.ProgressIndicator
@@ -170,11 +171,11 @@ internal class CascadePanel(private val project: Project) {
170171
actionGroup.add(RefreshAction())
171172
actionGroup.add(ClearAction())
172173

173-
val toolbar = ActionManager.getInstance()
174+
val tabToolbar = ActionManager.getInstance()
174175
.createActionToolbar(ActionPlaces.TOOLBAR, actionGroup, true)
175-
toolbar.targetComponent = tree
176+
tabToolbar.targetComponent = tree
176177

177-
return toolbar.component
178+
return combineToolbars(tabToolbar.component, tree)
178179
}
179180

180181
private fun navigateToSource(node: CascadeNode) {

compose-stability-analyzer-idea/src/main/kotlin/com/skydoves/compose/stability/idea/heatmap/HeatmapPanel.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.AnAction
2222
import com.intellij.openapi.actionSystem.AnActionEvent
2323
import com.intellij.openapi.actionSystem.DefaultActionGroup
2424
import com.intellij.openapi.project.Project
25+
import com.skydoves.compose.stability.idea.toolwindow.combineToolbars
2526
import com.intellij.openapi.ui.SimpleToolWindowPanel
2627
import com.intellij.ui.ColoredTreeCellRenderer
2728
import com.intellij.ui.ScrollPaneFactory
@@ -160,11 +161,11 @@ internal class HeatmapPanel(private val project: Project) {
160161
actionGroup.add(RefreshAction())
161162
actionGroup.add(ClearAction())
162163

163-
val toolbar = ActionManager.getInstance()
164+
val tabToolbar = ActionManager.getInstance()
164165
.createActionToolbar(ActionPlaces.TOOLBAR, actionGroup, true)
165-
toolbar.targetComponent = tree
166+
tabToolbar.targetComponent = tree
166167

167-
return toolbar.component
168+
return combineToolbars(tabToolbar.component, tree)
168169
}
169170

170171
/**
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Designed and developed by 2025 skydoves (Jaewoong Eum)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.skydoves.compose.stability.idea.toolwindow
17+
18+
import com.intellij.icons.AllIcons
19+
import com.intellij.ide.BrowserUtil
20+
import com.intellij.openapi.actionSystem.AnAction
21+
import com.intellij.openapi.actionSystem.AnActionEvent
22+
23+
/**
24+
* Action to open the Compose Stability Analyzer GitHub repository.
25+
*/
26+
internal class GitHubAction : AnAction(
27+
"GitHub",
28+
"Open Compose Stability Analyzer on GitHub",
29+
AllIcons.Vcs.Vendors.Github,
30+
) {
31+
override fun actionPerformed(e: AnActionEvent) {
32+
BrowserUtil.browse("https://github.com/skydoves/compose-stability-analyzer")
33+
}
34+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Designed and developed by 2025 skydoves (Jaewoong Eum)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.skydoves.compose.stability.idea.toolwindow
17+
18+
import com.intellij.icons.AllIcons
19+
import com.intellij.openapi.actionSystem.AnAction
20+
import com.intellij.openapi.actionSystem.AnActionEvent
21+
import com.intellij.openapi.options.ShowSettingsUtil
22+
23+
/**
24+
* Action to open the Compose Stability Analyzer settings.
25+
*/
26+
internal class SettingsAction : AnAction(
27+
"Settings",
28+
"Open Compose Stability Analyzer settings",
29+
AllIcons.General.Settings,
30+
) {
31+
override fun actionPerformed(e: AnActionEvent) {
32+
val project = e.project ?: return
33+
ShowSettingsUtil.getInstance()
34+
.showSettingsDialog(project, "Compose Stability Analyzer")
35+
}
36+
}

compose-stability-analyzer-idea/src/main/kotlin/com/skydoves/compose/stability/idea/toolwindow/StabilityToolWindow.kt

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,11 @@ public class StabilityToolWindow(private val project: Project) {
139139
actionGroup.add(FilterAllAction())
140140
actionGroup.add(FilterSkippableAction())
141141
actionGroup.add(FilterUnskippableAction())
142-
actionGroup.addSeparator()
143-
actionGroup.add(SettingsAction())
144-
actionGroup.add(GitHubAction())
145-
val toolbar = ActionManager.getInstance()
142+
val tabToolbar = ActionManager.getInstance()
146143
.createActionToolbar(ActionPlaces.TOOLBAR, actionGroup, true)
147-
toolbar.targetComponent = tree
144+
tabToolbar.targetComponent = tree
148145

149-
return toolbar.component
146+
return combineToolbars(tabToolbar.component, tree)
150147
}
151148

152149
private fun refresh() {
@@ -544,32 +541,7 @@ public class StabilityToolWindow(private val project: Project) {
544541
}
545542
}
546543

547-
/**
548-
* Settings action
549-
*/
550-
private inner class SettingsAction : AnAction(
551-
"Settings",
552-
"Open Compose Stability Analyzer settings",
553-
AllIcons.General.Settings,
554-
) {
555-
override fun actionPerformed(e: AnActionEvent) {
556-
com.intellij.openapi.options.ShowSettingsUtil.getInstance()
557-
.showSettingsDialog(project, "Compose Stability Analyzer")
558-
}
559-
}
560544

561-
/**
562-
* GitHub link action
563-
*/
564-
private inner class GitHubAction : AnAction(
565-
"GitHub",
566-
"Open Compose Stability Analyzer on GitHub",
567-
AllIcons.Vcs.Vendors.Github,
568-
) {
569-
override fun actionPerformed(e: AnActionEvent) {
570-
com.intellij.ide.BrowserUtil.browse("https://github.com/skydoves/compose-stability-analyzer")
571-
}
572-
}
573545

574546
/**
575547
* Custom tree cell renderer with color coding

compose-stability-analyzer-idea/src/main/kotlin/com/skydoves/compose/stability/idea/toolwindow/StabilityToolWindowFactory.kt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package com.skydoves.compose.stability.idea.toolwindow
1717

18-
import com.intellij.openapi.actionSystem.ActionManager
1918
import com.intellij.openapi.project.Project
2019
import com.intellij.openapi.wm.ToolWindow
2120
import com.intellij.openapi.wm.ToolWindowFactory
@@ -61,16 +60,6 @@ public class StabilityToolWindowFactory : ToolWindowFactory {
6160
false,
6261
)
6362
toolWindow.contentManager.addContent(heatmapContent)
64-
65-
// Add toggle heatmap and clear buttons to tool window title bar
66-
val actionManager = ActionManager.getInstance()
67-
val titleActions = listOfNotNull(
68-
actionManager.getAction("com.skydoves.compose.stability.idea.heatmap.ToggleHeatmapAction"),
69-
actionManager.getAction("com.skydoves.compose.stability.idea.heatmap.ClearHeatmapDataAction"),
70-
)
71-
if (titleActions.isNotEmpty()) {
72-
toolWindow.setTitleActions(titleActions)
73-
}
7463
}
7564

7665
public override fun shouldBeAvailable(project: Project): Boolean = true
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Designed and developed by 2025 skydoves (Jaewoong Eum)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.skydoves.compose.stability.idea.toolwindow
17+
18+
import com.intellij.openapi.actionSystem.ActionManager
19+
import com.intellij.openapi.actionSystem.ActionPlaces
20+
import com.intellij.openapi.actionSystem.DefaultActionGroup
21+
import java.awt.BorderLayout
22+
import javax.swing.JComponent
23+
import javax.swing.JPanel
24+
25+
/**
26+
* Creates a shared toolbar with right-aligned global actions
27+
* (Toggle Heatmap, Clear Recomposition Data, Settings, GitHub).
28+
*/
29+
internal fun createSharedToolbar(targetComponent: JComponent): JComponent {
30+
val actionGroup = DefaultActionGroup()
31+
val actionManager = ActionManager.getInstance()
32+
actionManager.getAction("com.skydoves.compose.stability.idea.heatmap.ToggleHeatmapAction")
33+
?.let { actionGroup.add(it) }
34+
actionManager.getAction("com.skydoves.compose.stability.idea.heatmap.ClearHeatmapDataAction")
35+
?.let { actionGroup.add(it) }
36+
actionGroup.add(SettingsAction())
37+
actionGroup.add(GitHubAction())
38+
39+
val toolbar = actionManager.createActionToolbar(ActionPlaces.TOOLBAR, actionGroup, true)
40+
toolbar.targetComponent = targetComponent
41+
return toolbar.component
42+
}
43+
44+
/**
45+
* Combines a tab-specific toolbar (left) with the shared global toolbar (right).
46+
*/
47+
internal fun combineToolbars(
48+
tabToolbar: JComponent,
49+
targetComponent: JComponent,
50+
): JComponent {
51+
val sharedToolbar = createSharedToolbar(targetComponent)
52+
return JPanel(BorderLayout()).apply {
53+
isOpaque = false
54+
add(tabToolbar, BorderLayout.WEST)
55+
add(sharedToolbar, BorderLayout.EAST)
56+
}
57+
}

compose-stability-analyzer-idea/src/main/resources/META-INF/plugin.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,11 @@
144144
description="Clear all accumulated recomposition heatmap data">
145145
<add-to-group group-id="CodeMenu" anchor="last"/>
146146
</action>
147+
148+
<action
149+
id="com.skydoves.compose.stability.idea.toolwindow.GitHubAction"
150+
class="com.skydoves.compose.stability.idea.toolwindow.GitHubAction"
151+
text="GitHub"
152+
description="Open Compose Stability Analyzer on GitHub"/>
147153
</actions>
148154
</idea-plugin>

0 commit comments

Comments
 (0)