Skip to content

Commit

Permalink
Merge pull request #170 from Lootwig/gutter-icon-updates
Browse files Browse the repository at this point in the history
Gutter icon updates
  • Loading branch information
mallowigi authored Sep 13, 2024
2 parents 3221c61 + 5edbc38 commit 668a4b2
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 7 deletions.
5 changes: 5 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

## 18.0.0


### Features
- Provide "Gutter only" option for preview
- Add border to gutter icons for better contrast

## 17.0.1

### Fixes
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/mallowigi/ColorHighlighterIcons.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ object ColorHighlighterIcons {
val FOREGROUND_ICON: Icon = load("icons/highlighting/foreground.svg")
val UNDERLINE_ICON: Icon = load("icons/highlighting/underline.svg")
val INLINE_ICON: Icon = load("icons/highlighting/inline.svg")
val DISABLED_ICON: Icon = load("icons/highlighting/disabled.svg")
}

object Other {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import com.intellij.openapi.util.NlsContexts
import com.mallowigi.ColorHighlighterBundle.message
import com.mallowigi.ColorHighlighterIcons.Highlighting.BACKGROUND_ICON
import com.mallowigi.ColorHighlighterIcons.Highlighting.BORDER_ICON
import com.mallowigi.ColorHighlighterIcons.Highlighting.DISABLED_ICON
import com.mallowigi.ColorHighlighterIcons.Highlighting.FOREGROUND_ICON
import com.mallowigi.ColorHighlighterIcons.Highlighting.INLINE_ICON
import com.mallowigi.ColorHighlighterIcons.Highlighting.UNDERLINE_ICON
Expand All @@ -43,5 +44,6 @@ enum class HighlightingStyles(
BORDER(message("HighlightingStyles.border"), BORDER_ICON),
UNDERLINE(message("HighlightingStyles.underline"), UNDERLINE_ICON),
FOREGROUND(message("HighlightingStyles.foreground"), FOREGROUND_ICON),
INLINE(message("HighlightingStyles.inline"), INLINE_ICON);
INLINE(message("HighlightingStyles.inline"), INLINE_ICON),
DISABLED(message("HighlightingStyles.disabled"), DISABLED_ICON);
}
14 changes: 8 additions & 6 deletions src/main/java/com/mallowigi/gutter/GutterColorRenderer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package com.mallowigi.gutter

import com.intellij.openapi.actionSystem.*
import com.intellij.openapi.editor.colors.EditorColorsManager
import com.intellij.openapi.editor.markup.GutterIconRenderer
import com.intellij.openapi.ide.CopyPasteManager
import com.intellij.ui.ColorChooserService
Expand All @@ -43,7 +44,12 @@ import javax.swing.Icon

class GutterColorRenderer(private val color: Color?) : GutterIconRenderer() {
override fun getIcon(): Icon = when {
color != null -> JBUIScale.scaleIcon(ColorIcon(ICON_SIZE, color))
color != null -> {
EditorColorsManager.getInstance().globalScheme.defaultForeground
.let { ColorIcon(ICON_SIZE, ICON_SIZE, ICON_SIZE - 2, ICON_SIZE - 2, color, it, 3) }
.let { JBUIScale.scaleIcon(it) }
}

else -> JBUIScale.scaleIcon(EmptyIcon.create(ICON_SIZE))
}

Expand Down Expand Up @@ -81,11 +87,7 @@ class GutterColorRenderer(private val color: Color?) : GutterIconRenderer() {
val editor = e.getData(CommonDataKeys.EDITOR) ?: return
val currentColor = color ?: return
val newColor = ColorChooserService.instance.showDialog(
editor.project,
editor.component,
message("replace.color"),
currentColor,
false
editor.project, editor.component, message("replace.color"), currentColor, false
)
copyColor(currentColor, newColor)
}
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/com/mallowigi/highlighters/DisabledHighlighter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 Elior "Mallowigi" Boukhobza
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*
*/

package com.mallowigi.highlighters

import com.intellij.openapi.editor.markup.TextAttributes
import java.awt.Color

class DisabledHighlighter : Highlighter {
override fun getAttributesFlyweight(color: Color): TextAttributes {
return TextAttributes()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class HighlighterStyleFactory {
HighlightingStyles.UNDERLINE -> UnderlineHighlighter()
HighlightingStyles.FOREGROUND -> ForegroundHighlighter()
HighlightingStyles.INLINE -> InlineHighlighter()
HighlightingStyles.DISABLED -> DisabledHighlighter()
}

companion object {
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/icons/highlighting/disabled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ HighlightingStyles.border=Border
HighlightingStyles.foreground=Foreground
HighlightingStyles.inline=Inline
HighlightingStyles.underline=Underline
HighlightingStyles.disabled=Disabled (Gutter only)
no.custom.colors=No custom colors defined
notification.group.color.highlighter.notifications=Color highlighter
notification.update.content=<br/>Thank you for using the <b>Color Highlighter Plugin</b>!<br> \
Expand Down

0 comments on commit 668a4b2

Please sign in to comment.