replaceWith() method's sizeToScene property cuts top and increases bottom part of the window












0















I have 2 views: LoginScreen and MainScreen. I use replaceWith() to switch to the MainScreen. They both have the same prefHeight and prefWidth. The problem is that when I go from LoginScreen to MainScreen, the bottom part of the window snaps and gets bigger for like 30-40px.



This was my code:



loginScreen.replaceWith(mainScreen, sizeToScene = true, transition=metroAnimation)



and then I tried it with sizeToScene=false and it worked, no more snapping... however I noticed another problem, around 30-40px of MainScreen's top was gone:



sizeToScene=true with growing bottom:
enter image description here



sizeToScene=false, bottom doesn't grow but top part is eaten:
enter image description here



How can I fix it, is there something that I am doing wrong?



This is my MainScreen:



class MainScreen : View("MainScreen") {

private val toolbarLayout: ToolbarLayout by inject()

override val root = borderpane {
addClass(screen)
top = toolbarLayout.root
center = flowpane {
vgap = 20.0
hgap = 20.0
paddingAll = 20
for (i in 0..14) {
add(MobileAppGridItemLayout(i))
}
}
}


}



This is my ToolbarLayout



class ToolbarLayout : View() {
override val root = borderpane {
addClass(PanelStyle.toolbar)
paddingAll = 20

left {
hbox(20) {
label("MainView") {
addClass(PanelStyle.titleText)
textFill = Color.WHITE
}
}
}

right {
vbox {
button("Logout") {
addClass(toolbarButton)
}
}
}
}}


This is a style for default screen height and width used in both LoginScreen and MainScreen:



screen {
prefHeight = 720.px
prefWidth = 1280.px
}


Edited:
I tried replaceWith() without animation and here are the results:




  1. When sizeToScene=false, no growing bottoms and no eaten tops.

  2. When sizeToScene=true, bottom grows.










share|improve this question





























    0















    I have 2 views: LoginScreen and MainScreen. I use replaceWith() to switch to the MainScreen. They both have the same prefHeight and prefWidth. The problem is that when I go from LoginScreen to MainScreen, the bottom part of the window snaps and gets bigger for like 30-40px.



    This was my code:



    loginScreen.replaceWith(mainScreen, sizeToScene = true, transition=metroAnimation)



    and then I tried it with sizeToScene=false and it worked, no more snapping... however I noticed another problem, around 30-40px of MainScreen's top was gone:



    sizeToScene=true with growing bottom:
    enter image description here



    sizeToScene=false, bottom doesn't grow but top part is eaten:
    enter image description here



    How can I fix it, is there something that I am doing wrong?



    This is my MainScreen:



    class MainScreen : View("MainScreen") {

    private val toolbarLayout: ToolbarLayout by inject()

    override val root = borderpane {
    addClass(screen)
    top = toolbarLayout.root
    center = flowpane {
    vgap = 20.0
    hgap = 20.0
    paddingAll = 20
    for (i in 0..14) {
    add(MobileAppGridItemLayout(i))
    }
    }
    }


    }



    This is my ToolbarLayout



    class ToolbarLayout : View() {
    override val root = borderpane {
    addClass(PanelStyle.toolbar)
    paddingAll = 20

    left {
    hbox(20) {
    label("MainView") {
    addClass(PanelStyle.titleText)
    textFill = Color.WHITE
    }
    }
    }

    right {
    vbox {
    button("Logout") {
    addClass(toolbarButton)
    }
    }
    }
    }}


    This is a style for default screen height and width used in both LoginScreen and MainScreen:



    screen {
    prefHeight = 720.px
    prefWidth = 1280.px
    }


    Edited:
    I tried replaceWith() without animation and here are the results:




    1. When sizeToScene=false, no growing bottoms and no eaten tops.

    2. When sizeToScene=true, bottom grows.










    share|improve this question



























      0












      0








      0








      I have 2 views: LoginScreen and MainScreen. I use replaceWith() to switch to the MainScreen. They both have the same prefHeight and prefWidth. The problem is that when I go from LoginScreen to MainScreen, the bottom part of the window snaps and gets bigger for like 30-40px.



      This was my code:



      loginScreen.replaceWith(mainScreen, sizeToScene = true, transition=metroAnimation)



      and then I tried it with sizeToScene=false and it worked, no more snapping... however I noticed another problem, around 30-40px of MainScreen's top was gone:



      sizeToScene=true with growing bottom:
      enter image description here



      sizeToScene=false, bottom doesn't grow but top part is eaten:
      enter image description here



      How can I fix it, is there something that I am doing wrong?



      This is my MainScreen:



      class MainScreen : View("MainScreen") {

      private val toolbarLayout: ToolbarLayout by inject()

      override val root = borderpane {
      addClass(screen)
      top = toolbarLayout.root
      center = flowpane {
      vgap = 20.0
      hgap = 20.0
      paddingAll = 20
      for (i in 0..14) {
      add(MobileAppGridItemLayout(i))
      }
      }
      }


      }



      This is my ToolbarLayout



      class ToolbarLayout : View() {
      override val root = borderpane {
      addClass(PanelStyle.toolbar)
      paddingAll = 20

      left {
      hbox(20) {
      label("MainView") {
      addClass(PanelStyle.titleText)
      textFill = Color.WHITE
      }
      }
      }

      right {
      vbox {
      button("Logout") {
      addClass(toolbarButton)
      }
      }
      }
      }}


      This is a style for default screen height and width used in both LoginScreen and MainScreen:



      screen {
      prefHeight = 720.px
      prefWidth = 1280.px
      }


      Edited:
      I tried replaceWith() without animation and here are the results:




      1. When sizeToScene=false, no growing bottoms and no eaten tops.

      2. When sizeToScene=true, bottom grows.










      share|improve this question
















      I have 2 views: LoginScreen and MainScreen. I use replaceWith() to switch to the MainScreen. They both have the same prefHeight and prefWidth. The problem is that when I go from LoginScreen to MainScreen, the bottom part of the window snaps and gets bigger for like 30-40px.



      This was my code:



      loginScreen.replaceWith(mainScreen, sizeToScene = true, transition=metroAnimation)



      and then I tried it with sizeToScene=false and it worked, no more snapping... however I noticed another problem, around 30-40px of MainScreen's top was gone:



      sizeToScene=true with growing bottom:
      enter image description here



      sizeToScene=false, bottom doesn't grow but top part is eaten:
      enter image description here



      How can I fix it, is there something that I am doing wrong?



      This is my MainScreen:



      class MainScreen : View("MainScreen") {

      private val toolbarLayout: ToolbarLayout by inject()

      override val root = borderpane {
      addClass(screen)
      top = toolbarLayout.root
      center = flowpane {
      vgap = 20.0
      hgap = 20.0
      paddingAll = 20
      for (i in 0..14) {
      add(MobileAppGridItemLayout(i))
      }
      }
      }


      }



      This is my ToolbarLayout



      class ToolbarLayout : View() {
      override val root = borderpane {
      addClass(PanelStyle.toolbar)
      paddingAll = 20

      left {
      hbox(20) {
      label("MainView") {
      addClass(PanelStyle.titleText)
      textFill = Color.WHITE
      }
      }
      }

      right {
      vbox {
      button("Logout") {
      addClass(toolbarButton)
      }
      }
      }
      }}


      This is a style for default screen height and width used in both LoginScreen and MainScreen:



      screen {
      prefHeight = 720.px
      prefWidth = 1280.px
      }


      Edited:
      I tried replaceWith() without animation and here are the results:




      1. When sizeToScene=false, no growing bottoms and no eaten tops.

      2. When sizeToScene=true, bottom grows.







      tornadofx






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 19 at 20:46







      Mirmuhsin Sodiqov

















      asked Jan 19 at 18:17









      Mirmuhsin SodiqovMirmuhsin Sodiqov

      61211




      61211
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I think I found the issue, it was because items of flowpane were more than they could fit into the window. I added flawpane into the scrollpane and the problem was solved.



          override val root = borderpane {
          addClass(screen)
          top = toolbarLayout.root
          center = scrollpane {
          isFitToHeight = true
          isFitToWidth = true
          vbarPolicy = ScrollPane.ScrollBarPolicy.AS_NEEDED
          content = flowpane {
          vgap = 20.0
          hgap = 20.0
          padding = insets(20, 40, 20, 40)
          for (i in 0..15) {
          add(MobileAppGridItemLayout(i))
          }
          }
          }
          }





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54270043%2freplacewith-methods-sizetoscene-property-cuts-top-and-increases-bottom-part-o%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I think I found the issue, it was because items of flowpane were more than they could fit into the window. I added flawpane into the scrollpane and the problem was solved.



            override val root = borderpane {
            addClass(screen)
            top = toolbarLayout.root
            center = scrollpane {
            isFitToHeight = true
            isFitToWidth = true
            vbarPolicy = ScrollPane.ScrollBarPolicy.AS_NEEDED
            content = flowpane {
            vgap = 20.0
            hgap = 20.0
            padding = insets(20, 40, 20, 40)
            for (i in 0..15) {
            add(MobileAppGridItemLayout(i))
            }
            }
            }
            }





            share|improve this answer




























              0














              I think I found the issue, it was because items of flowpane were more than they could fit into the window. I added flawpane into the scrollpane and the problem was solved.



              override val root = borderpane {
              addClass(screen)
              top = toolbarLayout.root
              center = scrollpane {
              isFitToHeight = true
              isFitToWidth = true
              vbarPolicy = ScrollPane.ScrollBarPolicy.AS_NEEDED
              content = flowpane {
              vgap = 20.0
              hgap = 20.0
              padding = insets(20, 40, 20, 40)
              for (i in 0..15) {
              add(MobileAppGridItemLayout(i))
              }
              }
              }
              }





              share|improve this answer


























                0












                0








                0







                I think I found the issue, it was because items of flowpane were more than they could fit into the window. I added flawpane into the scrollpane and the problem was solved.



                override val root = borderpane {
                addClass(screen)
                top = toolbarLayout.root
                center = scrollpane {
                isFitToHeight = true
                isFitToWidth = true
                vbarPolicy = ScrollPane.ScrollBarPolicy.AS_NEEDED
                content = flowpane {
                vgap = 20.0
                hgap = 20.0
                padding = insets(20, 40, 20, 40)
                for (i in 0..15) {
                add(MobileAppGridItemLayout(i))
                }
                }
                }
                }





                share|improve this answer













                I think I found the issue, it was because items of flowpane were more than they could fit into the window. I added flawpane into the scrollpane and the problem was solved.



                override val root = borderpane {
                addClass(screen)
                top = toolbarLayout.root
                center = scrollpane {
                isFitToHeight = true
                isFitToWidth = true
                vbarPolicy = ScrollPane.ScrollBarPolicy.AS_NEEDED
                content = flowpane {
                vgap = 20.0
                hgap = 20.0
                padding = insets(20, 40, 20, 40)
                for (i in 0..15) {
                add(MobileAppGridItemLayout(i))
                }
                }
                }
                }






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 20 at 21:07









                Mirmuhsin SodiqovMirmuhsin Sodiqov

                61211




                61211






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54270043%2freplacewith-methods-sizetoscene-property-cuts-top-and-increases-bottom-part-o%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Callistus III

                    Ostreoida

                    Plistias Cous