当前位置: 首页>>代码示例>>C++>>正文


C++ EventHandler::mouse_press方法代码示例

本文整理汇总了C++中EventHandler::mouse_press方法的典型用法代码示例。如果您正苦于以下问题:C++ EventHandler::mouse_press方法的具体用法?C++ EventHandler::mouse_press怎么用?C++ EventHandler::mouse_press使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventHandler的用法示例。


在下文中一共展示了EventHandler::mouse_press方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

static gboolean 
on_button_press (GtkWidget *widget, GdkEventButton *event, void *user_data)
{
    Viewer *self = (Viewer*) user_data;

    gtku_gl_drawing_area_set_context (self->gl_area);
    double ray_start[3];
    double ray_dir[3];
    _window_coord_to_ray (event->x, widget->allocation.height - event->y, ray_start, ray_dir);

    // find a new picker?
    double best_distance = HUGE;
    EventHandler *best_handler = NULL;

    if (self->picking_handler == NULL || self->picking_handler->picking==0) {
        for (unsigned int eidx = 0; eidx < g_ptr_array_size(self->event_handlers); eidx++) {
            EventHandler *handler = g_ptr_array_index(self->event_handlers, eidx);
            
            if (handler->enabled && handler->pick_query) {
                double this_distance = handler->pick_query(self, handler, ray_start, ray_dir);
                if (this_distance < best_distance && this_distance >= 0) {
                    best_distance = this_distance;
                    best_handler = handler;
                }
            }
        }

        // notify the new handler
        if (best_handler)
            viewer_request_pick(self, best_handler);
    }

    // give picking handler first dibs
    int consumed = 0;
    if (self->picking_handler && !self->picking_handler->picking)
        self->picking_handler = NULL;
    if (self->picking_handler && self->picking_handler->enabled && self->picking_handler->mouse_press) {
        consumed = self->picking_handler->mouse_press(self, self->picking_handler, ray_start, ray_dir, event);
        update_status_bar(self);
    }

    // try all the other handlers in order of priority
    for (unsigned int eidx = 0; !consumed && eidx < g_ptr_array_size(self->event_handlers); eidx++) {
        EventHandler *handler = g_ptr_array_index(self->event_handlers, eidx);
        
        if (handler != self->picking_handler && handler->enabled && handler->mouse_press)
            if (handler->mouse_press(self, handler, ray_start, ray_dir, event))
                break;
    }

    return TRUE;
}
开发者ID:BIANZiyang,项目名称:3PRE,代码行数:52,代码来源:viewer.c


注:本文中的EventHandler::mouse_press方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。