Login
Remember
IF Answers
Ask a Question

# With Flexible Windows, can I make the background color of one window always match another one? (Inform 7)

0 votes
78 views
asked May 24 in Authoring by bg (692 points)

Is there a way to make the background color of window X always reflect the background color of window Y, even if the color of window Y gets changed?

Using this as a starting point

    Include version 15/150128 of Flexible Windows by Jon Ingold.

    The side window is a g-window spawned by the main window.
    The position of the side window is g-placeright.
    The scale method of the side window is g-proportional.
    The measurement of the side window is 33.

    Toggling the side window is an action out of world.
    Understand "side window" as toggling the side window.

    Carry out toggling the side window:
        if the side window is g-present:
            close the side window;
        otherwise:
            open the side window.

    The border window is a graphics g-window spawned by the side window.
    The position of the border window is g-placeleft.
    The scale method of the border window is g-fixed-size.
    The measurement of the border window is 20.

    After constructing the side window:
        open the border window;

    Rule for refreshing the side window:
        say "This should be indented.[line break]So should this."

    Table of User Styles (continued)
    window (a g-window) background color (a text)
    side window "607080"

    Place is a room.

I added this, which didn't compile:

    The background color of the border window is the background color of the side window.

and when I tried this

    The background color of the border window is "[background color of the side window]".

it compiled but did not make the colors match.

related to an answer for: How do you indent text in a window using Flexible Windows by Jon Ingold? (Inform 7)

- inform7
- flexible-windows

## 1 Answer

0 votes
answered May 24 by Dannii (329 points)
selected May 26 by bg
Best answer

Your problem is that you're not really setting the background colour of the window, you're setting the background colours of all the text styles, which will result in the same thing happening, but 'the background color of the side window' will be empty. If you set the property instead then the substitution might work, but I'm not sure, I forget the rules of when substitutions get evaluated.

But I know this will work (replacing the after constructing rule in your code above):

    The background color of the side window is "607080".

    After constructing the side window:
        now the background color of the border window is the background color of the side window;
        open the border window;

commented May 25 by bg (692 points)
This specific case (wanting to change one window to reflect another) aside, is setting the property the preferred way to get the window to appear a certain color? Or is this what the background color column in the table is designed to do (though it achieves it in a different way)?
To put it another way: if you're not worried about changing the colors later, is there any special reason to do it one way or the other?
commented May 25 by Dannii (329 points)
The table is for changing the background colour of individual styles. For example you could make a single word 'ERROR' show up with a red background.
I'm not sure if there would really be any downsides to doing it your way.
commented May 26 by bg (692 points)
Oh, so like text highlighting, basically.
asked Jun 11 in Authoring by bg (692 points) How to show window background color in Quixe: background color property or text background? (Flexible Windows, Inform 7)
commented Jun 14 by Dannii (329 points)
@bg I have thought of another reason to use the background color property rather than the text styles table: the Gargoyle window padding rule will only use the property. It's also good for consistency to use the property because that's the only option available for graphics windows.
commented Jun 15 by bg (692 points)
Good to know. Thanks!

## Related questions

- With Flexible Windows by Jon Ingold, is there a way to make the text display at the top of the window, even in Gargoyle? (Inform 7)
- How to show window background color in Quixe: background color property or text background? (Flexible Windows, Inform 7)
- With Flexible Windows, can you specify whether a window will have a scroll bar? (Inform 7)
- In Flexible Windows, is it acceptable to set, e.g., the window position at or after the start of play? (Inform 7)
- How do you avoid an extra line break when refreshing a window with Flexible Windows (Inform 7)?

...