OmegaT の背景に画像を表示します。
ステータスバーの透過・不透過の切り替えに対応
| @@ -17,6 +17,7 @@ | ||
| 17 | 17 | package jp.sourceforge.users.yutang.omegat.plugin.moenizer; |
| 18 | 18 | |
| 19 | 19 | import com.sun.java.swing.plaf.windows.WindowsMenuBarUI; |
| 20 | +import com.vlsolutions.swing.docking.AutoHideButtonPanel; | |
| 20 | 21 | import com.vlsolutions.swing.docking.DockView; |
| 21 | 22 | import com.vlsolutions.swing.docking.DockViewTitleBar; |
| 22 | 23 | import com.vlsolutions.swing.docking.Dockable; |
| @@ -36,6 +37,7 @@ | ||
| 36 | 37 | import javax.swing.JPanel; |
| 37 | 38 | import javax.swing.JScrollPane; |
| 38 | 39 | import org.omegat.core.Core; |
| 40 | +import org.omegat.util.Log; | |
| 39 | 41 | import org.omegat.util.gui.UIThreadsUtil; |
| 40 | 42 | |
| 41 | 43 | /** |
| @@ -51,6 +53,9 @@ | ||
| 51 | 53 | private Container contentPane; |
| 52 | 54 | private JMenuBar menuBar; |
| 53 | 55 | private DockingDesktop desktop; |
| 56 | + private JPanel statusBar; | |
| 57 | + private JPanel buttonPanel; | |
| 58 | + | |
| 54 | 59 | |
| 55 | 60 | private boolean makeTransparentMenubar = true; |
| 56 | 61 | private boolean makeTransparentButtonPanel = true; |
| @@ -150,7 +155,9 @@ | ||
| 150 | 155 | layeredPane = new MoeLayeredPane(); |
| 151 | 156 | contentPane = frame.getContentPane(); |
| 152 | 157 | menuBar = frame.getJMenuBar(); |
| 158 | + statusBar = getJPanel(contentPane); | |
| 153 | 159 | desktop = getDockingDesktop(contentPane); |
| 160 | + buttonPanel = getButtonPanel(desktop); | |
| 154 | 161 | |
| 155 | 162 | // replace LayeredPane with MoeLayeredPane |
| 156 | 163 | frame.setLayeredPane(layeredPane); |
| @@ -182,6 +189,16 @@ | ||
| 182 | 189 | } |
| 183 | 190 | |
| 184 | 191 | private void transparentRecursive(Component component) { |
| 192 | + // StatusBar | |
| 193 | + if (!makeTransparentStatusbar && statusBar.equals(component)) { | |
| 194 | + return; | |
| 195 | + } | |
| 196 | + | |
| 197 | + // ButtonPanel | |
| 198 | + if (!makeTransparentButtonPanel && buttonPanel.equals(component)) { | |
| 199 | + return; | |
| 200 | + } | |
| 201 | + | |
| 185 | 202 | if (component instanceof JComponent) { |
| 186 | 203 | JComponent c = (JComponent) component; |
| 187 | 204 | if (c.isOpaque()) { |
| @@ -188,7 +205,7 @@ | ||
| 188 | 205 | c.setOpaque(false); |
| 189 | 206 | } |
| 190 | 207 | } |
| 191 | - | |
| 208 | + | |
| 192 | 209 | if (component instanceof Container) { |
| 193 | 210 | Container container = (Container) component; |
| 194 | 211 | for (Component c: container.getComponents()) { |
| @@ -195,7 +212,7 @@ | ||
| 195 | 212 | transparentRecursive(c); |
| 196 | 213 | } |
| 197 | 214 | } |
| 198 | - | |
| 215 | + | |
| 199 | 216 | if (component instanceof DockingDesktop) { |
| 200 | 217 | transparentRecursive((DockingDesktop) component); |
| 201 | 218 | } |
| @@ -275,6 +292,38 @@ | ||
| 275 | 292 | return null; |
| 276 | 293 | } |
| 277 | 294 | |
| 295 | + private JPanel getJPanel(Container contentPane) { | |
| 296 | + // contentPane | |
| 297 | + // + javax.swing.JPanel // ステータスバーの実体 | |
| 298 | + // + com.vlsolutions.swing.docking.DockingDesktop // メニューバーの下からステータスバーの上までの領域 | |
| 299 | + for (Component c: contentPane.getComponents()) { | |
| 300 | + if (c instanceof JPanel) { | |
| 301 | + return (JPanel) c; | |
| 302 | + } | |
| 303 | + } | |
| 304 | + return null; | |
| 305 | + } | |
| 306 | + | |
| 307 | + private JPanel getButtonPanel(DockingDesktop desktop) { | |
| 308 | + // desktop | |
| 309 | + // + com.vlsolutions.swing.docking.AutoHideExpandPanel // 非表示 | |
| 310 | + // + com.vlsolutions.swing.docking.DockingDesktop$1 // ボタンパネルの上の領域、ボタンパネルが非表示の場合は下のパネルと同じサイズ | |
| 311 | + // + javax.swing.JPanel // ボタンパネルを含む領域 <= this | |
| 312 | + | |
| 313 | + JPanel panel = getJPanel(desktop); | |
| 314 | + // panel | |
| 315 | + // + com.vlsolutions.swing.docking.AutoHideButtonPanel // 非表示、未使用 | |
| 316 | + // + com.vlsolutions.swing.docking.AutoHideButtonPanel // 非表示、未使用 | |
| 317 | + // + com.vlsolutions.swing.docking.AutoHideButtonPanel // ボタンがあれば表示(isShowing()、isVisible() ともに true) | |
| 318 | + // + com.vlsolutions.swing.docking.AutoHideButtonPanel // 非表示、未使用 | |
| 319 | + // + com.vlsolutions.swing.docking.DockingPanel // ボタンパネルの上の領域 | |
| 320 | + | |
| 321 | + // 3番目の AutoHideButtonPanel を取得したい。 | |
| 322 | + // 状態が不明(表示/非表示で識別できるかどうか分からない)なので、 | |
| 323 | + // とりあえずインデックスで決め打ちする。 | |
| 324 | + return (JPanel) panel.getComponent(2); | |
| 325 | + } | |
| 326 | + | |
| 278 | 327 | private JEditorPane getJEditorPaneFromEditor(DockingDesktop desktop) { |
| 279 | 328 | for (DockableState d: desktop.getDockables()) { |
| 280 | 329 | Dockable dockable = d.getDockable(); |