Example #1
0
NvUIEventResponse NvTweakVarUI<float>::HandleReaction(const NvUIReaction& react)
{
    if (react.code && (react.code!=m_tvar.getActionCode()))
        return nvuiEventNotHandled; // not a message for us.

    if (react.flags & NvReactFlag::FORCE_UPDATE)
    {
        NvUIReaction &change = GetReactionEdit(false); // false to not clear it!!!
        change.fval = m_tvar; // update to what's stored in the variable.
    }

    INHERITED::HandleReaction(react);

    NvUIEventResponse r = nvuiEventNotHandled;
    if (   (react.uid==GetUID()) // we always listen to our own sent messages.
        || (react.code && (react.code==m_tvar.getActionCode())) // we always listen to our action code
        || (!react.code && (react.flags & NvReactFlag::FORCE_UPDATE)) ) // we listen to force-update only if NO action code
    {
        if (m_tvar != react.fval)
        {
            m_tvar = react.fval; // float TweakVar stashed value in fval in HandleReaction
            return nvuiEventHandled; // !!!!TBD TODO do we eat it here?
        }
    }

    return r;
}
Example #2
0
//======================================================================
//======================================================================
void NvTweakBar::syncValue(NvTweakVarBase* var)
{
    NvUIReaction &react = GetReactionEdit(true);
    react.code = var->getActionCode();
    react.flags = NvReactFlag::FORCE_UPDATE;
    HandleReaction(react);
}
Example #3
0
//======================================================================
//======================================================================
void NvTweakBar::syncValues()
{
    NvUIReaction &react = GetReactionEdit(true);
    react.code = 0; // match all.
    react.flags = NvReactFlag::FORCE_UPDATE;
    HandleReaction(react);
}
Example #4
0
NvUIEventResponse NvTweakEnumUI<float>::HandleFocusEvent(NvFocusEvent::Enum evt)
{
    NvUIEventResponse r = INHERITED::HandleFocusEvent(evt);
    if (r&nvuiEventHadReaction)
    {
        NvUIReaction &react = GetReactionEdit(false); // false to not clear it!!!
        react.fval = m_enumval;
    }
    return r;
}
Example #5
0
NvUIEventResponse NvTweakEnumUI<float>::HandleEvent(const NvGestureEvent &ev, NvUST timeUST, NvUIElement *hasInteract)
{
    NvUIEventResponse r = INHERITED::HandleEvent(ev, timeUST, hasInteract);
    if (r&nvuiEventHadReaction)
    {
        NvUIReaction &react = GetReactionEdit(false); // false to not clear it!!!
        react.fval = m_enumval;
    }
    return r;
}
Example #6
0
NvUIEventResponse NvTweakEnumUI<bool>::HandleFocusEvent(NvFocusEvent::Enum evt)
{
    NvUIEventResponse r = INHERITED::HandleFocusEvent(evt);
    if (r&nvuiEventHadReaction)
    {
        NvUIReaction &react = GetReactionEdit(false); // false to not clear it!!!
        // copy to state AND ival, as enums might need in ival.
        react.state = (m_enumval ? 1 : 0);
        react.ival = react.state;
    }
    return r;
}
Example #7
0
NvUIEventResponse NvTweakEnumUI<bool>::HandleEvent(const NvGestureEvent &ev, NvUST timeUST, NvUIElement *hasInteract)
{
    NvUIEventResponse r = INHERITED::HandleEvent(ev, timeUST, hasInteract);
    if (r&nvuiEventHadReaction)
    {
        NvUIReaction &react = GetReactionEdit(false); // false to not clear it!!!
        // copy to state AND ival, as enums might need in ival.
        react.state = (m_enumval ? 1 : 0);
        react.ival = react.state;
    }
    return r;
}
Example #8
0
//======================================================================
//======================================================================
NvUIEventResponse NvUIButton::HandleFocusEvent(NvFocusEvent::Enum evt)
{
    NvUIEventResponse r = nvuiEventNotHandled;
    if (!GetVisibility()) return r;

    // we only handle PRESS focus actions for right now.
    if (evt!=NvFocusEvent::ACT_PRESS) return r;

    uint32_t st = GetDrawState();
    // we don't handle actions if we're inactive.
    if (st == NvUIButtonState::INACTIVE) return r;
    
    if (m_type==NvUIButtonType::CHECK)
    { // then toggle.
        if (st == NvUIButtonState::ACTIVE)
            st = NvUIButtonState::SELECTED;
        else
            st = NvUIButtonState::ACTIVE;
        SetDrawState(st);
    }
    else
    if (m_type==NvUIButtonType::RADIO)
    { // then select THIS radio
        st = NvUIButtonState::SELECTED;
        SetDrawState(st);
    }
    else // push button
    { // fake that we're pushed in...
        st = NvUIButtonState::ACTIVE;
        // but don't set drawstate!
    }

    NvUIReaction &react = GetReactionEdit();
    react.uid = m_uiuid;
    react.code = m_action;
    react.state = st;
    // in case someone is looking for a value for this reaction.
    if (m_type==NvUIButtonType::RADIO)
        react.ival = m_subcode;
    else
        react.ival = react.state; // pass draw state as value.
    react.flags = NvReactFlag::NONE;
    r = nvuiEventHandledInteractReaction;
    VERBOSE_PRINT("}}}}}} prepped reaction\n");

    return r;
}
Example #9
0
NvUIEventResponse NvTweakEnumUI<uint32_t>::HandleReaction(const NvUIReaction& react)
{
    if (react.code && (react.code!=m_tvar.getActionCode()))
        return nvuiEventNotHandled; // not a message for us.

    NvUIEventResponse r = nvuiEventNotHandled;
    
    NvUIReaction &change = GetReactionEdit(false); // false to not clear it!!!        
    // if it's a system|forced update, we assume value changed but button/proxy state needs update.
    if (change.flags & NvReactFlag::FORCE_UPDATE)
    {
        if (m_tvar != m_enumval) 
        { // if tweakvar value is not our enum, set state to 0/inactive
            change.state = 0;
        }
        else 
        { // tweakvar value matches our enum, so set state to 1/active
            change.state = 1;
            // in case someone wants it, fill in our value since we matched the tweakvar value..
            change.ival = m_enumval;
        }
    }
    else if (change.flags & NvReactFlag::CLEAR_STATE)
    {
        change.state = 0; // clear drawstate of all els who match our actioncode.
    }
    // else we leave reaction alone.

    // if we sent ourselves the reaction, we need to let NvTweakVarUI handle...
    if (change.uid==GetUID())
    {
        INHERITED::HandleReaction(change);
    }
    else
    {
        // if we didn't handle self-reactions, then here we need to skip over
        // what NvTweakVarUI would do, go right up to proxybase instead.
        // !!> double INHERITED <!!
        INHERITED::INHERITED::HandleReaction(change);
    }
    return r;
}
Example #10
0
//======================================================================
//======================================================================
NvUIEventResponse NvUIButton::HandleEvent(const NvGestureEvent &gdata, NvUST timeUST, NvUIElement *hasInteract)
{
    bool hit = false;       
    
    if (!m_isVisible
    ||  (GetDrawState()==NvUIButtonState::INACTIVE)
#ifndef BTN_SUPPORTS_HOVER
    ||  (gdata.kind<=NvGestureKind::HOVER)
#else
    ||  (gdata.kind<NvGestureKind::HOVER)
    ||    (gdata.kind==NvGestureKind::HOVER && !m_wantsHover)
#endif
        )
        return nvuiEventNotHandled;
        
    bool possibleSlideTarget = false;
    
    if (gdata.uid == m_reactGestureUID) // then we're done?
    {
        VERBOSE_PRINT("early exit same event UID");
        if (this==hasInteract)
            return nvuiEventHandledInteract;
        else
            return nvuiEventHandled; // since we flagged the triggered UID...
    }

    // check if this is a valid, non-focused/non-active slide-focus target
    if (gdata.kind==NvGestureKind::DRAG    // is a drag/slide going on
    &&  GetSlideInteractGroup()               // we have a focus group ID
    &&  GetSlideInteractGroup() == GetActiveSlideInteractGroup()) // and our ID matches active ID
    {
        if (!m_wasHit       // if we aren't flagged as active/hit
        &&  hasInteract        // focus isn't null (early exit) -- note focus could be a higher container rather than another button.
    //        &&  this!=hasInteract  // aren't the focused element (sorta redundant check)
            )
        {
            possibleSlideTarget = true;
        }
    }
        
    if (!possibleSlideTarget
    &&  gdata.uid == m_failedHitUID)
    {
        VERBOSE_PRINT("early exit failed hit");
        return nvuiEventNotHandled;
    }
        
    // verify we've been hit..
    hit = m_rect.Inside((float)(gdata.x+gdata.dx), (float)(gdata.y+gdata.dy),
                            m_hitMarginWide, m_hitMarginTall);
    //VERBOSE_PRINT("[event 0x%x] hit = %s, focus = 0x%x\n", (unsigned int)(gdata.uid), hit?"yes":"no", (uint32_t)hasInteract);
    
    if (possibleSlideTarget)
    { // use drag dx/dy for hit detection of CURRENT position, not gesture start loc.
        if (!hit)
        {
            m_wasHit = false;
            m_failedHitUID = gdata.uid; // so we don't retest.
            VERBOSE_PRINT("!!!!!> slide target 0x%x not hit\n", (uint32_t)this);
            return nvuiEventNotHandled; // we're done.
        }
        VERBOSE_PRINT("!!!!!> slide target 0x%x hit\n", (uint32_t)this);
        m_wasHit = true;                
        m_failedHitUID = 0; // so we retest.
        SetPrevDrawState(GetDrawState());
        
        // .. anything special here??
        // lostInteract on other element will happen in container above us.
    }
    else
    // !!!!!TBD
    // I'm getting MULTIPLE PRESS EVENTS!!!?!?!
    if (!m_wasHit && gdata.kind==NvGestureKind::PRESS)
    {
        if (!hit)
        {
            m_wasHit = false;
            m_failedHitUID = gdata.uid; // so we don't retest.
            return nvuiEventNotHandled; // we're done.
        }
        m_wasHit = true;                
        VERBOSE_PRINT("!!!!!> not hit -> got hit\n");
        SetPrevDrawState(GetDrawState());
        if (GetDrawState()==0 && GetSlideInteractGroup()) // we set the active group on press.
            SetActiveSlideInteractGroup(GetSlideInteractGroup());
        else
            SetActiveSlideInteractGroup(0);
        if (possibleSlideTarget) // we are now!
        {
            // .. anything special here??
            // lostInteract on other element will happen in container above us.
        }
    }
    else
    if (!m_wasHit)
    {
        VERBOSE_PRINT("!!!!!> not hit -> not hit\n");
#if later
        // if we get here we:
        // weren't a valid slide target
        // weren't getting a press (above)
        // hadn't gotten a press yet (!wasHit)
        // hadn't ignored a press (uid exit would have hit above)
        if (gdata.kind==NV_GESTURE_NONE)
        { // TODO -- I realize, this isn't great code.  trying to get something starter-ish in place.
            // already calc'd hit.
            if (hit)
            {
                if (!m_wasHover)
                    SetDrawState(1);
                return nvuiEventHandledHover;
            }
            else //!hit
            {   
                if (!m_wasHover)
                    SetDrawState(0);
            }            
        }
#endif
        return nvuiEventNotHandled;
    }
    else
    if (m_wasHit && gdata.kind==NvGestureKind::DRAG)
    {
        // we're dragging.  but might not be INSIDE/hit.
        VERBOSE_PRINT("> drag\n");
    }
    else
    if (
    //  gdata.kind==NV_GESTURE_FLICK ||
        gdata.kind&NvGestureKind::MASK_RELEASED) // any release state!!!
    {
        // already calc'd hit.
        VERBOSE_PRINT("!!!!!> got release\n");
    }
    else
    if (m_wasHit || this==hasInteract) // keep focus.
    {
        VERBOSE_PRINT("!!!!!> was hit, keep focus\n");
        return nvuiEventHandledInteract;
    }

    VERBOSE_PRINT("!!!!!> secondary processing...\n");
      
    if (hit)
    {
        VERBOSE_PRINT("}}}} was hit\n");
        if (m_type==NvUIButtonType::CHECK)
        { // !!!!TBD
            if (GetPrevDrawState() == GetDrawState()) // we haven't flipped yet
            {
                if (GetDrawState()==NvUIButtonState::ACTIVE)
                    SetDrawState(NvUIButtonState::SELECTED);
                else
                    SetDrawState(NvUIButtonState::ACTIVE);
            }
        }
        else
            SetDrawState(NvUIButtonState::SELECTED);
    }
    else
    if (!m_stickyClick)
    {
        VERBOSE_PRINT("}}}} not hit\n");
        if (m_type!=NvUIButtonType::PUSH)
        { // !!!!TBD
            //if (m_prevDrawState != m_currDrawState) // we flipped, put BACK
                SetDrawStatePrev();
        }
        else
            SetDrawState(NvUIButtonState::ACTIVE);
    }                
        
    // if we came this far, we're hit.  are we done?
    if (gdata.kind & NvGestureKind::MASK_RELEASED) // we're done?
    {
        VERBOSE_PRINT("}}}} got release !!! !!! !!!! !!! !!!\n");
        NvUIEventResponse r = nvuiEventHandled;

        if (hit) // on the release, what's our curr state??
        {
            VERBOSE_PRINT("}}}}}} hit, any reaction?\n");
            if (gdata.uid != m_reactGestureUID)
            {
                // !!!!TBD if a radio button, we really want to stash the
                // state at PRESSED time, so that we know whether to send
                // an event at all!
                m_reactGestureUID = gdata.uid; // so we don't retrigger.
                
                NvUIReaction &react = GetReactionEdit();
                react.uid = m_uiuid;
                react.code = m_action;
                react.state = GetDrawState();
                // in case someone is looking for a value for this reaction.
                if (m_type==NvUIButtonType::RADIO)
                    react.ival = m_subcode;
                else
                    react.ival = react.state; // pass draw state as value.
                react.flags = NvReactFlag::NONE;
                react.causeKind = gdata.kind;
                react.causeIndex = gdata.index;
                r = nvuiEventHandledInteractReaction; // KEEP FOCUS FOR NOW -- else maybe->tap issues !!!!TBD
                VERBOSE_PRINT("}}}}}} prepped reaction\n");
            }
        }

        // reset draw state if button type is Push
        // AFTER reaction, so we get state correct in the message.
        if (m_type==NvUIButtonType::PUSH)
            SetDrawState(NvUIButtonState::ACTIVE);
        
        m_wasHit = false; // reset!
        return r;
    }        
    
    if (m_wasHit || this==hasInteract) // keep focus.
    {
        NvUIEventResponse r = nvuiEventWantsInteract;
        if (hit) {
            r = nvuiEventHandledInteract;
        } else {
            VERBOSE_PRINT("} keep focus ftm..\n");
        }
        return r;
    }

    return nvuiEventNotHandled;
}