Skip to content

Commit

Permalink
BMenuField/BTextControl: Store and reuse Label()
Browse files Browse the repository at this point in the history
  • Loading branch information
jscipione committed Apr 24, 2014
1 parent b11edca commit 60370b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/kits/interface/MenuField.cpp
Expand Up @@ -1288,8 +1288,9 @@ BMenuField::_ValidateLayoutData()
font_height& fh = fLayoutData->font_info;
GetFontHeight(&fh);

if (Label() != NULL) {
fLayoutData->label_width = ceilf(StringWidth(Label()));
const char* label = Label();
if (label != NULL) {
fLayoutData->label_width = ceilf(StringWidth(label));
fLayoutData->label_height = ceilf(fh.ascent) + ceilf(fh.descent);
} else {
fLayoutData->label_width = 0;
Expand Down
5 changes: 3 additions & 2 deletions src/kits/interface/TextControl.cpp
Expand Up @@ -1259,8 +1259,9 @@ BTextControl::_ValidateLayoutData()
font_height& fh = fLayoutData->font_info;
GetFontHeight(&fh);

if (Label() != NULL) {
fLayoutData->label_width = ceilf(StringWidth(Label()));
const char* label = Label();
if (label != NULL) {
fLayoutData->label_width = ceilf(StringWidth(label));
fLayoutData->label_height = ceilf(fh.ascent) + ceilf(fh.descent);
} else {
fLayoutData->label_width = 0;
Expand Down

0 comments on commit 60370b9

Please sign in to comment.