Impz0r
Member
|
ComboBox draw behavior
Hey there,
I right now playing with the ComboBox around and inherited a custom class from it and overwrote the draw() method.
If I want to change the Button color this is no problemo, if I want to do the same for the Menu it does not work at all:
Code:
EE::Gui.tds_button.color = RED_LIGHT;
EE::Gui.tds_cmenu.color = RED_LIGHT;
// render orginal
EE::ComboBox::draw(gpc);
EE::Gui.tds_button.color = BLACK;
EE::Gui.tds_cmenu.color = BLACK;
The Button Text will be drawn in red, the Menu Text on the other hand does completely ignore my setting and renders in black all the time.
Am I missing something here?
Thanks in advance!
Mfg Imp
|
|
06-02-2010 03:20 AM |
|
Esenthel
Administrator
|
RE: ComboBox draw behavior
I think combobox has its own CMenu (ComboBox::cmenu)
|
|
06-02-2010 10:42 PM |
|
Impz0r
Member
|
RE: ComboBox draw behavior
Yeah it does, but I'm not quite sure how to overwrite its behavior.
I want to change the Font and Color of the comboboxes text. Do i have to inherit from the CMenu aswell and overwrite its drawing behavior ?
Thanks in advance!
Mfg Imp
|
|
06-02-2010 11:45 PM |
|
Esenthel
Administrator
|
RE: ComboBox draw behavior
combobox.cmenu.list.tds=&..
|
|
06-02-2010 11:49 PM |
|
Impz0r
Member
|
RE: ComboBox draw behavior
Thanks Esenthel!
Well I tired it, and unfortunately it does not work. This is how I'm doing things right now:
Code:
void UIComboboxEE::draw(GuiPC & gpc)
{
cmenu.list.tds->color = RED_LIGHT;
// render orginal
ComboBox::draw(gpc);
cmenu.list.tds->color = BLACK;
}
It renders the Combobox Text still black. But if I do something like:
Code:
void UIComboboxEE::draw(GuiPC & gpc)
{
Gui.tds_cmenu.color = RED_LIGHT;
// render orginal
ComboBox::draw(gpc);
}
It does render the Text in red, but only if I'm not setting the Gui.tds_cmenu.color back to Black right after ComboBox::draw(gpc); . So I'm really lost right now. I guess I'm doing something literally wrong Oo
Any thoughts?
Mfg Imp
|
|
06-03-2010 01:47 AM |
|
Esenthel
Administrator
|
RE: ComboBox draw behavior
you need to set cmenu.list.tds=&custom_tds;
|
|
06-04-2010 11:15 AM |
|
Impz0r
Member
|
RE: ComboBox draw behavior
Thanks Esenthel, unfortunately it has no effect whatsoever on the Combobox drawing.
I tried to set EE::Gui.tds_list and EE::Gui.tds_cmenu with no effect at all.
I even tried this:
Code:
cmenu.list.tds = NULL;
and it does NOT crash, it just renders as nothing had happend
Any thoughts?
Mfg Imp
|
|
06-04-2010 06:15 PM |
|
Esenthel
Administrator
|
RE: ComboBox draw behavior
you need to create custom TextDS object;
|
|
06-05-2010 09:25 AM |
|
Impz0r
Member
|
RE: ComboBox draw behavior
Well i did create a custom TextDS object and used it like this:
Code:
class MyCB : public ComboBox
{
private:
TextDS m_TextDS;
public:
MyVC() : TextDS(Gui.tds_list) { } // init with default list text definitions
void draw(GuiPC &gpc) {
cmenu.list.tds = &m_TextDS;
ComboBox::draw(gc);
}
}
But I've no success with it whatsoever. Maybe I'm doing something wrong here.. but I'm stuck. Any ideas?
Thanks in advance!
Mfg Imp
|
|
06-06-2010 12:59 PM |
|
fatcoder
Member
|
RE: ComboBox draw behavior
You're not setting up your custom tds. Sure you are creating it, but you need to set it up to draw with the color you want. Look at the GUI tutorials and see how they handle it.
|
|
06-07-2010 12:20 AM |
|
Impz0r
Member
|
RE: ComboBox draw behavior
Well the Example I posted is just that, an example. I do set the color and font within my code but I thought it would be too much to post that too but you couldn't possible know that
The problem remains and the main aspect which puzzels me most is that if i set cmenu.list.tds to NULL, nothing happens, no exception no nothing it just renders as nothing had happend.
I dont want to get on your nerves, I just want to know how to customize the drawing behavior
Maybe Esenthel you could lookup the ComboBoxes drawing routine and check which TextDS object is actually been used by it.
Thanks in advance!
Mfg Imp
|
|
06-07-2010 02:06 PM |
|
Esenthel
Administrator
|
RE: ComboBox draw behavior
I don't have codes in front of me, but if it's NULL then probably default settings are used. Gui.tds_list or something similar
|
|
06-07-2010 06:59 PM |
|
Impz0r
Member
|
RE: ComboBox draw behavior
Hey there,
I had the time to try something different and it made me think that ComboBox.cmenu.list.tds is currently not been used at all. This is what I did:
Code:
void draw(GuiPC &gpc) {
cmenu.list.tds = (TextDS*) 0xDEADBEEF;
ComboBox::draw(gc);
}
I used a wrong address on purpose to see if the program crashes or show some wired behavior while rendering the combobox, and it does not. So it appears that cmenu.list.tds is currently not being used by the ComboBox::draw() method.
PS: I tried couple other addresses and all did the same, they seemed to be ignored.
Any chance that you could take a look at the drawing routine to verify this?
Thanks in advance!
Mfg Imp
|
|
06-08-2010 09:28 PM |
|
Esenthel
Administrator
|
RE: ComboBox draw behavior
I've just tested this and it works ok
Code:
struct ComboBox2 : ComboBox
{
void draw(GuiPC &gpc)
{
static TextDS tds; tds.color=RED;
cmenu.list.tds=&tds;
__super::draw(gpc);
}
}combo;
static CChar8 *t[]=
{
"test",
"test aj",
"test ajshdkjas asjdhkqugwjeg jasda vb",
};
Bool Init()
{
Gui+=combo .create(Rect_C(0.5f,-0.6,0.3,0.06),t,ELMS(t));
|
|
06-08-2010 09:59 PM |
|
Impz0r
Member
|
RE: ComboBox draw behavior
Thanks Esenthel, that worked.
The only thing I did different was to reset the pointer after the draw call. SO i guess you batch the calls and render them later?
Thanks!
|
|
06-08-2010 10:54 PM |
|