fix checkbox width / Height - if autosize True;
Unfortunately this is not the way to implement AutoSize correctly. You will need for CheckBox to override Control.GetPreferredSizeCore and calculate a new size that takes every possible size modifier into account, eg:
- Font
- Text
- Check glyph
- Image
- ImageTextRelation
- Border width
- Padding
var result = TextImageLayoutEngine.Layout (this);
already taking care of everything. BUT its not sending result information to control's height/Width.
so i override the checkbox.GetPreferredSize() . add layout mesuremnts there.
edit: i realized you have written GetPreferredSizeCore . if its wrong, i can move the code there. but it work inside ""GetPreferredSize"" ??
current state
https://github.com/user-attachments/assets/69d1b1bd-8e75-465f-826c-48fed0cee802
- also textalign , imagealign , glypalign ,, after these changed..
need to call trigger autosize . othwerwise . the control are may get bigger on each change of these enums.
- [edit: done]
i realized radiobutton also has the same problem
i realized you have written GetPreferredSizeCore . if its wrong, i can move the code there. but it work inside ""GetPreferredSize"" ??
Overriding Control.GetPreferredSize breaks all the AutoSize logic in there. If you override Control.GetPreferredSizeCore then you shouldn't need to call anything in the property setters like TextAlign (as long as they already have the LayoutTransaction.DoLayoutIf (AutoSize, Parent, this, PropertyNames.TextAlign) call).
i realized radiobutton also has the same problem
Yes, the Size calculate_AutosizeArea () code probably needs to go into TextImageLayoutEngine.GetPreferredSize (Control control, Size proposedSize). Then it can be called by all the Controls that use TextImageLayoutEngine like Button, Label, RadioButton, and CheckBox.
since i am a noob in this repo - baby steps for me .
i moved calculate_AutosizeArea into GetPrefferredSizeCore.
it Works same as GetPrefferredSize ..
no problem here..
then
i removed Trigger_Resizing() from the chekbox's enums (TextRealation etc)
but if i do that; on every Enum change (TextRealation etc) , Checkbox Size gets bigger bigger…
see here:
https://github.com/user-attachments/assets/77d48c31-cd8c-469e-903d-19f906856b8f
so, until real Fix is found, i ll keep triggerResizing() as Hack..
a question:
currently in calculate_AutosizeArea ;
i am using TextImageLayoutData.layout() //just like you do in the ChekboxRenderer..
but the TextImageLayoutData.layout
i do calculation believing that
info result of TextImageLayoutData.layout() is correct ??
I don't think TextImageLayoutData.Layout () is going to work for this purpose. It is designed to fit the content the best it can within a predetermined size.
You need the opposite: what is the ideal size to fit the content?
instead of x.y posititons ..
latest code uses engine.layout() . widths Heights.
now enums dont need trigger resizing.