Changeset 537

Show
Ignore:
Timestamp:
06/07/08 03:35:15 (4 months ago)
Author:
krobillard
Message:

Added show, hide, and gui_setMouseFocus().
Quit & halt propogate up nested ur_eval() calls.
Thune-gl RPM builds again.

Location:
trunk/thune
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • trunk/thune/cmake_modules/FindThune.cmake

    r517 r537  
    1 FIND_PATH(THUNE_INCLUDE_DIR urlan.h /usr/include /usr/local/include) 
     1FIND_PATH(THUNE_INCLUDE_DIR urlan.h /usr/include/thune /usr/local/include/thune) 
    22 
    33FIND_LIBRARY(THUNE_LIBRARY NAMES thune PATH /usr/lib64 /usr/local/lib64 /usr/lib /usr/local/lib)  
  • trunk/thune/cmake_modules/FindThuneGL.cmake

    r518 r537  
    1 FIND_PATH(THUNEGL_INCLUDE_DIR thune-gl.h /usr/include /usr/local/include) 
     1FIND_PATH(THUNEGL_INCLUDE_DIR gx.h /usr/include/thune /usr/local/include/thune) 
    22 
    33FIND_LIBRARY(THUNEGL_LIBRARY NAMES thune-gl PATH /usr/lib64 /usr/local/lib64 /usr/lib /usr/local/lib)  
  • trunk/thune/doc/GLManual

    r516 r537  
    155155make-matrix        (vec3 -- matrix) 
    156156=================  ======================  ====================== 
     157 
     158 
     159Widget Functions 
     160---------------- 
     161 
     162================  ======================  ====================== 
     163Word              Stack Usage             Function 
     164================  ======================  ====================== 
     165show              (widget -- )            Show widget 
     166show/focus        (widget -- )            Show widget and give it focus 
     167hide              (widget -- )            Hide widget 
     168================  ======================  ====================== 
    157169 
    158170 
  • trunk/thune/gl/CMakeLists.txt

    r527 r537  
    7272    rfont.c 
    7373    shader.c 
    74 #   gui.c 
     74    gui.c 
    7575    ${GLV_FILE} 
    7676    ${JOYSTICK_FILE} 
     
    114114install(TARGETS thune-gl     DESTINATION /usr/local/bin) 
    115115install(TARGETS thuneGL-lib  DESTINATION /usr/local/lib) 
    116 #install(FILES   urlan.h     DESTINATION /usr/local/include) 
     116install(FILES   gx.h         DESTINATION /usr/local/include/thune) 
     117install(FILES   gui.h        DESTINATION /usr/local/include/thune) 
     118install(FILES   TexFont.h    DESTINATION /usr/local/include/thune) 
    117119endif () 
    118120 
  • trunk/thune/gl/gui.c

    r536 r537  
    7272    for(it.id = ui->rootList; IS_VALID(it.id); it.id = it.w->next) { \ 
    7373        it.w = WPTR(it.id); 
     74 
     75#define EACH_SHOWN_ROOT(it) \ 
     76    EACH_ROOT(it) \ 
     77        if( it.w->flags & GW_HIDDEN ) \ 
     78            continue; 
    7479 
    7580#define EACH_END    } 
     
    121126 
    122127 
    123 static void gui_freeWidgetP( GUI* ui, GWidget* w, GWidgetId id ) 
    124 { 
    125     GWidgetIt it; 
    126     GWidgetId next; 
    127  
    128     w->next = ui->firstFree; 
    129     ui->firstFree = id; 
    130  
     128static void gui_removeFocus( GUI* ui, GWidgetId id ) 
     129{ 
    131130    if( ui->mouseFocus == id ) 
    132131    { 
     
    137136    if( ui->keyFocus == id ) 
    138137        ui->keyFocus = NO_WID; 
     138} 
     139 
     140 
     141static void gui_freeWidgetP( GUI* ui, GWidget* w, GWidgetId id ) 
     142{ 
     143    GWidgetIt it; 
     144    GWidgetId next; 
     145 
     146    w->next = ui->firstFree; 
     147    ui->firstFree = id; 
     148 
     149    gui_removeFocus( ui, id ); 
    139150 
    140151    //EACH_CHILD( w, it ) 
     
    896907    ui->ut         = ut; 
    897908    ui->style      = 0; 
    898     ui->root       = NO_WID; 
    899909    ui->keyFocus   = NO_WID; 
    900910    ui->mouseFocus = NO_WID; 
     
    956966 
    957967 
     968void gui_setKeyFocus( GUI* ui, GWidgetId id ) 
     969{ 
     970    ui->keyFocus = id; 
     971} 
     972 
     973 
     974void gui_setMouseFocus( GUI* ui, GWidgetId id ) 
     975{ 
     976    ui->mouseFocus = id; 
     977} 
     978 
     979 
     980void gui_grabMouse( GUI* ui, GWidgetId id ) 
     981{ 
     982    ui->mouseFocus = id; 
     983    ui->mouseGrabbed = 1; 
     984} 
     985 
     986 
     987void gui_ungrabMouse( GUI* ui, GWidgetId id ) 
     988{ 
     989    if( ui->mouseFocus == id ) 
     990    { 
     991        ui->mouseGrabbed = 0; 
     992    } 
     993} 
     994 
     995 
    958996static GWidget* childAt( GUI* ui, GWidget* wp, const GLViewEvent* ev ) 
    959997{ 
     
    9671005 
    9681006 
    969 void gui_setKeyFocus( GUI* ui, GWidgetId id ) 
    970 { 
    971     ui->keyFocus = id; 
    972 } 
    973  
    974  
    975 void gui_grabMouse( GUI* ui, GWidgetId id ) 
    976 { 
    977     ui->mouseFocus = id; 
    978     ui->mouseGrabbed = 1; 
    979 } 
    980  
    981  
    982 void gui_ungrabMouse( GUI* ui, GWidgetId id ) 
    983 { 
    984     if( ui->mouseFocus == id ) 
    985     { 
    986         ui->mouseGrabbed = 0; 
    987     } 
     1007static GWidgetId widgetAt( GUI* ui, const GLViewEvent* ev ) 
     1008{ 
     1009    GWidgetIt it; 
     1010    EACH_SHOWN_ROOT( it ) 
     1011        if( gui_widgetContains( it.w, ev->x, ev->y ) ) 
     1012        { 
     1013            it.w = childAt( ui, it.w, ev ); 
     1014            return it.w ? WID(it.w) : NO_WID; 
     1015        } 
     1016    EACH_END 
     1017    return NO_WID; 
    9881018} 
    9891019 
     
    9941024 
    9951025#if 0 
    996     printf( "KR dispatch %d  root %d  mouseFocus %d  keyFocus %d\n", 
    997             ev->type, ui->root, ui->mouseFocus, ui->keyFocus ); 
     1026    printf( "KR dispatch %d  mouseFocus %d  keyFocus %d\n", 
     1027            ev->type, ui->mouseFocus, ui->keyFocus ); 
    9981028#endif 
    9991029 
     
    10041034            // Convert window system origin from top of window to the bottom. 
    10051035            ev->y = ui->rootH - ev->y; 
     1036            // Fall through... 
    10061037 
    10071038        case GLV_EVENT_WHEEL: 
     
    10311062                                ev->state, ev->x, ev->y ); 
    10321063                    CLASS( w ).dispatch( ui, w, &me ); 
    1033                     ui->mouseFocus = NO_WID; 
    10341064                } 
    10351065            } 
    1036             if( IS_VALID(ui->root) ) 
     1066 
     1067            ui->mouseFocus = widgetAt( ui, ev ); 
     1068            if( IS_VALID(ui->mouseFocus) ) 
    10371069            { 
    1038                 GWidget* rw = WPTR(ui->root); 
    1039                 w = childAt( ui, rw, ev ); 
    1040                 if( /*(w != rw) &&*/ (! (w->flags & GW_DISABLED)) ) 
     1070                w = WPTR(ui->mouseFocus); 
     1071                if( ! (w->flags & GW_DISABLED) ) 
    10411072                { 
    10421073                    GLViewEvent me; 
     
    10441075                                ev->state, ev->x, ev->y ); 
    10451076                    CLASS( w ).dispatch( ui, w, &me ); 
    1046                     ui->mouseFocus = WID(w); 
    10471077                    goto dispatch; 
    10481078                } 
     
    10601090 
    10611091        case GLV_EVENT_FOCUS_IN: 
     1092            ui->mouseFocus = widgetAt( ui, ev ); 
     1093            // Fall through... 
     1094 
    10621095        case GLV_EVENT_FOCUS_OUT: 
    1063             goto root; 
    1064     } 
    1065  
    1066 root: 
    1067  
    1068     if( ! IS_VALID(ui->root) ) 
    1069         return; 
    1070     w = WPTR(ui->root); 
     1096            if( IS_VALID(ui->mouseFocus) ) 
     1097            { 
     1098                w = WPTR(ui->mouseFocus); 
     1099                goto dispatch; 
     1100            } 
     1101            break; 
     1102    } 
     1103    return; 
    10711104 
    10721105dispatch: 
     
    11701203 
    11711204/** 
    1172   Returns pointer to root widget or zero if id is invalid. 
     1205  Returns pointer to root parent widget or zero if id is invalid. 
    11731206*/ 
    11741207GWidget* gui_root( const GUI* ui, GWidgetId id ) 
     
    12251258    else if( ! hidden ) 
    12261259    { 
     1260        GWidgetId id = WID(wp); 
     1261        gui_removeFocus( ui, id ); 
    12271262        wp->flags |= GW_HIDDEN; 
    12281263        markLayoutDirty( ui, wp->parent ); 
     
    13391374                        { 
    13401375                            linkRoot( ui, wp, ms->wid ); 
    1341                             ui->root = ms->wid; 
    1342  
    13431376                            if( ! IS_VALID(ui->keyFocus) ) 
    1344                                 ui->keyFocus = ui->root; 
     1377                                ui->keyFocus = ms->wid; 
    13451378                        } 
    13461379                        //return wp; 
  • trunk/thune/gl/gui.h

    r533 r537  
    4444    UAtom     atom_action; 
    4545    UAtom     atom_text; 
    46     GWidgetId root; 
    4746    GWidgetId keyFocus; 
    4847    GWidgetId mouseFocus; 
     
    163162GWidget* gui_root( const GUI* ui, GWidgetId id ); 
    164163void     gui_setKeyFocus( GUI*, GWidgetId ); 
     164void     gui_setMouseFocus( GUI*, GWidgetId ); 
    165165void     gui_grabMouse( GUI*, GWidgetId ); 
    166166void     gui_ungrabMouse( GUI*, GWidgetId ); 
  • trunk/thune/gl/gx.c

    r536 r537  
    721721 
    722722 
     723// (widget -- ) 
     724UR_CALL( uc_show ) 
     725{ 
     726    if( ur_is(tos, UT_WIDGET) ) 
     727    { 
     728        UCell* inv; 
     729        GWidgetId id = ur_int(tos); 
     730        GWidget* wp = gui_widgetPtr( &gxEnv.gui, id ); 
     731        if( wp ) 
     732        { 
     733            gui_show( &gxEnv.gui, wp, 1 ); 
     734 
     735            inv = UR_CALL_CELL; 
     736            if( inv && (ur_sel(inv) == UR_ATOM_FOCUS) ) 
     737            { 
     738                gui_setKeyFocus( &gxEnv.gui, id ); 
     739                gui_setMouseFocus( &gxEnv.gui, id ); 
     740            } 
     741        } 
     742    } 
     743    UR_S_DROP; 
     744} 
     745 
     746 
     747// (widget -- ) 
     748UR_CALL( uc_hide ) 
     749{ 
     750    if( ur_is(tos, UT_WIDGET) ) 
     751    { 
     752        GWidget* wp = gui_widgetPtr( &gxEnv.gui, ur_int(tos) ); 
     753        if( wp ) 
     754            gui_show( &gxEnv.gui, wp, 0 ); 
     755    } 
     756    UR_S_DROP; 
     757} 
     758 
     759 
    723760// (matrix vec3 -- ) 
    724761UR_CALL( uc_look_at ) 
     
    12931330    { uc_play,           "play" }, 
    12941331    { uc_stop,           "stop" }, 
     1332    { uc_show,           "show" }, 
     1333    { uc_hide,           "hide" }, 
    12951334    { uc_text_size,      "text-size" }, 
    12961335    { uc_display_events, "display.events" }, 
  • trunk/thune/thune-gl.spec

    r536 r537  
    4040mkdir include 
    4141sed -e "s~\"urlan.h\"~<thune/urlan.h>~" gl/gui.h >include/gui.h 
    42 sed -e "s~\"gui.h\"~<thune/gui.h>~" -e "s~\"TexFont.h\"~<thune/TexFontgui.h>~" gl/gx.h >include/gx.h 
     42sed -e "s~\"gui.h\"~<thune/gui.h>~" -e "s~\"TexFont.h\"~<thune/TexFont.h>~" gl/gx.h >include/gx.h 
    4343install -m 644 include/gx.h  $RPM_BUILD_ROOT%{_includedir}/thune 
    4444install -m 644 include/gui.h $RPM_BUILD_ROOT%{_includedir}/thune 
  • trunk/thune/thune.c

    r533 r537  
    773773 
    774774                case OP_HALT: 
     775                    UR_CALL_OP = OP_HALT; 
    775776                    EMH_HALT(pc, end) 
    776777                    goto halt; 
     
    778779                case OP_QUIT: 
    779780                    UR_S_PUSH( *val ); 
     781                    UR_CALL_OP = OP_QUIT; 
    780782                    goto quit; 
    781783 
     
    10161018 
    10171019                case OP_HALT: 
    1018                     UR_CALL_OP = 0; 
     1020                    //UR_CALL_OP = 0; 
    10191021                    goto halt; 
    10201022 
    10211023                case OP_QUIT: 
    1022                     UR_CALL_OP = 0; 
     1024                    //UR_CALL_OP = 0; 
    10231025                    goto quit; 
    10241026