BPopUpMenu style fixes

This commit is contained in:
John Scipione
2013-05-01 22:18:56 -04:00
parent 211e7b396d
commit 01b1b8bdaa
2 changed files with 65 additions and 59 deletions
+5 -5
View File
@@ -43,7 +43,7 @@ public:
int32 form, const char* property);
virtual status_t GetSupportedSuites(BMessage* data);
virtual status_t Perform(perform_code code, void* data);
virtual status_t Perform(perform_code code, void* _data);
virtual void ResizeToPreferred();
virtual void GetPreferredSize(float* _width,
@@ -66,13 +66,13 @@ protected:
private:
BMenuItem* _Go(BPoint where, bool autoInvoke,
bool startOpened, BRect* specialRect,
bool startOpened, BRect* _specialRect,
bool async);
BMenuItem* _StartTrack(BPoint where, bool autoInvoke,
bool startOpened, BRect* specialRect);
BMenuItem* _WaitMenu(void* data);
bool startOpened, BRect* _specialRect);
BMenuItem* _WaitMenu(void* _data);
static int32 _thread_entry(void* data);
static int32 _thread_entry(void* menuData);
private:
BPoint fWhere;
+27 -21
View File
@@ -38,7 +38,8 @@ struct popup_menu_data {
BPopUpMenu::BPopUpMenu(const char* title, bool radioMode, bool autoRename,
menu_layout layout)
: BMenu(title, layout),
:
BMenu(title, layout),
fUseWhere(false),
fAutoDestruct(false),
fTrackThread(-1)
@@ -52,7 +53,8 @@ BPopUpMenu::BPopUpMenu(const char *title, bool radioMode, bool autoRename,
BPopUpMenu::BPopUpMenu(BMessage* archive)
: BMenu(archive),
:
BMenu(archive),
fUseWhere(false),
fAutoDestruct(false),
fTrackThread(-1)
@@ -103,9 +105,9 @@ BPopUpMenu::Go(BPoint where, bool deliversMessage, bool openAnyway,
void
BPopUpMenu::MessageReceived(BMessage *msg)
BPopUpMenu::MessageReceived(BMessage* message)
{
BMenu::MessageReceived(msg);
BMenu::MessageReceived(message);
}
@@ -124,9 +126,9 @@ BPopUpMenu::MouseUp(BPoint point)
void
BPopUpMenu::MouseMoved(BPoint point, uint32 code, const BMessage *msg)
BPopUpMenu::MouseMoved(BPoint point, uint32 code, const BMessage* message)
{
BView::MouseMoved(point, code, msg);
BView::MouseMoved(point, code, message);
}
@@ -159,10 +161,10 @@ BPopUpMenu::FrameResized(float newWidth, float newHeight)
BHandler*
BPopUpMenu::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier,
int32 form, const char *property)
BPopUpMenu::ResolveSpecifier(BMessage* message, int32 index,
BMessage* specifier, int32 form, const char* property)
{
return BMenu::ResolveSpecifier(msg, index, specifier, form, property);
return BMenu::ResolveSpecifier(message, index, specifier, form, property);
}
@@ -307,7 +309,7 @@ void BPopUpMenu::_ReservedPopUpMenu3() {}
BPopUpMenu&
BPopUpMenu::operator=(const BPopUpMenu &)
BPopUpMenu::operator=(const BPopUpMenu& other)
{
return *this;
}
@@ -317,7 +319,6 @@ BMenuItem *
BPopUpMenu::_Go(BPoint where, bool autoInvoke, bool startOpened,
BRect* _specialRect, bool async)
{
if (fTrackThread >= B_OK) {
// we already have an active menu, wait for it to go away before
// spawning another
@@ -325,8 +326,9 @@ BPopUpMenu::_Go(BPoint where, bool autoInvoke, bool startOpened,
while (wait_for_thread(fTrackThread, &unused) == B_INTERRUPTED)
;
}
popup_menu_data* data = new (std::nothrow) popup_menu_data;
if (!data)
if (data == NULL)
return NULL;
sem_id sem = create_sem(0, "window close lock");
@@ -336,14 +338,14 @@ BPopUpMenu::_Go(BPoint where, bool autoInvoke, bool startOpened,
}
// Get a pointer to the window from which Go() was called
BWindow *window = dynamic_cast<BWindow *>(BLooper::LooperForThread(find_thread(NULL)));
BWindow* window
= dynamic_cast<BWindow*>(BLooper::LooperForThread(find_thread(NULL)));
data->window = window;
// Asynchronous menu: we set the BWindow menu's semaphore
// and let BWindow block when needed
if (async && window != NULL) {
if (async && window != NULL)
_set_menu_sem_(window, sem);
}
data->object = this;
data->autoInvoke = autoInvoke;
@@ -357,7 +359,8 @@ BPopUpMenu::_Go(BPoint where, bool autoInvoke, bool startOpened,
data->lock = sem;
// Spawn the tracking thread
fTrackThread = spawn_thread(_thread_entry, "popup", B_DISPLAY_PRIORITY, data);
fTrackThread = spawn_thread(_thread_entry, "popup", B_DISPLAY_PRIORITY,
data);
if (fTrackThread < B_OK) {
// Something went wrong. Cleanup and return NULL
delete_sem(sem);
@@ -378,16 +381,17 @@ BPopUpMenu::_Go(BPoint where, bool autoInvoke, bool startOpened,
/* static */
int32
BPopUpMenu::_thread_entry(void *arg)
BPopUpMenu::_thread_entry(void* menuData)
{
popup_menu_data *data = static_cast<popup_menu_data *>(arg);
popup_menu_data* data = static_cast<popup_menu_data*>(menuData);
BPopUpMenu* menu = data->object;
BRect* rect = NULL;
if (data->useRect)
rect = &data->rect;
data->selected = menu->_StartTrack(data->where, data->autoInvoke, data->startOpened, rect);
data->selected = menu->_StartTrack(data->where, data->autoInvoke,
data->startOpened, rect);
// Reset the window menu semaphore
if (data->async && data->window)
@@ -409,7 +413,8 @@ BPopUpMenu::_thread_entry(void *arg)
BMenuItem*
BPopUpMenu::_StartTrack(BPoint where, bool autoInvoke, bool startOpened, BRect *_specialRect)
BPopUpMenu::_StartTrack(BPoint where, bool autoInvoke, bool startOpened,
BRect* _specialRect)
{
fWhere = where;
@@ -418,7 +423,8 @@ BPopUpMenu::_StartTrack(BPoint where, bool autoInvoke, bool startOpened, BRect *
// called by BMenu::Track()
fUseWhere = true;
// Determine when mouse-down-up will be taken as a 'press', rather than a 'click'
// Determine when mouse-down-up will be taken as a 'press',
// rather than a 'click'
bigtime_t clickMaxTime = 0;
get_click_speed(&clickMaxTime);
clickMaxTime += system_time();