Commit 7a66c84c authored by twanvl's avatar twanvl

Width of labels in native look editor is adjusted based on the longest label

parent b1000aad
......@@ -58,6 +58,23 @@ void NativeLookEditor::resizeViewers() {
int w, h;
GetClientSize(&w, &h);
const int default_height = 17;
// Determine label width
{
label_width = 0;
wxClientDC dc(this);
dc.SetFont(*wxNORMAL_FONT);
FOR_EACH(v, viewers) {
ValueEditor* e = v->getEditor();
if (!e || e->drawLabel()) {
// width of the label string
int w;
Style& s = *v->getStyle();
String text = tr(*set->game, s.fieldP->name, capitalize_sentence(s.fieldP->name));
dc.GetTextExtent(text,&w,nullptr);
label_width = max(label_width, w + label_margin);
}
}
}
// Set editor sizes
FOR_EACH(v, viewers) {
StyleP s = v->getStyle();
......
......@@ -35,10 +35,11 @@ class NativeLookEditor : public DataEditor {
virtual void onInit();
private:
static const UInt margin = 6;
static const UInt margin_left = 4;
static const UInt label_width = 150;
static const UInt vspace = 10;
static const int margin = 6;
static const int margin_left = 4;
static const int vspace = 10;
static const int label_margin = 10;
int label_width;
DECLARE_EVENT_TABLE();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment