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.

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.
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!
This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...