Skip to content

Commit

Permalink
Make sure status label and toolbar drop-down don't overlap when the
Browse files Browse the repository at this point in the history
panel window is small
  • Loading branch information
eyedol committed Jul 14, 2024
1 parent 4b076c8 commit 3629669
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,11 @@ import java.awt.Image
import java.awt.event.ComponentAdapter
import java.awt.event.ComponentEvent
import java.awt.event.ComponentListener
import java.awt.event.MouseAdapter
import java.awt.event.MouseEvent
import java.io.File
import javax.imageio.ImageIO
import javax.swing.Box
import javax.swing.DefaultListModel
import javax.swing.ImageIcon
import javax.swing.JLabel
import javax.swing.JList
import javax.swing.JPanel
import javax.swing.JScrollPane
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Key
import com.intellij.ui.components.JBLabel
import com.intellij.ui.components.JBPanel
import java.awt.BorderLayout
import com.intellij.util.ui.JBUI
import java.awt.Dimension
import java.awt.GridBagConstraints
import java.awt.GridBagLayout
import javax.swing.BorderFactory
import javax.swing.Box
import javax.swing.JComponent

class StatusToolbarPanel(
project: Project,
onActionClicked: (taskName: String) -> Unit
) : JBPanel<Nothing>(BorderLayout()){
) : JBPanel<JBPanel<*>>(GridBagLayout()){
private val _statusLabel = JBLabel()
private val actionToolbar = RoborazziGradleTaskToolbar(
project = project,
Expand All @@ -48,8 +52,31 @@ class StatusToolbarPanel(

init {
actionToolbar.setTargetComponent(this)
add(_statusLabel, BorderLayout.WEST)
add(actionToolbar.component, BorderLayout.EAST)
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5))
val gbc = GridBagConstraints().apply {
gridx = 0
gridy = 0
anchor = GridBagConstraints.WEST
insets = JBUI.insets(5)
}
add(_statusLabel, gbc)
val hRGlueConstraints = gbc.apply {
gridx = 1
gridy = 0
weightx = 1.0
anchor = GridBagConstraints.CENTER
fill = GridBagConstraints.HORIZONTAL
}
// Add a horizontal glue to push the label to the left
add(Box.createHorizontalGlue(), hRGlueConstraints)

val actionToolbarConstraints = gbc.apply {
gridx = 1
gridy = 0
fill = GridBagConstraints.NONE
anchor = GridBagConstraints.EAST
}
add(actionToolbar.component, actionToolbarConstraints)
}

fun setActions(actions: List<ToolbarAction>) {
Expand Down

0 comments on commit 3629669

Please sign in to comment.