Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7758139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:16:46+00:00 2026-06-01T13:16:46+00:00

I have a flow layout. Inside it I have about 900 tables. Each table

  • 0

I have a flow layout. Inside it I have about 900 tables. Each table is stacked one on top of the other. I have a slider which resizes them and thus causes the flow layout to resize too.

The problem is, the tables should be linearly resizing. Their base size is 200×200. So when scale = 1.0, the w and h of the tables is 200.

I resize by a fixed amount each time making them 4% bigger each time. This means I would expect them to grow by 8 pixels each time. What happens is, every few resizes, the tables grow by 9 pixels. I use doubles everywhere. I have tried rounding, floor and ceil but the problem persists. What could I do so that they always grow by the correct amount?

void LobbyTableManager::changeTableScale( double scale )
    {
        setTableScale(scale);
    }

    void LobbyTableManager::setTableScale( double scale )
    {
        scale += 0.3;
        scale *= 2.0;

        std::cout << scale << std::endl;
        agui::Gui* gotGui = getGui();
        float scrollRel = m_vScroll->getRelativeValue();
        setScale(scale);
        rescaleTables();
        resizeFlow();
    ...



    double LobbyTableManager::getTableScale() const
        {
            return (getInnerWidth() / 700.0) * getScale();
        }

    void LobbyFilterManager::valueChanged( agui::Slider* source,int val )
    {
        if(source == m_magnifySlider)
        {

            DISPATCH_LOBBY_EVENT
            {
                (*it)->changeTableScale((double)val / source->getRange());
            }
        }
    }

void LobbyTableManager::renderBG( GraphicsContext* g, agui::Rectangle& absRect, agui::Rectangle& childRect )
    {
        int cx, cy, cw, ch;
        g->getClippingRect(cx,cy,cw,ch);
        g->setClippingRect(absRect.getX(),absRect.getY(),absRect.getWidth(),absRect.getHeight());
        float scale = 0.35f;
        int w = m_bgSprite->getWidth() * getTableScale() * scale;
        int h = m_bgSprite->getHeight() * getTableScale() * scale;

        int numX = ceil(absRect.getWidth() / (float)w) + 2;
        int numY = ceil(absRect.getHeight() / (float)h) + 2;

        float offsetX = m_activeTables[0]->getLocation().getX() - w;
        float offsetY = m_activeTables[0]->getLocation().getY() - h;
        int startY = childRect.getY() + 1;
        if(moo)
        {
            std::cout << "TS: " << getTableScale() << " Scr: " << m_vScroll->getValue() << " LOC: " << childRect.getY() << " H: " << h << std::endl; 
        }
    if(moo)
    {
        std::cout << "S=" << startY << ",";
    }
        int numAttempts = 0;
        while(startY + h < absRect.getY() && numAttempts < 1000)
        {
            startY += h;
            if(moo)
            {
                std::cout << startY << ",";
            }

            numAttempts++;
        }


        if(moo)
        {
            std::cout << "\n";
            moo = false;
        }
        g->holdDrawing();
        for(int i = 0; i < numX; ++i)
        {
            for(int j = 0; j < numY; ++j)
            {
                g->drawScaledSprite(m_bgSprite,0,0,m_bgSprite->getWidth(),m_bgSprite->getHeight(),
                    absRect.getX() + (i * w) + (offsetX),absRect.getY() + (j * h) + startY,w,h,0);
            }
        }
        g->unholdDrawing();
        g->setClippingRect(cx,cy,cw,ch);
    }

        void LobbyTable::rescale( double scale )
        {
            setScale(scale);
            float os = getObjectScale();
            double x = m_baseHeight * os;
            if((int)(x + 0.5) > (int)x)
            {
                x++;
            }
            int oldH = getHeight();
            setSize(m_baseWidth * os, floor(x));
    ...

I added the related code. The slider sends a value changed which is multiplied to get a 4 percent increase (or 8 percent if slider moves 2 values etc…) then the tables are rescaled with this.

enter image description here

The first 3 are when the table size increased by 9, the 4th time it increased by 8px. But the scale factor increases by 0.04 each time.

Why is the 4th time inconsistant?

the pattern seems like 8,8,8,9,9,9,8,8,8,9,9,9…

It increases by 1 pixel more for a few and then decreases by 1 ten increases by 1 etc, thats my issue…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:16:48+00:00Added an answer on June 1, 2026 at 1:16 pm

    I still don’t see the “add 4%” code there (in a form I can understand, anyway), but from your description I think I see the problem: adding 4% twice is not adding 8%. It is adding 8.16% (1.04 * 1.04 == 1.0816). Do that a few more times and you’ll start getting 9 pixel jumps. Do it a lot more times and your jumps will get much bigger (they will be 16 pixel jumps when the size gets up to 400×400). Which, IMHO is how I like my scaling to happen.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a flow layout. Inside it I have about 900 tables. Each table
I have panel which is using flow layout. How can I make break in
I have two UILabels in a XIB file, one on top of the other,
Brief Idea about the flow : I have say minimum 1 and maximum 18
I have a flowlayout panel which has a textfield inside. Although the textfield is
So I have a bunch of JTable s. Each JTable is inside a JScrollPane
I was thinking about ways to exploit the flow layout panel control, and I
I have a panel with flow layout, and it can contain a variable number
I have a JPanel inside BorderLayout.CENTER The JPanel has a Grid Layout, and I
I have a flow layout with following two alignment issues Refer Image 1: When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.