diff options
author | syeyoung <cyong06@naver.com> | 2021-07-25 20:37:22 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-07-25 20:37:22 +0900 |
commit | a6b8e47c879ce5a1c69d0552cdb26a3b3e95e4b6 (patch) | |
tree | 2eab5dc84e6dcaf426ef100d7dfd0a2f0dd93771 /src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollablePanel.java | |
parent | a7b6db18ec1471ba604df91652741a04bc436fa2 (diff) | |
download | Skyblock-Dungeons-Guide-a6b8e47c879ce5a1c69d0552cdb26a3b3e95e4b6.tar.gz Skyblock-Dungeons-Guide-a6b8e47c879ce5a1c69d0552cdb26a3b3e95e4b6.tar.bz2 Skyblock-Dungeons-Guide-a6b8e47c879ce5a1c69d0552cdb26a3b3e95e4b6.zip |
new config.
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollablePanel.java')
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollablePanel.java | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollablePanel.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollablePanel.java index bdbf51d0..42a3cb91 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollablePanel.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollablePanel.java @@ -40,8 +40,6 @@ public class MScrollablePanel extends MPanel { private final int axis; // 1: Y 2: X 3: both. - private Dimension totalContentArea = new Dimension(); - private MPanel viewPort; @Getter private MPanel contentArea; @@ -135,23 +133,28 @@ public class MScrollablePanel extends MPanel { @Override public void setBounds(Rectangle bounds) { super.setBounds(bounds); - boolean hideX = false, hideY = false; - if (bounds.width > contentAreaDim.width && hideScrollBarWhenNotNecessary) hideX = true; - if (bounds.height > contentAreaDim.height && hideScrollBarWhenNotNecessary) hideY = true; + boolean hideX = (axis & 2) == 0, hideY = (axis & 1) == 0; + viewPort.setBounds(new Rectangle(0,0,bounds.width, bounds.height)); + evalulateContentArea(); + if (bounds.width >= contentAreaDim.width && hideScrollBarWhenNotNecessary) hideX = true; + if (bounds.height >= contentAreaDim.height && hideScrollBarWhenNotNecessary) hideY = true; - if (axis == 3 && !(hideX || hideY)) { + if (!(hideX || hideY)) { Dimension preferedX = scrollBarX.getPreferredSize(); Dimension preferedY = scrollBarY.getPreferredSize(); scrollBarY.setBounds(new Rectangle(bounds.width - preferedY.width, 0, preferedY.width, bounds.height - preferedX.height)); scrollBarX.setBounds(new Rectangle(0, bounds.height - preferedX.height, bounds.width - preferedY.width, preferedX.height)); - } else if (axis == 2 || (axis == 3 && hideY)) { + } else if ((hideY && !hideX)) { Dimension preferedX = scrollBarX.getPreferredSize(); scrollBarY.setBounds(new Rectangle(0,0,0,0)); scrollBarX.setBounds(new Rectangle(0, bounds.height - preferedX.height, bounds.width, preferedX.height)); - } else if (axis == 1 || (axis == 3 && hideX)) { + } else if ((hideX && !hideY)) { Dimension preferedY = scrollBarY.getPreferredSize(); scrollBarX.setBounds(new Rectangle(0,0,0,0)); scrollBarY.setBounds(new Rectangle(bounds.width - preferedY.width, 0, preferedY.width, bounds.height)); + } else if (hideX && hideY){ + scrollBarY.setBounds(new Rectangle(0,0,0,0)); + scrollBarX.setBounds(new Rectangle(0,0,0,0)); } viewPort.setBounds(new Rectangle(0,0,bounds.width-scrollBarY.getBounds().width, bounds.height - scrollBarX.getBounds().height)); |