sfml-widgets icon indicating copy to clipboard operation
sfml-widgets copied to clipboard

glScissors cropping text when Theme values are changed

Open SwiTool opened this issue 4 years ago • 0 comments

I am on OSX and I created a view of 3840x2160, in a window of 1920x1080.

All the values in my view must be huge so they appear on smaller screens.

Here are the values I entered in Theme.cpp :

size_t    Theme::textSize = 54;
int       Theme::borderSize      = 10.f;
int       Theme::minWidgetWidth  = 800;
float     Theme::PADDING          = 10.f;
float     Theme::MARGIN           = 30.f;

Visually, it looks nice : image

The code looks like this :

    gui::Menu menu(*win);
    gui::HBoxLayout* hbox = menu.addHBoxLayout();
    gui::FormLayout* form = hbox->addFormLayout();
    gui::TextBox *tb = new gui::TextBox(500);
    tb->setText("SwiTool");
    form->addRow("Pseudo", tb);

The problem is that I must comment the glScissors part, or I can't see what's in the textbox :

// in TextBox.cpp
    glScissor(pos.x + Theme::borderSize, target.getSize().y - (pos.y + getSize().y), getSize().x, getSize().y);

image

Then I added a debug RectangleShape to see where it actually crops. Here is the code for the rectangle :

    sf::RectangleShape rect(sf::Vector2f(getSize().x, getSize().y));
    rect.setPosition(sf::Vector2f(pos.x + Theme::borderSize, target.getSize().y - (pos.y + getSize().y)));
    rect.setFillColor(sf::Color::Transparent);
    rect.setOutlineThickness(5);
    rect.setOutlineColor(sf::Color::Red);
    target.draw(rect);

And this is the result :

image

I tried to play with the scissors value, but can't get it to work properly... Any thoughts ?

SwiTool avatar Mar 05 '21 16:03 SwiTool