Skip to content

Commit 67a7d27

Browse files
committed
fix icons and zoom level
1 parent 5414bb7 commit 67a7d27

6 files changed

Lines changed: 59 additions & 18 deletions

File tree

jetbrains_plugin/src/main/kotlin/com/roocode/jetbrains/extensions/plugin/zoo/ZooCodeButtonProvider.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@ class ZooCodeButtonProvider : ExtensionButtonProvider {
3434

3535
override fun getButtons(project: Project): List<AnAction> {
3636
// Note: project parameter kept for future extensibility
37-
// Order matches VS Code: New Task, Marketplace, Settings, Cloud (visible)
37+
// Order matches VS Code: New Task, Marketplace, Settings (visible)
3838
// History, Prompts, MCP, Open in Editor (overflow menu)
3939
return listOf(
4040
PlusButtonClickAction(),
4141
MarketplaceButtonClickAction(),
4242
SettingsButtonClickAction(),
43-
CloudButtonClickAction(),
4443
HistoryButtonClickAction(),
4544
PromptsButtonClickAction(),
4645
MCPButtonClickAction(),
@@ -49,12 +48,11 @@ class ZooCodeButtonProvider : ExtensionButtonProvider {
4948
}
5049

5150
override fun getVisibleButtons(project: Project): List<AnAction> {
52-
// First 4 buttons are directly visible in the toolbar
51+
// These buttons are directly visible in the toolbar
5352
return listOf(
5453
PlusButtonClickAction(),
5554
MarketplaceButtonClickAction(),
56-
SettingsButtonClickAction(),
57-
CloudButtonClickAction()
55+
SettingsButtonClickAction()
5856
)
5957
}
6058

@@ -74,7 +72,7 @@ class ZooCodeButtonProvider : ExtensionButtonProvider {
7472

7573
/**
7674
* Zoo Code button configuration - shows buttons matching VS Code layout.
77-
* Directly visible: New Task, Marketplace, Settings, Cloud
75+
* Directly visible: New Task, Marketplace, Settings
7876
* In overflow menu: History, Prompts, MCP Servers, Open in Editor
7977
*/
8078
private class ZooCodeButtonConfiguration : ButtonConfiguration {
@@ -89,7 +87,6 @@ class ZooCodeButtonProvider : ExtensionButtonProvider {
8987
ButtonType.PLUS, // New Task
9088
ButtonType.MARKETPLACE, // Marketplace
9189
ButtonType.SETTINGS, // Settings
92-
ButtonType.CLOUD, // Cloud
9390
ButtonType.HISTORY, // History (overflow)
9491
ButtonType.PROMPTS, // Prompts (overflow)
9592
ButtonType.MCP, // MCP Servers (overflow)

jetbrains_plugin/src/main/kotlin/com/roocode/jetbrains/extensions/ui/actions/DynamicExtensionActionsGroup.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ class DynamicExtensionActionsGroup : DefaultActionGroup(), DumbAware, ActionUpda
105105
}
106106

107107
/**
108-
* Creates an overflow menu (three dots) containing additional actions
108+
* Creates an overflow menu containing additional actions.
109109
*/
110110
private fun createOverflowMenu(): AnAction {
111111
return object : DefaultActionGroup("More Actions", true), DumbAware {
112112
init {
113-
templatePresentation.icon = AllIcons.Actions.More
113+
templatePresentation.icon = AllIcons.Actions.ListFiles
114114
templatePresentation.text = "" // No text, just icon
115115
templatePresentation.description = "More actions"
116116

jetbrains_plugin/src/main/kotlin/com/roocode/jetbrains/webview/WebViewManager.kt

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ import org.cef.browser.CefFrame
3232
import org.cef.handler.*
3333
import org.cef.misc.BoolRef
3434
import org.cef.network.CefRequest
35+
import java.awt.KeyboardFocusManager
36+
import java.awt.event.KeyEvent
3537
import java.io.IOException
3638
import java.nio.charset.StandardCharsets
3739
import java.nio.file.Files
3840
import java.nio.file.Path
3941
import java.nio.file.Paths
4042
import java.util.*
43+
import javax.swing.SwingUtilities
4144
import kotlin.io.path.createDirectories
4245
import kotlin.io.path.exists
4346
import kotlin.io.path.pathString
@@ -464,6 +467,12 @@ class WebViewInstance(
464467

465468
// JCEF browser instance
466469
val browser = JBCefBrowser.createBuilder().setOffScreenRendering(true).build()
470+
471+
private var zoomLevel = DEFAULT_ZOOM_LEVEL
472+
473+
private val zoomKeyEventDispatcher = java.awt.KeyEventDispatcher { event ->
474+
handleZoomKeyEvent(event)
475+
}
467476

468477
// WebView state
469478
private var isDisposed = false
@@ -486,10 +495,41 @@ class WebViewInstance(
486495

487496
init {
488497
setupJSBridge()
498+
setupZoomShortcuts()
489499
// Enable resource loading interception
490500
enableResourceInterception(extension)
491501
}
492502

503+
private fun setupZoomShortcuts() {
504+
KeyboardFocusManager.getCurrentKeyboardFocusManager()
505+
.addKeyEventDispatcher(zoomKeyEventDispatcher)
506+
}
507+
508+
private fun handleZoomKeyEvent(event: KeyEvent): Boolean {
509+
if (isDisposed || event.id != KeyEvent.KEY_PRESSED || (!event.isMetaDown && !event.isControlDown)) {
510+
return false
511+
}
512+
513+
val focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().focusOwner
514+
if (focusOwner == null ||
515+
(focusOwner !== browser.component && !SwingUtilities.isDescendingFrom(focusOwner, browser.component))
516+
) {
517+
return false
518+
}
519+
520+
val newZoomLevel = when (event.keyCode) {
521+
KeyEvent.VK_EQUALS, KeyEvent.VK_ADD -> (zoomLevel + ZOOM_STEP).coerceAtMost(MAX_ZOOM_LEVEL)
522+
KeyEvent.VK_MINUS, KeyEvent.VK_SUBTRACT -> (zoomLevel - ZOOM_STEP).coerceAtLeast(MIN_ZOOM_LEVEL)
523+
KeyEvent.VK_0, KeyEvent.VK_NUMPAD0 -> DEFAULT_ZOOM_LEVEL
524+
else -> return false
525+
}
526+
527+
zoomLevel = newZoomLevel
528+
browser.cefBrowser.zoomLevel = zoomLevel
529+
event.consume()
530+
return true
531+
}
532+
493533
/**
494534
* Send theme config to the specified WebView instance
495535
*/
@@ -929,9 +969,18 @@ class WebViewInstance(
929969

930970
override fun dispose() {
931971
if (!isDisposed) {
972+
KeyboardFocusManager.getCurrentKeyboardFocusManager()
973+
.removeKeyEventDispatcher(zoomKeyEventDispatcher)
932974
browser.dispose()
933975
isDisposed = true
934976
logger.info("WebView instance released: $viewType/$viewId")
935977
}
936978
}
937-
}
979+
980+
private companion object {
981+
const val DEFAULT_ZOOM_LEVEL = 0.0
982+
const val ZOOM_STEP = 1.0
983+
const val MIN_ZOOM_LEVEL = -5.0
984+
const val MAX_ZOOM_LEVEL = 5.0
985+
}
986+
}

jetbrains_plugin/src/main/resources/META-INF/pluginIcon.svg

Lines changed: 1 addition & 3 deletions
Loading

jetbrains_plugin/src/main/resources/META-INF/pluginIcon_dark.svg

Lines changed: 1 addition & 3 deletions
Loading

jetbrains_plugin/src/main/resources/icons/zoo-logo.svg

Lines changed: 1 addition & 2 deletions
Loading

0 commit comments

Comments
 (0)