Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly changing window title text color #940

Open
ArthurSonzogni opened this issue Oct 21, 2024 Discussed in #939 · 2 comments
Open

Properly changing window title text color #940

ArthurSonzogni opened this issue Oct 21, 2024 Discussed in #939 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@ArthurSonzogni
Copy link
Owner

Discussed in #939

Originally posted by sentientbottleofwine October 20, 2024
This might be a very simple question and I might be just missing something obvious, I tried and couldn't resolve my issue. When I try to make a window that has a title that's supposed to be colored and apply the color to the title the whole upper border of the window changes color:
20241020_17h22m27s_grim
Here's the code:

#include <ftxui/dom/elements.hpp>
#include <ftxui/screen/screen.hpp>

int main() {
    using namespace ftxui;
    auto render = window(text("Only text should be colored") | color(Color::Green), text("Contents")) | color(Color::White);
    auto screen = Screen::Create(
        Dimension::Full(),
        Dimension::Fit(render)
    );
    Render(screen, render);
    screen.Print();
}

I have no idea how to do this correctly. I greatly appreciate and thank any help.

@ArthurSonzogni
Copy link
Owner Author

Thanks!

This looks like a bug. I believe this is because the "title" is flexible by default and covers the whole line, causing the color decorator to apply to everything that is behind.

We probably want to fix this.

@ArthurSonzogni ArthurSonzogni self-assigned this Oct 22, 2024
@ArthurSonzogni ArthurSonzogni added the bug Something isn't working label Oct 22, 2024
@sentientbottleofwine
Copy link

Thanks for the response!
So I tried looking into this and from what I can see the title_box has it's x_min and x_max set to the x_min and x_max of the whole window, this creates a problem where a color decorator sets the color for all pixels in the title_box including the ones from the original border because of the previously mentioned value assigned to title_box. Just like you said! But if we try to decrease those values if an hcenter decorator has been applied. We can see that the title of the window is shifted by the amount we decreased from the center. I can't figure out how to change the color of only the title without shifting it (Also I don't know where to get the 'true' values for the title_box anyway). @ArthurSonzogni Let me know what do you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants