ControlStates RenderTheme::controlStatesForRenderer(const RenderObject* o) const { ControlStates result = 0; if (isHovered(o)) { result |= HoverState; if (isSpinUpButtonPartHovered(o)) result |= SpinUpState; } if (isPressed(o)) { result |= PressedState; if (isSpinUpButtonPartPressed(o)) result |= SpinUpState; } if (isFocused(o) && o->style()->outlineStyleIsAuto()) result |= FocusState; if (isEnabled(o)) result |= EnabledState; if (isChecked(o)) result |= CheckedState; if (isReadOnlyControl(o)) result |= ReadOnlyState; if (!isActive(o)) result |= WindowInactiveState; if (isIndeterminate(o)) result |= IndeterminateState; return result; }
LRESULT CALLBACK GuiClientRetHook(int nCode, WPARAM wParam, LPARAM lParam) { if (nCode == HC_ACTION) { CWPRETSTRUCT* p = (CWPRETSTRUCT*)lParam; CREATESTRUCT* pc = NULL; wchar_t szDbg[200]; szDbg[0] = 0; wchar_t szClass[127]; szClass[0] = 0; switch (p->message) { case WM_DESTROY: { user->getClassNameW(p->hwnd, szClass, countof(szClass)); msprintf(szDbg, countof(szDbg), L"WM_DESTROY on 0x%08X (%s)\n", (DWORD)p->hwnd, szClass); break; } case WM_CREATE: { pc = (CREATESTRUCT*)p->lParam; if (p->lResult == -1) { wcscpy_c(szDbg, L"WM_CREATE --FAILED--\n"); } break; } case WM_SIZE: case WM_MOVE: case WM_WINDOWPOSCHANGED: case WM_WINDOWPOSCHANGING: { WINDOWPOS *wp = (WINDOWPOS*)p->lParam; WORD x = LOWORD(p->lParam); WORD y = HIWORD(p->lParam); if (p->hwnd == ghAttachGuiClient || p->hwnd == hMonitorWndPos) { int nDbg = 0; if (p->message == WM_WINDOWPOSCHANGING || p->message == WM_WINDOWPOSCHANGED) { if ((wp->x > 0 || wp->y > 0) && !isPressed(VK_LBUTTON)) { if (user->getParent(p->hwnd) == ghConEmuWndBack) { //_ASSERTEX(!(wp->x > 0 || wp->y > 0)); break; } } } } break; } } if (*szDbg) { DebugString(szDbg); } } return user->callNextHookEx(ghGuiClientRetHook, nCode, wParam, lParam); }
boolean Button::update(){ // Record the previous and new state of the button boolean _previous_button_state = isPressed(); boolean _new_button_state = _update_button_state(); // Record the new state of the button _is_pressed = _new_button_state; //Serial.println("Button Update"); // If the state of the button has changed if(_previous_button_state != _new_button_state){ // If the button is now pressed if(_new_button_state){ _button_pressed(); } else { // Otherwise if it has just been let go _button_released(); } return true; // State has changed // If the state hasn't changed but the button is pressed - ie it is being held } else if(_new_button_state){ _button_held(); return false; // State hasn't changed } }
unsigned RenderThemeChromiumWin::determineState(RenderObject* o, ControlSubPart subPart) { unsigned result = TS_NORMAL; ControlPart appearance = o->style()->appearance(); if (!isEnabled(o)) result = TS_DISABLED; else if (isReadOnlyControl(o)) result = (appearance == TextFieldPart || appearance == TextAreaPart || appearance == SearchFieldPart) ? ETS_READONLY : TS_DISABLED; // Active overrides hover and focused. else if (isPressed(o) && (subPart == SpinButtonUp) == isSpinUpButtonPartPressed(o)) result = TS_PRESSED; else if (supportsFocus(appearance) && isFocused(o)) result = ETS_FOCUSED; else if (isHovered(o) && (subPart == SpinButtonUp) == isSpinUpButtonPartHovered(o)) result = TS_HOT; // CBS_UNCHECKED*: 1-4 // CBS_CHECKED*: 5-8 // CBS_MIXED*: 9-12 if (isIndeterminate(o)) result += 8; else if (isChecked(o)) result += 4; return result; }
bool isPressedHeld(Controls *c, GameKeyType gkt) { if (!(gkt >= 0 && gkt < gameKeyCount)) return false; const float delay_time = 0.33f; /* secs */ bool axis = false; if (gkt == gameKeyUp) { const axis_state_t *as = &c->hardware.axisY; axis = as->type == AXIS_STATE_OUT_DEAD_ZONE && as->value > 0 && as->time >= delay_time; } if (gkt == gameKeyDown) { const axis_state_t *as = &c->hardware.axisY; axis = as->type == AXIS_STATE_OUT_DEAD_ZONE && as->value < 0 && as->time >= delay_time; } if (gkt == gameKeyRight) { const axis_state_t *as = &c->hardware.axisX; axis = as->type == AXIS_STATE_OUT_DEAD_ZONE && as->value > 0 && as->time >= delay_time; } if (gkt == gameKeyLeft) { const axis_state_t *as = &c->hardware.axisX; axis = as->type == AXIS_STATE_OUT_DEAD_ZONE && as->value < 0 && as->time >= delay_time; } const key_state_t *ks = &c->hardware.key[c->game.key[gkt]]; return isPressed(c, gkt) || (ks->type == KEY_STATE_HELD && ks->time >= delay_time) || axis; }
bool UIWidget::propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton button) { // do a backup of children list, because it may change while looping it UIWidgetList children; for(const UIWidgetPtr& child : m_children) { // events on hidden or disabled widgets are discarded if(!child->isExplicitlyEnabled() || !child->isExplicitlyVisible()) continue; // mouse release events go to all children children.push_back(child); } for(const UIWidgetPtr& child : children) { if(child->propagateOnMouseRelease(mousePos, button)) return true; } bool ret = onMouseRelease(mousePos, button); if(isPressed() && button == Fw::MouseLeftButton) setPressed(false); return ret; }
void MMSLabelWidget::getForeground(MMSFBColor *color) { color->a = 0; if (isActivated()) { if (isSelected()) { *color = getSelColor(); } else { *color = getColor(); } if (isPressed()) { MMSFBColor mycol; if (isSelected()) { mycol = getSelColor_p(); if (mycol.a>0) *color=mycol; } else { mycol = getColor_p(); if (mycol.a>0) *color=mycol; } } } else { if (isSelected()) { *color = getSelColor_i(); } else { *color = getColor_i(); } } }
bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* cancelButtonObject, const PaintInfo& paintInfo, const IntRect& r) { // Get the renderer of <input> element. Node* input = cancelButtonObject->node()->shadowHost(); RenderObject* baseRenderer = input ? input->renderer() : cancelButtonObject; if (!baseRenderer->isBox()) return false; RenderBox* inputRenderBox = toRenderBox(baseRenderer); LayoutRect inputContentBox = inputRenderBox->contentBoxRect(); // Make sure the scaled button stays square and will fit in its parent's box. LayoutUnit cancelButtonSize = std::min(inputContentBox.width(), std::min<LayoutUnit>(inputContentBox.height(), r.height())); // Calculate cancel button's coordinates relative to the input element. // Center the button vertically. Round up though, so if it has to be one pixel off-center, it will // be one pixel closer to the bottom of the field. This tends to look better with the text. LayoutRect cancelButtonRect(cancelButtonObject->offsetFromAncestorContainer(inputRenderBox).width(), inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1) / 2, cancelButtonSize, cancelButtonSize); IntRect paintingRect = convertToPaintingRect(inputRenderBox, cancelButtonObject, cancelButtonRect, r); static Image* cancelImage = Image::loadPlatformResource("searchCancel").leakRef(); static Image* cancelPressedImage = Image::loadPlatformResource("searchCancelPressed").leakRef(); paintInfo.context->drawImage(isPressed(cancelButtonObject) ? cancelPressedImage : cancelImage, cancelButtonObject->style()->colorSpace(), paintingRect); return false; }
ControlStates::States RenderTheme::extractControlStatesForRenderer(const RenderObject& o) const { ControlStates::States states = 0; if (isHovered(o)) { states |= ControlStates::HoverState; if (isSpinUpButtonPartHovered(o)) states |= ControlStates::SpinUpState; } if (isPressed(o)) { states |= ControlStates::PressedState; if (isSpinUpButtonPartPressed(o)) states |= ControlStates::SpinUpState; } if (isFocused(o) && o.style().outlineStyleIsAuto()) states |= ControlStates::FocusState; if (isEnabled(o)) states |= ControlStates::EnabledState; if (isChecked(o)) states |= ControlStates::CheckedState; if (isDefault(o)) states |= ControlStates::DefaultState; if (!isActive(o)) states |= ControlStates::WindowInactiveState; if (isIndeterminate(o)) states |= ControlStates::IndeterminateState; return states; }
bool RenderThemeWx::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { wxWindow* window = o->view()->frameView()->nativeWindow(); wxDC* dc = static_cast<wxDC*>(i.context->platformContext()); wxASSERT(dc->IsOk()); int flags = 0; if (!isEnabled(o)) flags |= wxCONTROL_DISABLED; EAppearance appearance = o->style()->appearance(); if (supportsFocus(o->style()->appearance()) && isFocused(o)) flags |= wxCONTROL_FOCUSED; if (isPressed(o)) flags |= wxCONTROL_PRESSED; if (appearance == PushButtonAppearance || appearance == ButtonAppearance) wxRendererNative::Get().DrawPushButton(window, *dc, r, flags); // TODO: add a radio button rendering API to wx //else if(appearance == RadioAppearance) else if(appearance == CheckboxAppearance) { if (isChecked(o)) flags |= wxCONTROL_CHECKED; wxRendererNative::Get().DrawCheckBox(window, *dc, r, flags); } return false; }
bool RenderThemeWx::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { wxScrolledWindow* window = o->view()->frameView()->nativeWindow(); wxPaintDC dc((wxWindow*)window); window->DoPrepareDC(dc); int flags = 0; if (!isEnabled(o)) flags |= wxCONTROL_DISABLED; EAppearance appearance = o->style()->appearance(); if (supportsFocus(o->style()->appearance()) && isFocused(o)) flags |= wxCONTROL_FOCUSED; if (isPressed(o)) flags |= wxCONTROL_PRESSED; if(appearance == PushButtonAppearance || appearance == ButtonAppearance) wxRendererNative::Get().DrawPushButton(window, dc, r, flags); // TODO: add a radio button rendering API to wx //else if(appearance == RadioAppearance) // wxRendererNative::Get(). else if(appearance == CheckboxAppearance) wxRendererNative::Get().DrawCheckBox(window, dc, r, flags); return false; }
bool Accelerator::isLooselyPressed() const { os::System* sys = os::instance(); if (!sys) return false; KeyModifiers pressedModifiers = sys->keyModifiers(); if ((m_modifiers & pressedModifiers) != m_modifiers) return false; // Check if this shortcut is only if (m_scancode == kKeyNil && m_unicodeChar == 0) return true; // Compare with all pressed scancodes for (int s=int(kKeyNil); s<int(kKeyFirstModifierScancode); ++s) { if (sys->isKeyPressed(KeyScancode(s)) && isPressed(m_modifiers, // Use same modifiers (we've already compared the modifiers) KeyScancode(s), sys->getUnicodeFromScancode(KeyScancode(s)))) return true; } return false; }
void CConEmuCtrl::SkipOneAppsRelease(bool abSkip) { if (abSkip) { if (isPressed(VK_APPS)) { // Игнорировать одно следующее VK_APPS mb_SkipOneAppsRelease = true; if (!mh_SkipOneAppsRelease) mh_SkipOneAppsRelease = SetWindowsHookEx(WH_GETMESSAGE, SkipOneAppsReleaseHook, NULL, GetCurrentThreadId()); DEBUGSTRAPPS(mh_SkipOneAppsRelease ? L"CConEmuCtrl::SkipOneAppsRelease set was succeeded\n" : L"CConEmuCtrl::SkipOneAppsRelease FAILED\n"); } else { abSkip = false; DEBUGSTRAPPS(L"CConEmuCtrl::SkipOneAppsRelease ignored, VK_APPS not pressed\n"); } } if (!abSkip) { if (mh_SkipOneAppsRelease) { UnhookWindowsHookEx(mh_SkipOneAppsRelease); mh_SkipOneAppsRelease = NULL; mb_SkipOneAppsRelease = false; DEBUGSTRAPPS(L"CConEmuCtrl::SkipOneAppsRelease was unhooked\n"); } } }
bool RenderThemeChromiumDefault::paintSliderThumb(RenderObject* o, const PaintInfo& i, const IntRect& rect) { if (i.context->paintingDisabled()) return false; blink::WebThemeEngine::ExtraParams extraParams; blink::WebCanvas* canvas = i.context->canvas(); extraParams.slider.vertical = o->style()->appearance() == SliderThumbVerticalPart; extraParams.slider.inDrag = isPressed(o); // FIXME: Mock theme doesn't handle zoomed sliders. float zoomLevel = useMockTheme() ? 1 : o->style()->effectiveZoom(); GraphicsContextStateSaver stateSaver(*i.context, false); IntRect unzoomedRect = rect; if (zoomLevel != 1) { stateSaver.save(); unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); i.context->translate(unzoomedRect.x(), unzoomedRect.y()); i.context->scale(zoomLevel, zoomLevel); i.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); } blink::Platform::current()->themeEngine()->paint(canvas, blink::WebThemeEngine::PartSliderThumb, getWebThemeState(this, o), blink::WebRect(unzoomedRect), &extraParams); return false; }
bool RenderThemeWx::paintMenuList(RenderObject* o, const PaintInfo& i, const IntRect& r) { wxWindow* window = nativeWindowForRenderObject(o); wxDC* dc = static_cast<wxDC*>(i.context->platformContext()); LocalDC localDC(dc, r); IntRect rect = r; int flags = 0; if (!isEnabled(o)) flags |= wxCONTROL_DISABLED; if (supportsFocus(o->style()->appearance()) && isFocused(o)) flags |= wxCONTROL_FOCUSED; if (isPressed(o)) flags |= wxCONTROL_PRESSED; #if wxCHECK_VERSION(2,9,0) wxRendererNative::Get().DrawChoice(window, *localDC.context(), rect, flags); #else wxRenderer_DrawChoice(window, *localDC.context(), rect, flags); #endif return false; }
ControlStates LayoutTheme::controlStatesForLayoutObject(const LayoutObject& o) { ControlStates result = 0; if (isHovered(o)) { result |= HoverControlState; if (isSpinUpButtonPartHovered(o)) result |= SpinUpControlState; } if (isPressed(o)) { result |= PressedControlState; if (isSpinUpButtonPartPressed(o)) result |= SpinUpControlState; } if (isFocused(o) && o.style()->outlineStyleIsAuto()) result |= FocusControlState; if (isEnabled(o)) result |= EnabledControlState; if (isChecked(o)) result |= CheckedControlState; if (isReadOnlyControl(o)) result |= ReadOnlyControlState; if (!isActive(o)) result |= WindowInactiveControlState; if (isIndeterminate(o)) result |= IndeterminateControlState; return result; }
McoStatus DisplayDialog::DoEvents(short item, Point clickPoint, WindowCode *wc, int32 *numwc, void **data, Boolean &changed) { UserItemUPP myfilter; Str255 theString; short itemtype; Handle cn1,sliderControl; Rect r; short part; Point mpoint; int32 next_patch; McoStatus status; WindowPtr oldp; int32 temp; double m=1; GetPort(&oldp); SetPort(dp); Changed = FALSE; *numwc = 0; status = MCO_SUCCESS; if (isPressed(0x38)) m = 10; if (item != -1) { if (item == ids[Slider]) // the slider has been adjusted { GetMouse(&mpoint); do { current_patch = GetSlider(mpoint,ids[Slider]); ShowPatchScroll(current_patch); SetSheetStripText(); current_sheet = current_patch/(patch_per_strip*strip_per_sheet); current_strip = (current_patch - current_sheet*(patch_per_strip*strip_per_sheet))/patch_per_strip; GetMouse(&mpoint); } while ( StillDown ( ) ); checkError((current_patch/patch_per_strip)*patch_per_strip); //_waiting = 0; Enable(dp,ids[Redo]); SetSheetStripText(); } else if (item == ids[Strip_Rect]) { GlobalToLocal(&clickPoint); temp = whichPatch(clickPoint); if (temp != -1) { current_patch = temp; current_disp = current_patch-current_top; GetDItem ( dp, ids[Slider], &itemtype, (Handle*)&sliderControl, &r ); SetCtlValue ( (ControlHandle)sliderControl,current_patch); ShowPatch(current_patch); SetSheetStripText(); } } } SetPort(oldp); return status; }
void InputManager::update() { updateJoystick(); // for(list<Button*>::iterator i=buffer.begin(); // i!=buffer.end(); // i++) // cout<<(*i)->value; // cout<<endl; // cout.flush(); const Uint8* currentKeyStates = SDL_GetKeyboardState( NULL ); bool is_button_pressed = false; for(int i=0;i<possible_buttons.size();i++) { if(isPressed(possible_buttons[i])) { buffer.push_back(new Button(possible_buttons[i])); buffer.pop_front(); is_button_pressed=true; break; } } for(map<char,int>::iterator i=joystick_map.begin(); i!=joystick_map.end(); i++) { if(isJoyDown((*i).second,0)) { buffer.push_back(new Button((*i).first)); is_button_pressed=true; } } // if(isJoyDown(0,0)) // { // buffer.push_back(new Button('a')); // is_button_pressed=true; // } // // if(isJoyDown(-4,0)) // { // buffer.push_back(new Button('4')); // is_button_pressed=true; // } // // if(isJoyDown(-6,0)) // { // buffer.push_back(new Button('6')); // is_button_pressed=true; // } if(!is_button_pressed) { buffer.push_back(new Button('5')); buffer.pop_front(); } }
/* || @description || | Polling model for holding, this is true every check after hold time || | Check to see if the button has been pressed for time ms || # */ bool Button::heldFor(unsigned int time) { if (isPressed()) { if (millis()-pressedStartTime > time) { return true; } } return false; }
/** * Returns the state of the button * BUTTON_MONITOR_NOT_PRESSED 0 * BUTTON_MONITOR_DEPRESSED 1 * BUTTON_MONITOR_PRESSED 2 * BUTTON_MONITOR_REPEATING 3 * BUTTON_MONITOR_FAST_REPEATING 4 * BUTTON_MONITOR_RELEASED 5 */ uint8_t NIButtonMonitor::getState(uint8_t buttonId) { if (isDepressed(buttonId)) return BUTTON_MONITOR_DEPRESSED; if (isReleased(buttonId)) return BUTTON_MONITOR_RELEASED; if (isFastRepeating(buttonId)) return BUTTON_MONITOR_FAST_REPEATING; if (isRepeating(buttonId)) return BUTTON_MONITOR_REPEATING; if (isPressed(buttonId)) return BUTTON_MONITOR_PRESSED; return BUTTON_MONITOR_NOT_PRESSED; }
void RfbKeySym::restoreModifier(unsigned char modifier) { UINT32 rfbSym; if (isPressed(modifier)) { bool success = m_keyMap.virtualCodeToKeySym(&rfbSym, modifier); _ASSERT(success); sendKeySymEvent(rfbSym, true); } }
bool RenderThemeChromiumLinux::paintSliderThumb(RenderObject* o, const PaintInfo& i, const IntRect& rect) { PlatformSupport::ThemePaintExtraParams extraParams; extraParams.slider.vertical = o->style()->appearance() == SliderThumbVerticalPart; extraParams.slider.inDrag = isPressed(o); PlatformSupport::paintThemePart(i.context, PlatformSupport::PartSliderThumb, getWebThemeState(this, o), rect, &extraParams); return false; }
EAppearance RenderThemeQt::applyTheme(QStyleOption& option, RenderObject* o) const { // Default bits: no focus, no mouse over option.state &= ~(QStyle::State_HasFocus | QStyle::State_MouseOver); if (!isEnabled(o)) option.state &= ~QStyle::State_Enabled; if (isReadOnlyControl(o)) // Readonly is supported on textfields. option.state |= QStyle::State_ReadOnly; if (supportsFocus(o->style()->appearance()) && isFocused(o)) option.state |= QStyle::State_HasFocus; if (isHovered(o)) option.state |= QStyle::State_MouseOver; EAppearance result = o->style()->appearance(); switch (result) { case PushButtonAppearance: case SquareButtonAppearance: case ButtonAppearance: case ButtonBevelAppearance: case ListItemAppearance: case MenulistButtonAppearance: case ScrollbarButtonLeftAppearance: case ScrollbarButtonRightAppearance: case ScrollbarTrackHorizontalAppearance: case ScrollbarTrackVerticalAppearance: case ScrollbarThumbHorizontalAppearance: case ScrollbarThumbVerticalAppearance: case SearchFieldResultsButtonAppearance: case SearchFieldCancelButtonAppearance: { if (isPressed(o)) option.state |= QStyle::State_Sunken; else if (result == PushButtonAppearance) option.state |= QStyle::State_Raised; break; } } if(result == RadioAppearance || result == CheckboxAppearance) option.state |= (isChecked(o) ? QStyle::State_On : QStyle::State_Off); // If the webview has a custom palette, use it Page *page = o->document()->page(); if (page) { QWidget *view = static_cast<ChromeClientQt*>(page->chrome()->client())->m_webPage->view(); if (view) option.palette = view->palette(); } return result; }
bool RenderThemeGtk::paintMenuList(RenderObject* object, const PaintInfo& info, const IntRect& rect) { if (paintButton(object, info, rect)) return true; // Menu list button painting strategy. // For buttons with appears-as-list set to false (having a separator): // | left border | Button text | xthickness | vseparator | xthickness | arrow | xthickness | right border | // For buttons with appears-as-list set to true (not having a separator): // | left border | Button text | arrow | xthickness | right border | int leftBorder = 0, rightBorder = 0, bottomBorder = 0, topBorder = 0; getButtonInnerBorder(gtkComboBoxButton(), leftBorder, topBorder, rightBorder, bottomBorder); RenderStyle* style = &object->style(); int arrowSize = comboBoxArrowSize(style); GtkStyle* buttonStyle = gtk_widget_get_style(gtkComboBoxButton()); IntRect arrowRect(0, (rect.height() - arrowSize) / 2, arrowSize, arrowSize); if (style->direction() == RTL) arrowRect.setX(leftBorder + buttonStyle->xthickness); else arrowRect.setX(rect.width() - rightBorder - buttonStyle->xthickness - arrowSize); GtkShadowType shadowType = isPressed(object) ? GTK_SHADOW_IN : GTK_SHADOW_OUT; WidgetRenderingContext widgetContext(info.context, rect); GtkStateType stateType = getGtkStateType(this, object); widgetContext.gtkPaintArrow(arrowRect, gtkComboBoxArrow(), stateType, shadowType, GTK_ARROW_DOWN, "arrow"); // Some combo boxes do not have a separator. GtkWidget* separator = gtkComboBoxSeparator(); if (!separator) return false; // We want to decrease the height of the separator based on the focus padding of the button. gint focusPadding = 0, focusWidth = 0; gtk_widget_style_get(gtkComboBoxButton(), "focus-line-width", &focusWidth, "focus-padding", &focusPadding, NULL); topBorder += focusPadding + focusWidth; bottomBorder += focusPadding + focusWidth; int separatorWidth = getComboBoxSeparatorWidth(); IntRect separatorRect(0, topBorder, separatorWidth, rect.height() - topBorder - bottomBorder); if (style->direction() == RTL) separatorRect.setX(arrowRect.x() + arrowRect.width() + buttonStyle->xthickness + separatorWidth); else separatorRect.setX(arrowRect.x() - buttonStyle->xthickness - separatorWidth); gboolean hasWideSeparators = FALSE; gtk_widget_style_get(separator, "wide-separators", &hasWideSeparators, NULL); if (hasWideSeparators) widgetContext.gtkPaintBox(separatorRect, separator, GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT, "vseparator"); else widgetContext.gtkPaintVLine(separatorRect, separator, GTK_STATE_NORMAL, "vseparator"); return false; }
void blink(void){ { switch(s) { case R: if(isPressed()) period = 0; if (period >0){ P1OUT &= LED1; P1OUT &= ~LED2; period--; } else{ period = REDANDGREEN; s = RGR; } break; case RGR: if (period >0){ P1OUT |= LED1; P1OUT |= LED2; period--; } else{ period = GREENTIME; s = G; } break; case G: if (period >0){ P1OUT &= ~LED1; // Toggle P1.0 using exclusive-OR P1OUT &= LED2; period--; } else{ period = REDANDGREEN; s = GRG; } break; case GRG: if (period >0){ P1OUT |= LED1; P1OUT |= LED2; period--; } else{ period = REDTIME; s = R; } break; } } }
GtkStateType RenderThemeGtk::getGtkStateType(RenderObject* object) { if (!isEnabled(object) || isReadOnlyControl(object)) return GTK_STATE_INSENSITIVE; if (isPressed(object)) return GTK_STATE_ACTIVE; if (isHovered(object)) return GTK_STATE_PRELIGHT; return GTK_STATE_NORMAL; }
virtual bool mouseMoved(int oldX, int oldY, int newX, int newY) override { if(isPressed() && r_parent != nullptr) { r_parent->setLocalBounds( r_parent->getLocalBounds().offset(newX-oldX, newY-oldY)); return true; } return AWidget::mouseMoved(oldX, oldY, newX, newY); }
bool UIWidget::onMouseMove(const Point& mousePos, const Point& mouseMoved) { if(isDragable() && isPressed() && !m_dragging && !g_ui.getDraggingWidget()) { setDragging(true); g_ui.setDraggingWidget(asUIWidget()); onDragEnter(mousePos - mouseMoved); } return callLuaField<bool>("onMouseMove", mousePos, mouseMoved); }
void Button::press(){ this->pressed = !isPressed(); if(pressed){ setFrameRect(getCurrentFrame() + 1); } else{ setFrameRect(getCurrentFrame() - 1); } }
void Character::shieldScript() { switch (shieldState) { case Character::release: if (isPressed("s1")) shieldState = Character::under; break; case Character::under: if (isPressed("s1")) { auto state = getAnimation("block").updateInRange(allModels, getAnimation("block").getSpeed()); if (!state) { shieldState = Character::awaiting; } } else shieldState = Character::returns; break; case Character::awaiting: if (isPressed("s1")) { //gen.addParticle("particleTest.txt", 1, 1); } else shieldState = Character::returns; break; case Character::returns: if (!isPressed("s1")) { auto state = getAnimation("block").updateInRange(allModels, -getAnimation("block").getSpeed()); if (!state) shieldState = Character::release; } else shieldState = Character::under; break; } }