Don't implicitly call recalcRect()

This commit is contained in:
2025-03-14 14:33:09 -05:00
committed by Celtic Minstrel
parent ea8dbbc06c
commit 16703ae7a2
3 changed files with 6 additions and 5 deletions

View File

@@ -39,7 +39,8 @@ std::string cControl::generateRandomString() {
void cControl::setText(std::string l){
lbl = l;
recalcRect();
// TODO: calling recalcRect() here has major unwanted side effects
// recalcRect();
}
std::string cControl::getText() const {

View File

@@ -373,15 +373,14 @@ public:
if(anchor_id) *anchor_id = anchor;
return {horz, vert};
}
/// If the control automatically determines its rect based on certain criteria, override this.
/// It will automatically be called during parsing.
virtual void recalcRect() {}
protected:
/// Create a new control attached to a dialog.
/// @param t The type of the control.
/// @param p The parent container.
cControl(eControlType t, iComponent* p);
/// If the control automatically determines its rect based on certain criteria, override this.
/// It will automatically be called during parsing.
/// When overridden, it should normally be public.
virtual void recalcRect() {}
/// Returns a list of event handlers that this control supports.
/// @return The list of handlers as a std::set.
///

View File

@@ -248,6 +248,7 @@ short choose_pattern(short cur_choice, cDialog* parent, bool expandRotatable) {
std::string id2 = id;
id2.replace(0, 3, "name");
pat_dlg[id2].setText(pat.name);
pat_dlg[id2].recalcRect();
if(pat.rotatable) {
if(!expandRotatable) {
choices.push_back(pat_id);