mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[IFT] Make minimum Learn toolwindow size as 460
Also remove some magic from size lesson message pane calculation GitOrigin-RevId: dd57bf23178caf1061b13b9c0e743834e06225b0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5392a7de95
commit
2af8b2e670
@@ -14,7 +14,7 @@ import javax.swing.border.EmptyBorder
|
||||
internal class UISettings {
|
||||
|
||||
//GENERAL UI SETTINGS
|
||||
val width: Int by lazy { JBUI.scale(500) }
|
||||
val panelWidth: Int by lazy { JBUI.scale(460) }
|
||||
|
||||
//MAIN INSETS
|
||||
val northInset: Int by lazy { JBUI.scale(20) }
|
||||
|
||||
@@ -76,7 +76,7 @@ internal class LearnPanel(val learnToolWindow: LearnToolWindow) : JPanel() {
|
||||
add(footer, BorderLayout.PAGE_END)
|
||||
}
|
||||
|
||||
preferredSize = Dimension(UISettings.instance.width, 100)
|
||||
preferredSize = Dimension(UISettings.instance.panelWidth, 100)
|
||||
with(UISettings.instance) {
|
||||
border = EmptyBorder(northInset, JBUI.scale(18), southInset, JBUI.scale(18))
|
||||
}
|
||||
@@ -136,7 +136,10 @@ internal class LearnPanel(val learnToolWindow: LearnToolWindow) : JPanel() {
|
||||
lessonMessagePane.alignmentX = Component.LEFT_ALIGNMENT
|
||||
lessonMessagePane.margin = JBUI.emptyInsets()
|
||||
lessonMessagePane.border = EmptyBorder(0, 0, JBUI.scale(20), JBUI.scale(14))
|
||||
lessonMessagePane.maximumSize = Dimension(UISettings.instance.width, 10000)
|
||||
|
||||
preferredSize = Dimension(UISettings.instance.panelWidth, preferredSize.height)
|
||||
|
||||
revalidate()
|
||||
|
||||
//Set Next Button UI
|
||||
listOf(nextButton, prevButton).forEach {
|
||||
@@ -244,16 +247,9 @@ internal class LearnPanel(val learnToolWindow: LearnToolWindow) : JPanel() {
|
||||
}
|
||||
}
|
||||
|
||||
/** This important magic method is needed for [getPreferredSize]: it calculates the `lessonPanel.minimumSize` */
|
||||
private fun adjustMessagesArea() {
|
||||
//invoke #getPreferredSize explicitly to update actual size of LessonMessagePane
|
||||
lessonMessagePane.preferredSize
|
||||
|
||||
//Pack lesson panel
|
||||
lessonPanel.repaint()
|
||||
//run to update LessonMessagePane.getMinimumSize and LessonMessagePane.getPreferredSize
|
||||
lessonPanelBoxLayout.invalidateLayout(lessonPanel)
|
||||
lessonPanelBoxLayout.layoutContainer(lessonPanel)
|
||||
revalidate()
|
||||
repaint()
|
||||
}
|
||||
|
||||
fun resetMessagesNumber(number: Int) {
|
||||
@@ -323,13 +319,6 @@ internal class LearnPanel(val learnToolWindow: LearnToolWindow) : JPanel() {
|
||||
@NlsSafe
|
||||
private fun getNextLessonKeyStrokeText() = "Enter"
|
||||
|
||||
/** It is a magic implementation and need to invoke [adjustMessagesArea] before the use of this method (from Swing library code) */
|
||||
override fun getPreferredSize(): Dimension {
|
||||
if (lessonPanel.minimumSize == null) return Dimension(10, 10)
|
||||
return Dimension(lessonPanel.minimumSize.getWidth().toInt() + UISettings.instance.westInset + UISettings.instance.eastInset,
|
||||
lessonPanel.minimumSize.getHeight().toInt() + footer.minimumSize.getHeight().toInt() + UISettings.instance.northInset + UISettings.instance.southInset)
|
||||
}
|
||||
|
||||
fun makeNextButtonSelected() {
|
||||
rootPane?.defaultButton = nextButton
|
||||
nextButton.isSelected = true
|
||||
|
||||
@@ -31,6 +31,8 @@ class ModulesPanel(project: Project) : JPanel() {
|
||||
initModulesPanel()
|
||||
|
||||
revalidate()
|
||||
|
||||
preferredSize = Dimension(UISettings.instance.panelWidth, preferredSize.height)
|
||||
repaint()
|
||||
}
|
||||
|
||||
@@ -105,11 +107,6 @@ class ModulesPanel(project: Project) : JPanel() {
|
||||
add(shiftedFooter)
|
||||
}
|
||||
|
||||
override fun getPreferredSize(): Dimension {
|
||||
return Dimension(modulesPanel.minimumSize.getWidth().toInt() + UISettings.instance.westInset + UISettings.instance.eastInset,
|
||||
super.getPreferredSize().height)
|
||||
}
|
||||
|
||||
fun updateMainPanel() {
|
||||
modulesPanel.removeAll()
|
||||
initModulesPanel()
|
||||
|
||||
Reference in New Issue
Block a user