-
December 28th, 2019, 05:03 #1
Trying to fill only PART of a frame with a background color.
I can fill a WHOLE frame with a backcolor value, but I'm looking to fill only a name label with a color, and later add a stringfield control next to it, and I can't get it to display the color. Does backcolor only apply directly to frames, so that I have to make a new framedef? I'm trying to avoid making a bitmap image just for a single color.
Code:<template name="frame_char"> <genericcontrol> <!-- <frame name="groupbox" /> --> <frame name="charsheetbox" /> </genericcontrol> </template> <!-- This is a new template for single-line string entries. --> <template name="kult_string_entry_singleline"> <frame_char> <genericcontrol> <!-- <anchored to="kult_string_entry_singleline" position="insidetopleft" offset="0,0" height="5" /> --> <!-- <bounds>0,0,-1,-1</bounds> --> <backcolor>#999999</backcolor> <!-- This color doesn't show up. --> </genericcontrol> <!-- <backcolor>#999999</backcolor> --><!-- This line works, but it's for the entire frame. --> </frame_char> </template>
-
December 28th, 2019, 06:42 #2
Add a frame to the window control. See the frame definition in the Wiki developer guide here: https://www.fantasygrounds.com/refdoc/windowcontrol.xcp
See various examples in the CoreRPG templates. You don’t have to have a new bitmap image, just use one of the existing frame definitions.
Or try it with a control that has definite dimensions.
And, if you’re using a string field control then use that, not a genericcontrol.Last edited by Trenloe; December 28th, 2019 at 06:51.
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
December 28th, 2019, 07:33 #3
The stringfield control isn't even implemented yet. This code is supposed to be for the gray label to the left of it:
_________________________________
||||||LABEL|||||| String content |
""""""""""""""""""""""""""""""""""""""""""""""
I tried to follow your directions - at least what I imagined them to be - and the colors still aren't showing up.
I don't know what you mean by "definite dimensions". I tried putting in "bounds", "width" and "height" a little here and there, with values ranging from matching the absolute position on the page, to the position within the frame, but nothing is showing up.
Code:<template name="kult_string_entry_singleline"> <frame_char> <genericcontrol> <frame name="charsheetbox"> <bounds>0,0,30,10</bounds> <backcolor>#999999</backcolor> </frame> </genericcontrol> <!-- <backcolor>#333333</backcolor> --><!-- This line works. --> </frame_char> </template>
-
December 28th, 2019, 07:40 #4
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,562
The backcolor tag is separate from frame tag. The background color will be drawn first, and then the frame drawn on top, then the contents of the control.
Regards,
JPG
-
December 28th, 2019, 08:00 #5
So how do I draw a frame bitmap, and then, within that bitmap, on top of it, draw a smaller box filled with a single color? Are ALL background colors drawn first, before ALL the bitmaps, regardless of where they are? Do I have to make a png image just to fill a box with a single color?
-
December 28th, 2019, 08:10 #6
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,562
You have to layer controls to do something like that.
Regards,
JPG
-
December 28th, 2019, 09:04 #7
Yes, I'm trying to layer the controls. Aren't I doing that in the code I posted? I tried nesting some more controls in, but it displayed nothing but the original charsheetbox bitmap:
Code:<template name="frame_char"> <genericcontrol> <!-- <frame name="groupbox" /> --> <frame name="charsheetbox" /> </genericcontrol> </template> <!-- This is a new template for single-line string entries. --> <template name="kult_string_entry_singleline"> <frame_char> <genericcontrol> <bounds>59,68,-244,15</bounds> <frame name="groupbox"> <genericcontrol> <bounds>59,68,-254,15</bounds> <frame name="groupbox"> <bounds>0,0,30,10</bounds> <backcolor>#999999</backcolor> </frame> </genericcontrol> </frame> </genericcontrol> <!-- <backcolor>#333333</backcolor> --><!-- This line works. --> </frame_char> </template>
-
December 28th, 2019, 09:19 #8
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,562
Control definitions can't be nested. Each control must be defined separately. By layering, I mean that the controls are defined in a way such that they overlay the same layout space in the window class definition. In that way, the control defined first will be drawn first (i.e. on the bottom), the control defined next will be drawn on top of that one, and so on.
Regards,
JPG
-
December 28th, 2019, 09:40 #9
Oh, so templates cannot define more than one control?
...despite "addTextWidget()" being able to add and position text to a template?
...and so all the anchoring needs to be done outside templates?
I got anchoring outside templates to work, but figured that it was so much repetitive code to write.
-
December 28th, 2019, 15:56 #10
No, that can't be true, because there's createControl(). Can't you nest controls with that, just like with addWidget()?
It would be neat if I could just have a single template, that created a frame, and then resolved a label and a stringfield from two arguments (using code, I guess). This is, of course, provided that you can create a control at init-time, that would be as long as the label within it, and would allow the stringfield to be posted just after it. This seems to be doable with things like this:
Code:local w,h = labelwidget.getSize(); labelwidget.setPosition("bottomleft", w/2, h/2-4);
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks