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); int32 form, const char* property);
virtual status_t GetSupportedSuites(BMessage* data); 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 ResizeToPreferred();
virtual void GetPreferredSize(float* _width, virtual void GetPreferredSize(float* _width,
@@ -66,13 +66,13 @@ protected:
private: private:
BMenuItem* _Go(BPoint where, bool autoInvoke, BMenuItem* _Go(BPoint where, bool autoInvoke,
bool startOpened, BRect* specialRect, bool startOpened, BRect* _specialRect,
bool async); bool async);
BMenuItem* _StartTrack(BPoint where, bool autoInvoke, BMenuItem* _StartTrack(BPoint where, bool autoInvoke,
bool startOpened, BRect* specialRect); bool startOpened, BRect* _specialRect);
BMenuItem* _WaitMenu(void* data); BMenuItem* _WaitMenu(void* _data);
static int32 _thread_entry(void* data); static int32 _thread_entry(void* menuData);
private: private:
BPoint fWhere; BPoint fWhere;
+27 -21
View File
@@ -38,7 +38,8 @@ struct popup_menu_data {
BPopUpMenu::BPopUpMenu(const char* title, bool radioMode, bool autoRename, BPopUpMenu::BPopUpMenu(const char* title, bool radioMode, bool autoRename,
menu_layout layout) menu_layout layout)
: BMenu(title, layout), :
BMenu(title, layout),
fUseWhere(false), fUseWhere(false),
fAutoDestruct(false), fAutoDestruct(false),
fTrackThread(-1) fTrackThread(-1)
@@ -52,7 +53,8 @@ BPopUpMenu::BPopUpMenu(const char *title, bool radioMode, bool autoRename,
BPopUpMenu::BPopUpMenu(BMessage* archive) BPopUpMenu::BPopUpMenu(BMessage* archive)
: BMenu(archive), :
BMenu(archive),
fUseWhere(false), fUseWhere(false),
fAutoDestruct(false), fAutoDestruct(false),
fTrackThread(-1) fTrackThread(-1)
@@ -103,9 +105,9 @@ BPopUpMenu::Go(BPoint where, bool deliversMessage, bool openAnyway,
void void
BPopUpMenu::MessageReceived(BMessage *msg) BPopUpMenu::MessageReceived(BMessage* message)
{ {
BMenu::MessageReceived(msg); BMenu::MessageReceived(message);
} }
@@ -124,9 +126,9 @@ BPopUpMenu::MouseUp(BPoint point)
void 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* BHandler*
BPopUpMenu::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier, BPopUpMenu::ResolveSpecifier(BMessage* message, int32 index,
int32 form, const char *property) 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&
BPopUpMenu::operator=(const BPopUpMenu &) BPopUpMenu::operator=(const BPopUpMenu& other)
{ {
return *this; return *this;
} }
@@ -317,7 +319,6 @@ BMenuItem *
BPopUpMenu::_Go(BPoint where, bool autoInvoke, bool startOpened, BPopUpMenu::_Go(BPoint where, bool autoInvoke, bool startOpened,
BRect* _specialRect, bool async) BRect* _specialRect, bool async)
{ {
if (fTrackThread >= B_OK) { if (fTrackThread >= B_OK) {
// we already have an active menu, wait for it to go away before // we already have an active menu, wait for it to go away before
// spawning another // spawning another
@@ -325,8 +326,9 @@ BPopUpMenu::_Go(BPoint where, bool autoInvoke, bool startOpened,
while (wait_for_thread(fTrackThread, &unused) == B_INTERRUPTED) while (wait_for_thread(fTrackThread, &unused) == B_INTERRUPTED)
; ;
} }
popup_menu_data* data = new (std::nothrow) popup_menu_data; popup_menu_data* data = new (std::nothrow) popup_menu_data;
if (!data) if (data == NULL)
return NULL; return NULL;
sem_id sem = create_sem(0, "window close lock"); 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 // 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; data->window = window;
// Asynchronous menu: we set the BWindow menu's semaphore // Asynchronous menu: we set the BWindow menu's semaphore
// and let BWindow block when needed // and let BWindow block when needed
if (async && window != NULL) { if (async && window != NULL)
_set_menu_sem_(window, sem); _set_menu_sem_(window, sem);
}
data->object = this; data->object = this;
data->autoInvoke = autoInvoke; data->autoInvoke = autoInvoke;
@@ -357,7 +359,8 @@ BPopUpMenu::_Go(BPoint where, bool autoInvoke, bool startOpened,
data->lock = sem; data->lock = sem;
// Spawn the tracking thread // 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) { if (fTrackThread < B_OK) {
// Something went wrong. Cleanup and return NULL // Something went wrong. Cleanup and return NULL
delete_sem(sem); delete_sem(sem);
@@ -378,16 +381,17 @@ BPopUpMenu::_Go(BPoint where, bool autoInvoke, bool startOpened,
/* static */ /* static */
int32 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; BPopUpMenu* menu = data->object;
BRect* rect = NULL; BRect* rect = NULL;
if (data->useRect) if (data->useRect)
rect = &data->rect; 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 // Reset the window menu semaphore
if (data->async && data->window) if (data->async && data->window)
@@ -409,7 +413,8 @@ BPopUpMenu::_thread_entry(void *arg)
BMenuItem* BMenuItem*
BPopUpMenu::_StartTrack(BPoint where, bool autoInvoke, bool startOpened, BRect *_specialRect) BPopUpMenu::_StartTrack(BPoint where, bool autoInvoke, bool startOpened,
BRect* _specialRect)
{ {
fWhere = where; fWhere = where;
@@ -418,7 +423,8 @@ BPopUpMenu::_StartTrack(BPoint where, bool autoInvoke, bool startOpened, BRect *
// called by BMenu::Track() // called by BMenu::Track()
fUseWhere = true; 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; bigtime_t clickMaxTime = 0;
get_click_speed(&clickMaxTime); get_click_speed(&clickMaxTime);
clickMaxTime += system_time(); clickMaxTime += system_time();