Preferences dialog is progressing...

This commit is contained in:
plfiorini 2010-05-08 19:35:28 +00:00
parent aac9a222b3
commit 454762c7eb
9 changed files with 244 additions and 152 deletions

View File

@ -14,7 +14,8 @@ class BBitmap;
#include <SupportDefs.h> #include <SupportDefs.h>
#include <String.h> #include <String.h>
#include "KeyMap.h"
#include <libsupport/KeyMap.h>
class ImageCache class ImageCache
{ {

View File

@ -9,7 +9,8 @@
#include <Path.h> #include <Path.h>
#include <String.h> #include <String.h>
#include "KeyMap.h" #include <libs/libsupport/KeyMap.h>
#include "CayaProtocol.h" #include "CayaProtocol.h"
class BBitmap; class BBitmap;

View File

@ -44,8 +44,7 @@ const float kDividerWidth = 1.0f;
ProtocolSettings::ProtocolSettings(CayaProtocol* cayap) ProtocolSettings::ProtocolSettings(CayaProtocol* cayap)
: fProtocol(cayap), : fProtocol(cayap),
fTemplate(new BMessage()), fTemplate(new BMessage())
fSettings(new BMessage())
{ {
_Init(); _Init();
} }
@ -54,7 +53,6 @@ ProtocolSettings::ProtocolSettings(CayaProtocol* cayap)
ProtocolSettings::~ProtocolSettings() ProtocolSettings::~ProtocolSettings()
{ {
delete fTemplate; delete fTemplate;
delete fSettings;
} }
@ -65,19 +63,27 @@ ProtocolSettings::InitCheck() const
} }
BList* CayaProtocol*
ProtocolSettings::Protocol() const
{
return fProtocol;
}
List<BString>
ProtocolSettings::Accounts() const ProtocolSettings::Accounts() const
{ {
List<BString> list;
BPath path; BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
return NULL; return list;
path.Append("Caya/Protocols"); path.Append("Caya/Protocols");
path.Append(fProtocol->GetSignature()); path.Append(fProtocol->GetSignature());
if (create_directory(path.Path(), 0755) != B_OK) if (create_directory(path.Path(), 0755) != B_OK)
return NULL; return list;
BList* list = new BList();
BDirectory dir(path.Path()); BDirectory dir(path.Path());
BEntry entry; BEntry entry;
while (dir.GetNextEntry(&entry) == B_OK) { while (dir.GetNextEntry(&entry) == B_OK) {
@ -86,10 +92,8 @@ ProtocolSettings::Accounts() const
if (msg.Unflatten(&file) == B_OK) { if (msg.Unflatten(&file) == B_OK) {
char buffer[B_PATH_NAME_LENGTH]; char buffer[B_PATH_NAME_LENGTH];
if (entry.GetName(buffer) == B_OK) { if (entry.GetName(buffer) == B_OK)
BString* string = new BString(buffer); list.AddItem(BString(buffer));
list->AddItem(string);
}
} }
} }
@ -98,85 +102,26 @@ ProtocolSettings::Accounts() const
status_t status_t
ProtocolSettings::Load(const char* account) ProtocolSettings::LoadTemplate(BView* parent)
{ {
status_t ret = B_ERROR; return Load(NULL, parent);
// Find user's settings path
BPath path;
if ((ret = find_directory(B_USER_SETTINGS_DIRECTORY, &path)) != B_OK)
return ret;
// Create path
path.Append("Caya/Protocols");
path.Append(fProtocol->GetSignature());
if ((ret = create_directory(path.Path(), 0755)) != B_OK)
return ret;
// Load settings file
path.Append(account);
BFile file(path.Path(), B_READ_ONLY);
return fSettings->Unflatten(&file);
} }
status_t status_t
ProtocolSettings::Save(const char* account) ProtocolSettings::Load(const char* account, BView* parent)
{
status_t ret = B_ERROR;
// Find user's settings path
BPath path;
if ((ret = find_directory(B_USER_SETTINGS_DIRECTORY, &path)) != B_OK)
return ret;
// Create path
path.Append("Caya/Protocols");
path.Append(fProtocol->GetSignature());
if ((ret = create_directory(path.Path(), 0755)) != B_OK)
return ret;
// Load settings file
path.Append(account);
BFile file(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY);
return fSettings->Flatten(&file);
}
status_t
ProtocolSettings::Delete(const char* account)
{
status_t ret = B_ERROR;
// Find user's settings path
BPath path;
if ((ret = find_directory(B_USER_SETTINGS_DIRECTORY, &path)) != B_OK)
return ret;
// Create path
path.Append("Caya/Protocols");
path.Append(fProtocol->GetSignature());
if ((ret = create_directory(path.Path(), 0755)) != B_OK)
return ret;
path.Append(account);
// Delete settings file
BEntry entry(path.Path());
if ((ret = entry.Remove()) != B_OK)
return ret;
delete fSettings;
fSettings = new BMessage();
return B_OK;
}
void
ProtocolSettings::BuildGUI(BView* parent)
{ {
if (!parent) if (!parent)
debugger("Couldn't build protocol's settings GUI on a NULL parent!"); debugger("Couldn't build protocol's settings GUI on a NULL parent!");
BMessage* settings = NULL;
if (account) {
status_t ret = _Load(account, &settings);
if (ret != B_OK)
return ret;
}
BMessage curr; BMessage curr;
float inset = ceilf(be_plain_font->Size() * 0.7f); float inset = ceilf(be_plain_font->Size() * 0.7f);
@ -215,17 +160,21 @@ ProtocolSettings::BuildGUI(BView* parent)
menu->AddItem(item); menu->AddItem(item);
} }
value = fSettings->FindString(name); if (settings) {
if (value) value = settings->FindString(name);
menu->FindItem(value)->SetMarked(true); if (value)
menu->FindItem(value)->SetMarked(true);
}
} else { } else {
// It's a free-text setting // It's a free-text setting
if (curr.FindBool("multi_line", &multiLine) != B_OK) if (curr.FindBool("multi_line", &multiLine) != B_OK)
multiLine = false; multiLine = false;
value = fSettings->FindString(name); if (settings) {
if (!value) value = settings->FindString(name);
value = curr.FindString("default"); if (!value)
value = curr.FindString("default");
}
if (curr.FindBool("is_secret",&secret) != B_OK) if (curr.FindBool("is_secret",&secret) != B_OK)
secret = false; secret = false;
@ -240,7 +189,10 @@ ProtocolSettings::BuildGUI(BView* parent)
menu = new BPopUpMenu(name); menu = new BPopUpMenu(name);
int32 def = 0; int32 def = 0;
status_t hasValue = fSettings->FindInt32(name, 0, &def); status_t hasValue = B_ERROR;
if (settings)
settings->FindInt32(name, 0, &def);
if (hasValue != B_OK) if (hasValue != B_OK)
hasValue = curr.FindInt32("default", 0, &def); hasValue = curr.FindInt32("default", 0, &def);
@ -262,7 +214,7 @@ ProtocolSettings::BuildGUI(BView* parent)
// It's a free-text (but number) setting // It's a free-text (but number) setting
int32 v = 0; int32 v = 0;
if (fSettings->FindInt32(name, &v) == B_OK) { if (settings && settings->FindInt32(name, &v) == B_OK) {
sprintf(temp,"%ld", v); sprintf(temp,"%ld", v);
value = temp; value = temp;
} else if (curr.FindInt32("default", &v) == B_OK) { } else if (curr.FindInt32("default", &v) == B_OK) {
@ -278,7 +230,7 @@ ProtocolSettings::BuildGUI(BView* parent)
case B_BOOL_TYPE: { case B_BOOL_TYPE: {
bool active; bool active;
if (fSettings->FindBool(name, &active) != B_OK) { if (settings && settings->FindBool(name, &active) != B_OK) {
if (curr.FindBool("default", &active) != B_OK) if (curr.FindBool("default", &active) != B_OK)
active = false; active = false;
} }
@ -329,15 +281,19 @@ ProtocolSettings::BuildGUI(BView* parent)
layout.AddGlue(); layout.AddGlue();
parent->AddChild(layout); parent->AddChild(layout);
return B_OK;
} }
status_t status_t
ProtocolSettings::SaveGUI(BView* parent) ProtocolSettings::Save(const char* account, BView* parent)
{ {
if (!parent) if (!parent)
debugger("Couldn't save protocol's settings GUI on a NULL parent!"); debugger("Couldn't save protocol's settings GUI on a NULL parent!");
BMessage* settings = new BMessage();
BMessage cur; BMessage cur;
for (int32 i = 0; fTemplate->FindMessage("setting", i, &cur) == B_OK; i++) { for (int32 i = 0; fTemplate->FindMessage("setting", i, &cur) == B_OK; i++) {
const char* name = cur.FindString("name"); const char* name = cur.FindString("name");
@ -359,10 +315,10 @@ ProtocolSettings::SaveGUI(BView* parent)
if (textControl) { if (textControl) {
switch (type) { switch (type) {
case B_STRING_TYPE: case B_STRING_TYPE:
fSettings->AddString(name, textControl->Text()); settings->AddString(name, textControl->Text());
break; break;
case B_INT32_TYPE: case B_INT32_TYPE:
fSettings->AddInt32(name, atoi(textControl->Text())); settings->AddInt32(name, atoi(textControl->Text()));
break; break;
default: default:
return B_ERROR; return B_ERROR;
@ -378,10 +334,10 @@ ProtocolSettings::SaveGUI(BView* parent)
switch (type) { switch (type) {
case B_STRING_TYPE: case B_STRING_TYPE:
fSettings->AddString(name, item->Label()); settings->AddString(name, item->Label());
break; break;
case B_INT32_TYPE: case B_INT32_TYPE:
fSettings->AddInt32(name, atoi(item->Label())); settings->AddInt32(name, atoi(item->Label()));
break; break;
default: default:
return B_ERROR; return B_ERROR;
@ -391,15 +347,40 @@ ProtocolSettings::SaveGUI(BView* parent)
BCheckBox* checkBox BCheckBox* checkBox
= dynamic_cast<BCheckBox*>(view); = dynamic_cast<BCheckBox*>(view);
if (checkBox) if (checkBox)
fSettings->AddBool(name, (checkBox->Value() == B_CONTROL_ON)); settings->AddBool(name, (checkBox->Value() == B_CONTROL_ON));
NotifyingTextView* textView NotifyingTextView* textView
= dynamic_cast<NotifyingTextView*>(view); = dynamic_cast<NotifyingTextView*>(view);
if (textView) if (textView)
fSettings->AddString(name, textView->Text()); settings->AddString(name, textView->Text());
} }
fSettings->PrintToStream(); return _Save(account, settings);
}
status_t
ProtocolSettings::Delete(const char* account)
{
status_t ret = B_ERROR;
// Find user's settings path
BPath path;
if ((ret = find_directory(B_USER_SETTINGS_DIRECTORY, &path)) != B_OK)
return ret;
// Create path
path.Append("Caya/Protocols");
path.Append(fProtocol->GetSignature());
if ((ret = create_directory(path.Path(), 0755)) != B_OK)
return ret;
path.Append(account);
// Delete settings file
BEntry entry(path.Path());
if ((ret = entry.Remove()) != B_OK)
return ret;
return B_OK; return B_OK;
} }
@ -433,3 +414,60 @@ ProtocolSettings::_Init()
// Load protocol's settings template // Load protocol's settings template
fTemplate->Unflatten((const char*)data); fTemplate->Unflatten((const char*)data);
} }
status_t
ProtocolSettings::_Load(const char* account, BMessage** settings)
{
*settings = NULL;
if (!account || !settings)
return B_BAD_VALUE;
status_t ret = B_ERROR;
// Find user's settings path
BPath path;
if ((ret = find_directory(B_USER_SETTINGS_DIRECTORY, &path)) != B_OK)
return ret;
// Create path
path.Append("Caya/Protocols");
path.Append(fProtocol->GetSignature());
if ((ret = create_directory(path.Path(), 0755)) != B_OK)
return ret;
// Load settings file
path.Append(account);
BFile file(path.Path(), B_READ_ONLY);
BMessage* msg = new BMessage();
ret = msg->Unflatten(&file);
*settings = msg;
return ret;
}
status_t
ProtocolSettings::_Save(const char* account, BMessage* settings)
{
if (!account || !settings)
return B_BAD_VALUE;
status_t ret = B_ERROR;
// Find user's settings path
BPath path;
if ((ret = find_directory(B_USER_SETTINGS_DIRECTORY, &path)) != B_OK)
return ret;
// Create path
path.Append("Caya/Protocols");
path.Append(fProtocol->GetSignature());
if ((ret = create_directory(path.Path(), 0755)) != B_OK)
return ret;
// Load settings file
path.Append(account);
BFile file(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY);
return settings->Flatten(&file);
}

View File

@ -6,33 +6,35 @@
#ifndef _PROTOCOL_SETTINGS_H #ifndef _PROTOCOL_SETTINGS_H
#define _PROTOCOL_SETTINGS_H #define _PROTOCOL_SETTINGS_H
#include <libsupport/List.h>
class BMessage; class BMessage;
class CayaProtocol; class CayaProtocol;
class ProtocolSettings { class ProtocolSettings {
public: public:
ProtocolSettings(CayaProtocol* cayap); ProtocolSettings(CayaProtocol* cayap);
~ProtocolSettings(); ~ProtocolSettings();
status_t InitCheck() const; status_t InitCheck() const;
BList* Accounts() const; CayaProtocol* Protocol() const;
List<BString> Accounts() const;
status_t Load(const char* account); status_t LoadTemplate(BView* parent);
status_t Save(const char* account); status_t Load(const char* account, BView* parent);
status_t Delete(const char* account); status_t Save(const char* account, BView* parent);
status_t Delete(const char* account);
void BuildGUI(BView* parent);
status_t SaveGUI(BView* parent);
private: private:
status_t fStatus; status_t fStatus;
CayaProtocol* fProtocol; CayaProtocol* fProtocol;
BString fAccount; BString fAccount;
BMessage* fTemplate; BMessage* fTemplate;
BMessage* fSettings;
void _Init(); void _Init();
status_t _Load(const char* account, BMessage** settings);
status_t _Save(const char* account, BMessage* settings);
}; };
#endif // _PROTOCOL_SETTINGS_H #endif // _PROTOCOL_SETTINGS_H

View File

@ -8,9 +8,10 @@
#include <Message.h> #include <Message.h>
#include <MessageFilter.h> #include <MessageFilter.h>
#include <libsupport/KeyMap.h>
#include "CayaConstants.h" #include "CayaConstants.h"
#include "ContactLinker.h" #include "ContactLinker.h"
#include "KeyMap.h"
class MainWindow; class MainWindow;
class RosterItem; class RosterItem;

View File

@ -20,7 +20,6 @@ AccountListItem::AccountListItem(CayaProtocol* cayap, const char* account)
fBaselineOffset(0) fBaselineOffset(0)
{ {
fSettings = new ProtocolSettings(cayap); fSettings = new ProtocolSettings(cayap);
fSettings->Load(account);
} }

View File

@ -12,7 +12,7 @@
#include <GroupLayout.h> #include <GroupLayout.h>
#include <GroupLayoutBuilder.h> #include <GroupLayoutBuilder.h>
#include <ListView.h> #include <ListView.h>
#include <Menu.h> #include <PopUpMenu.h>
#include <MenuField.h> #include <MenuField.h>
#include <ScrollView.h> #include <ScrollView.h>
#include <TextControl.h> #include <TextControl.h>
@ -21,6 +21,7 @@
#include <libinterface/BitmapMenuItem.h> #include <libinterface/BitmapMenuItem.h>
#include <libinterface/Divider.h> #include <libinterface/Divider.h>
#include <libinterface/NotifyingTextView.h> #include <libinterface/NotifyingTextView.h>
#include <libinterface/ToolButton.h>
#include "AccountListItem.h" #include "AccountListItem.h"
#include "CayaProtocol.h" #include "CayaProtocol.h"
@ -28,14 +29,15 @@
#include "ProtocolManager.h" #include "ProtocolManager.h"
#include "ProtocolSettings.h" #include "ProtocolSettings.h"
const uint32 kAddAccount = 'ADAC'; const uint32 kAddAccount = 'ADAC';
const uint32 kEditAccount = 'EDAC'; const uint32 kEditAccount = 'EDAC';
const uint32 kDelAccount = 'DLAC'; const uint32 kDelAccount = 'DLAC';
const uint32 kSelect = 'SELT'; const uint32 kSelect = 'SELT';
const uint32 kCancel = 'CANC'; const uint32 kCancel = 'CANC';
const uint32 kOK = 'SAVE'; const uint32 kOK = 'SAVE';
const uint32 kChanged = 'CHGD';
const uint32 kChanged = 'CHGD';
class AccountView : public BView { class AccountView : public BView {
@ -100,21 +102,22 @@ public:
B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE) B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE)
{ {
fSettings = new ProtocolSettings(cayap); fSettings = new ProtocolSettings(cayap);
if (account)
fSettings->Load(account);
fAccountName = new BTextControl("accountName", "Account name:", NULL, NULL); fAccountName = new BTextControl("accountName", "Account name:", NULL, NULL);
fAccountName->SetFont(be_bold_font); fAccountName->SetFont(be_bold_font);
fAccountName->MakeFocus();
if (account) { if (account) {
fAccountName->SetText(account); fAccountName->SetText(account);
fAccountName->SetEnabled(false); fAccountName->SetEnabled(false);
} } else
fAccountName->MakeFocus(true);
Divider* divider = new Divider("divider", B_WILL_DRAW); Divider* divider = new Divider("divider", B_WILL_DRAW);
fTop = new AccountView("top"); fTop = new AccountView("top");
fSettings->BuildGUI(fTop); if (account)
fSettings->Load(account, fTop);
else
fSettings->LoadTemplate(fTop);
BButton* cancel = new BButton("Cancel", new BMessage(kCancel)); BButton* cancel = new BButton("Cancel", new BMessage(kCancel));
BButton* ok = new BButton("OK", new BMessage(kOK)); BButton* ok = new BButton("OK", new BMessage(kOK));
@ -142,9 +145,8 @@ public:
{ {
switch (msg->what) { switch (msg->what) {
case kOK: case kOK:
if (fSettings->SaveGUI(fTop) == B_OK) if (fSettings->Save(fAccountName->Text(), fTop) == B_OK)
if (fSettings->Save(fAccountName->Text()) == B_OK) Close();
Close();
// TODO: Error! // TODO: Error!
break; break;
case kCancel: case kCancel:
@ -177,20 +179,14 @@ PreferencesAccounts::PreferencesAccounts()
BList* protocols = ProtocolManager::Get()->GetProtocols(); BList* protocols = ProtocolManager::Get()->GetProtocols();
fProtosMenu = new BMenu("Add"); fProtosMenu = new BPopUpMenu(NULL, true);
for (int32 i = 0; i < protocols->CountItems(); i++) { for (int32 i = 0; i < protocols->CountItems(); i++) {
CayaProtocol* cayap CayaProtocol* cayap
= reinterpret_cast<CayaProtocol*>(protocols->ItemAtFast(i)); = reinterpret_cast<CayaProtocol*>(protocols->ItemAtFast(i));
ProtocolSettings* settings = new ProtocolSettings(cayap); ProtocolSettings* settings = new ProtocolSettings(cayap);
BList* accounts = settings->Accounts();
// Add accounts to list view // Add accounts to list view
for (int32 j = 0; j < accounts->CountItems(); j++) { _LoadListView(settings);
BString* account = reinterpret_cast<BString*>(accounts->ItemAtFast(j));
AccountListItem* listItem = new AccountListItem(cayap,
account->String());
fListView->AddItem(listItem);
}
// Add menu items // Add menu items
BMessage* msg = new BMessage(kAddAccount); BMessage* msg = new BMessage(kAddAccount);
@ -201,13 +197,13 @@ PreferencesAccounts::PreferencesAccounts()
ProtocolManager::Get()->GetProtocolIcon(cayap->GetSignature())); ProtocolManager::Get()->GetProtocolIcon(cayap->GetSignature()));
fProtosMenu->AddItem(item); fProtosMenu->AddItem(item);
delete accounts;
delete settings; delete settings;
} }
BMenuField* proto = new BMenuField("addAccountField", NULL, fProtosMenu); ToolButton* proto = new ToolButton("+", NULL);
fDelButton = new BButton(" - ", new BMessage(kDelAccount)); proto->SetMenu(fProtosMenu);
fEditButton = new BButton("Edit...", new BMessage(kEditAccount)); fDelButton = new ToolButton("-", new BMessage(kDelAccount));
fEditButton = new ToolButton("Edit...", new BMessage(kEditAccount));
fDelButton->SetEnabled(false); fDelButton->SetEnabled(false);
fEditButton->SetEnabled(false); fEditButton->SetEnabled(false);
@ -255,6 +251,9 @@ PreferencesAccounts::MessageReceived(BMessage* msg)
if (msg->FindPointer("protocol", &protocol) == B_OK) { if (msg->FindPointer("protocol", &protocol) == B_OK) {
CayaProtocol* cayap = (CayaProtocol*) protocol; CayaProtocol* cayap = (CayaProtocol*) protocol;
BLooper* looper = new BLooper();
looper->AddHandler(this);
AccountDialog* dialog = new AccountDialog("Add account", cayap); AccountDialog* dialog = new AccountDialog("Add account", cayap);
dialog->Show(); dialog->Show();
} }
@ -272,6 +271,9 @@ PreferencesAccounts::MessageReceived(BMessage* msg)
CayaProtocol* cayap = item->Protocol(); CayaProtocol* cayap = item->Protocol();
const char* account = item->Account(); const char* account = item->Account();
BLooper* looper = new BLooper();
looper->AddHandler(this);
AccountDialog* dialog = new AccountDialog("Edit account", cayap, account); AccountDialog* dialog = new AccountDialog("Edit account", cayap, account);
dialog->Show(); dialog->Show();
} }
@ -298,3 +300,21 @@ PreferencesAccounts::MessageReceived(BMessage* msg)
BView::MessageReceived(msg); BView::MessageReceived(msg);
} }
} }
void
PreferencesAccounts::_LoadListView(ProtocolSettings* settings)
{
if (!settings)
return;
List<BString> accounts = settings->Accounts();
// Add accounts to list view
for (uint32 i = 0; i < accounts.CountItems(); i++) {
BString account = accounts.ItemAt(i);
AccountListItem* listItem = new AccountListItem(
settings->Protocol(), account.String());
fListView->AddItem(listItem);
}
}

View File

@ -7,9 +7,12 @@
#include <View.h> #include <View.h>
class BListView;
class BMenu;
class BButton; class BButton;
class BListView;
class BPopUpMenu;
class ToolButton;
class ProtocolSettings;
class PreferencesAccounts : public BView { class PreferencesAccounts : public BView {
public: public:
@ -20,9 +23,12 @@ public:
private: private:
BListView* fListView; BListView* fListView;
BMenu* fProtosMenu; BPopUpMenu* fProtosMenu;
BButton* fDelButton; ToolButton* fDelButton;
BButton* fEditButton; ToolButton* fEditButton;
void _LoadListView(ProtocolSettings* settings);
}; };
#endif // _PREFERENCES_ACCOUNTS_H #endif // _PREFERENCES_ACCOUNTS_H

View File

@ -300,6 +300,30 @@ ToolButton::Perform(perform_code code, void* data)
((perform_data_preferred_size*)data)->return_value ((perform_data_preferred_size*)data)->return_value
= ToolButton::PreferredSize(); = ToolButton::PreferredSize();
return B_OK; return B_OK;
case PERFORM_CODE_LAYOUT_ALIGNMENT:
((perform_data_layout_alignment*)data)->return_value
= ToolButton::LayoutAlignment();
return B_OK;
case PERFORM_CODE_HAS_HEIGHT_FOR_WIDTH:
((perform_data_has_height_for_width*)data)->return_value
= ToolButton::HasHeightForWidth();
return B_OK;
case PERFORM_CODE_GET_HEIGHT_FOR_WIDTH: {
perform_data_get_height_for_width* _data
= (perform_data_get_height_for_width*)data;
ToolButton::GetHeightForWidth(_data->width, &_data->min, &_data->max,
&_data->preferred);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT: {
perform_data_invalidate_layout* _data
= (perform_data_invalidate_layout*)_data;
ToolButton::InvalidateLayout(_data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:
ToolButton::DoLayout();
return B_OK;
} }
return BControl::Perform(code, data); return BControl::Perform(code, data);
@ -375,7 +399,7 @@ ToolButton::_ValidatePreferredSize()
GetFontHeight(&fontHeight); GetFontHeight(&fontHeight);
fPreferredSize.height fPreferredSize.height
= ceilf((fontHeight.ascent + fontHeight.descent) * 1.8) = ceilf((fontHeight.ascent + fontHeight.descent) * 1.5)
+ (fBitmap ? kToolbarIconSize + 4.0f : 0); + (fBitmap ? kToolbarIconSize + 4.0f : 0);
ResetLayoutInvalidation(); ResetLayoutInvalidation();