U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ Core » DropList STDFONT size changing after Drawn on screen
DropList STDFONT size changing after Drawn on screen [message #59805] Thu, 20 April 2023 18:06 Go to previous message
devilsclaw is currently offline  devilsclaw
Messages: 76
Registered: August 2022
Member
So I have dynamic elements in my UI and when I select a option button it changes what is in a DropList.

Based off the content of the DropList I resize it.

Before the TopWindow is displayed on screen the STDFONT on my systems height is 13. Once it is displayed the STDFONT height is 11, which also affect the width

Why would the height change once the windows is displayed? it makes it impossible to actually calculate the width of something.


int egui_width(Upp::Font f, const char* s, size_t length, int minsize) {
  int width = 0;
  for(int i = 0; i < length; i++) {
    width += f[s[i]];
  }
  if(minsize > -1 && width < minsize) {
    width = minsize;
  }
  return Upp::DPI(width);
}

int egui_width(Upp::Font f, Upp::String s, int minsize) {
  return egui_width(f, s, s.GetCount(), minsize);
}

int egui_width(Upp::DropList& c, int minsize) {
  Upp::Font f = c.GetPreeditFont();
  int width = 0;
  for(int i = 0; i < c.GetCount(); i++) {
    int twidth = egui_width(f, c.GetValue(i));
    if(twidth > width) {
      width = twidth;
    }
  }

  width += Upp::DPI(c.GetMinSize().cx);
  width += Upp::DPI(24);

  if(minsize > -1 && width < Upp::DPI(minsize)) {
    width = Upp::DPI(minsize);
  }
  return width;
}

[Updated on: Thu, 20 April 2023 18:07]

Report message to a moderator

 
Read Message
Read Message
Read Message
Previous Topic: Latest leap second missing from GetLeapSeconds()
Next Topic: CreateProcessW doesn't compile with CLANG
Goto Forum:
  


Current Time: Tue Apr 28 16:01:45 GMT+2 2026

Total time taken to generate the page: 0.01090 seconds