Component* Button::updateFocus(int direction, int buttonsPressed) { Component* newFocus = NULL; if(!getFocus() && active) { setFocus(true); newFocus = this; } else if (!getFocus() && !active) { //try to move direction, and if new component found send to focus manager and remove focus for current component if (getNextFocus(direction)) newFocus = (getNextFocus(direction))->updateFocus(direction, buttonsPressed); else newFocus = getNextFocus(direction); } else { if (getNextFocus(direction)) newFocus = (getNextFocus(direction))->updateFocus(direction, buttonsPressed); if (newFocus) setFocus(false); else newFocus = this; } if (newFocus == this) { //finally update button behavior based on buttons pressed if(buttonsPressed & Focus::ACTION_BACK) doReturn(); else if (buttonsPressed & Focus::ACTION_SELECT) doClicked(); } return newFocus; }
void Ui::deleteLater( Widget* ptrElement ) { try { if( !ptrElement || !isMyChild( ptrElement ) ) { return; } if( ptrElement == getFocus() || ptrElement->isMyChild( getFocus() ) ) { _d->focusedElement = WidgetPtr(); } if( _d->hovered.current.object() == ptrElement || ptrElement->isMyChild( _d->hovered.current.object() ) ) { _d->hovered.current = WidgetPtr(); _d->hovered.noSubelement = WidgetPtr(); } for( auto widget : _d->deletionQueue ) { if( widget == ptrElement ) { return; } } _d->deletionQueue.push_back( ptrElement ); } catch(...) {} }
/*---------------------------------------------------------------------*//** フォーカスメニューを開く **//*---------------------------------------------------------------------*/ void FocusCursor::showFocusMenu(Unit* unit, const Vector2F* vScrPos) { const s32 MTNODEID_DROPITEM_FOCUS = 21001; const s32 MTNODEID_ENEMY_FOCUS = 22001; const s32 MTNODEID_EXTRA_FOCUS = 23001; const s32 MTNODEID_EXTRA_CHECK = 23002; const s32 MTNODEID_MAPOBJ_FOCUS = 24001; const s32 MTNODEID_MAPOBJ_CHECK = 24002; // メニュー種別と準備 FocusMenu::MenuKind mkind = FocusMenu::NUM_MENU; if(unit->getUnitType() == UNITTYPE_ENEMY_CHAR) { mkind = FocusMenu::MENU_ENEMY; // フォーカス _fcmenuRef->setMenuElementEnable(mkind, MTNODEID_ENEMY_FOCUS, getFocus(0) != unit); } else if(unit->getUnitType() == UNITTYPE_EXTRA_CHAR) { mkind = FocusMenu::MENU_EXTRA; // フォーカス _fcmenuRef->setMenuElementEnable(mkind, MTNODEID_EXTRA_FOCUS, getFocus(0) != unit); } else if(unit->getUnitType() == UNITTYPE_MAPOBJ) { mkind = FocusMenu::MENU_MAPOBJ; // フォーカス _fcmenuRef->setMenuElementEnable(mkind, MTNODEID_MAPOBJ_FOCUS, getFocus(0) != unit); // チェック bool isEnableCheck = false; if((unit != 0L) && TFW_IS_FLAG(unit->getUnitFlags(), Unit::UNITFLAG_NPC)) { const PlacementObj* pobj = ((NpcCharUnit*)unit)->getPlacementObj(); const EventIdInfoArray::EventIdInfo* cii = pobj->getCallEvi()->getInfo(pobj->getActiveCallEviIndex()); if(cii != 0L) { isEnableCheck = true; } } _fcmenuRef->setMenuElementEnable(mkind, MTNODEID_MAPOBJ_CHECK, isEnableCheck); } else if(unit->getUnitType() == UNITTYPE_PUT_ITEM) { mkind = FocusMenu::MENU_DROPITEM; // フォーカス _fcmenuRef->setMenuElementEnable(mkind, MTNODEID_DROPITEM_FOCUS, getFocus(0) != unit); } // メニューを開く if(mkind != FocusMenu::NUM_MENU) { PointF32 pt(vScrPos->x(), vScrPos->y()); _fcmenuRef->showMenu(mkind, &pt, unit, true); } }
void KFocusConfig::updateActiveMouseScreen() { // on by default for non click to focus policies KConfigGroup cfg(config, "Windows"); if (!cfg.hasKey(KWIN_ACTIVE_MOUSE_SCREEN)) setActiveMouseScreen(getFocus() != 0); }
bool Menu::MoveFocus(eFlyDirection eDir) { ViewNode* pNode = FocusMovePath::getNextFocusNode_AA(getViewNodeList(), getViewNodeNum(),getFocus()->getMinIndex(),eDir,_MENU_COLNUM_); return pNode?setFocus(pNode):false; }
string BZStageCommon::status() { string ret = ""; if (!_debug_info) return ret; ret += "game:"; char sz[1024]; sprintf(sz, "fps:%.1f;", this->fps()); //ret += sz; #if defined(_DEBUG) char szMem[128]; unsigned int alloced = gGetMemSizeAlloced(); unsigned int maxalloced = gGetMemMaxSizeAlloced(); sprintf(szMem, " mem:%d/%d", alloced, maxalloced); strcat(sz, szMem); #endif ret += sz; ret += "\n"; CAStageLayer* player = getFocus(); if (null != player) { ret += player->_sprite_container_debug_log(player->name().c_str(), false); ret += player->debuglog(); } return ret; }
TabbedWebView::TabbedWebView(QupZilla* mainClass, WebTab* webTab) : WebView(webTab) , p_QupZilla(mainClass) , m_tabWidget(p_QupZilla->tabWidget()) , m_page(0) , m_webTab(webTab) , m_menu(new Menu(this)) , m_mouseTrack(false) , m_navigationVisible(false) , m_hasRss(false) , m_rssChecked(false) { connect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted())); connect(this, SIGNAL(loadProgress(int)), this, SLOT(loadingProgress(int))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished())); connect(this, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl))); connect(this, SIGNAL(titleChanged(QString)), this, SLOT(titleChanged())); connect(this, SIGNAL(iconChanged()), this, SLOT(slotIconChanged())); connect(this, SIGNAL(statusBarMessage(QString)), p_QupZilla->statusBar(), SLOT(showMessage(QString))); connect(mApp->networkManager(), SIGNAL(wantsFocus(QUrl)), this, SLOT(getFocus(QUrl))); connect(p_QupZilla, SIGNAL(setWebViewMouseTracking(bool)), this, SLOT(trackMouse(bool))); // Tracking mouse also on tabs created in fullscreen trackMouse(p_QupZilla->isFullScreen()); }
void KFocusConfig::setDelayFocusEnabled() { int policyIndex = getFocus(); // the delayed focus related widgets are: delayFocus m_ui->delayFocusOnLabel->setEnabled(policyIndex != CLICK_TO_FOCUS); delayFocusOnTog(policyIndex != CLICK_TO_FOCUS); }
void KFocusConfig::save( void ) { int v; KConfigGroup cg(config, "Windows"); v = getFocus(); if (v == CLICK_TO_FOCUS) cg.writeEntry(KWIN_FOCUS,"ClickToFocus"); else if (v == FOCUS_UNDER_MOUSE) cg.writeEntry(KWIN_FOCUS,"FocusUnderMouse"); else if (v == FOCUS_STRICTLY_UNDER_MOUSE) cg.writeEntry(KWIN_FOCUS,"FocusStrictlyUnderMouse"); else cg.writeEntry(KWIN_FOCUS,"FocusFollowsMouse"); v = getAutoRaiseInterval(); if (v <0) v = 0; cg.writeEntry(KWIN_AUTORAISE_INTERVAL,v); v = getDelayFocusInterval(); if (v <0) v = 0; cg.writeEntry(KWIN_DELAYFOCUS_INTERVAL,v); cg.writeEntry(KWIN_AUTORAISE, autoRaiseOn->isChecked()); cg.writeEntry(KWIN_DELAYFOCUS, delayFocusOn->isChecked()); cg.writeEntry(KWIN_CLICKRAISE, clickRaiseOn->isChecked()); cg.writeEntry(KWIN_SEPARATE_SCREEN_FOCUS, separateScreenFocus->isChecked()); cg.writeEntry(KWIN_ACTIVE_MOUSE_SCREEN, activeMouseScreen->isChecked()); if (altTabPopup->isChecked()) cg.writeEntry(KWIN_ALTTABMODE, "KDE"); else cg.writeEntry(KWIN_ALTTABMODE, "CDE"); cg.writeEntry( KWIN_ROLL_OVER_DESKTOPS, rollOverDesktops->isChecked()); config->group("PopupInfo").writeEntry( KWIN_SHOW_POPUP, showPopupinfo->isChecked()); config->group("TabBox").writeEntry( KWIN_TRAVERSE_ALL , traverseAll->isChecked()); cg.writeEntry(KWIN_FOCUS_STEALING, focusStealing->currentIndex()); if (standAlone) { config->sync(); // Send signal to all kwin instances QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); QDBusConnection::sessionBus().send(message); } emit KCModule::changed(false); }
void lcl_OnyxLineEdit::mouseReleaseEvent(QMouseEvent * event) { event->accept(); emit getFocus(this); emit setCheckByMouse(this); QKeyEvent key_event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "virtual"); QApplication::sendEvent(this, &key_event); }
Camera::Camera(const Camera& cam) : position_(cam.getPosition()), focus_(cam.getFocus()), upVector_(cam.getUpVector()), frust_(cam.getFrustum()), projectionMode_(cam.getProjectionMode()) { viewMatrix_ = glm::lookAt(getPosition(), getFocus(), upVector_); }
void Panel::keyDown(const WORD code, const CHAR chr){ try{ switch (code) { case VK_UP:{ EventEngine::moveFocusBackword(*this,getFocus()); break; } case VK_DOWN:{ EventEngine::moveFocusForword(*this, getFocus()); break; } default:{ for (auto it = focusVec.begin() ; it != focusVec.end() ; ++it){ if ((*it) == getFocus()){ (*it)->keyDown(code, chr); break; } } break; } } } catch (exception& e) { perror("undefined key"); } }
void Panel::mousePressed(const int x, const int y, const bool isLeft){ if (isLeft){ for (auto it = children.begin(); it != children.end(); ++it){ int X = x - (*it)->getLeft(); int Y = y - (*it)->getTop(); if (X >= 0 && Y >= 0 && X < (*it)->getWidth() && Y < (*it)->getHeight() && (*it)->getLayer() ==getFocus()->getLayer()){ if ((*it)->canGetFocus()) setFocus(**it); (*it)->mousePressed(X, Y, isLeft); break; } } } }
void KFocusConfig::focusPolicyChanged() { int policyIndex = getFocus(); // the auto raise related widgets are: autoRaise m_ui->autoRaiseOn->setEnabled(policyIndex != CLICK_TO_FOCUS); autoRaiseOnTog(policyIndex != CLICK_TO_FOCUS && m_ui->autoRaiseOn->isChecked()); m_ui->focusStealing->setDisabled(policyIndex == FOCUS_UNDER_MOUSE || policyIndex == FOCUS_STRICTLY_UNDER_MOUSE); m_ui->focusStealingLabel->setEnabled(m_ui->focusStealing->isEnabled()); setDelayFocusEnabled(); }
void Panel::draw(Graphics& graphics, const int left, const int top, const size_t p){ Control::draw(graphics, left, top, p); if(focusVec.empty()) getAllControls(&focusVec); for (auto it = children.begin(); it != children.end(); ++it){ if((*it)->isVisible() && (*it)->get_layer()==p) (*it)->draw(graphics, left+(this->getLeft()), top+(this->getTop()), p); else{ graphics.setBackground(); graphics.setForeground(); } } auto textbox = dynamic_cast<TextBox*>(getFocus()); if (textbox) textbox->set_cursor(graphics, left, top); }
// ---------------------------------------------------------------------------- // ArchiveEntryList::getFocusedEntry // // Gets the archive entry associated with the currently focused list item. // Returns NULL if nothing is focused or no archive is open // ---------------------------------------------------------------------------- ArchiveEntry* ArchiveEntryList::getFocusedEntry() { // Get the focus index int focus = getFocus(); // Check that the focus index is valid if (focus < 0 || focus > GetItemCount()) return nullptr; // Return the focused archive entry if (archive) return getEntry(focus); else return nullptr; }
void KFocusConfig::save(void) { int v; KConfigGroup cg(config, "Windows"); v = getFocus(); if (v == CLICK_TO_FOCUS) cg.writeEntry(KWIN_FOCUS, "ClickToFocus"); else if (v == FOCUS_UNDER_MOUSE) cg.writeEntry(KWIN_FOCUS, "FocusUnderMouse"); else if (v == FOCUS_STRICTLY_UNDER_MOUSE) cg.writeEntry(KWIN_FOCUS, "FocusStrictlyUnderMouse"); else cg.writeEntry(KWIN_FOCUS, "FocusFollowsMouse"); cg.writeEntry("NextFocusPrefersMouse", v != m_ui->windowFocusPolicy->value()); v = getAutoRaiseInterval(); if (v < 0) v = 0; cg.writeEntry(KWIN_AUTORAISE_INTERVAL, v); v = getDelayFocusInterval(); if (v < 0) v = 0; cg.writeEntry(KWIN_DELAYFOCUS_INTERVAL, v); cg.writeEntry(KWIN_AUTORAISE, m_ui->autoRaiseOn->isChecked()); cg.writeEntry(KWIN_CLICKRAISE, m_ui->clickRaiseOn->isChecked()); cg.writeEntry(KWIN_SEPARATE_SCREEN_FOCUS, m_ui->separateScreenFocus->isChecked()); cg.writeEntry(KWIN_ACTIVE_MOUSE_SCREEN, m_ui->activeMouseScreen->isChecked()); cg.writeEntry(KWIN_FOCUS_STEALING, m_ui->focusStealing->currentIndex()); cg.writeEntry(KWIN_SEPARATE_SCREEN_FOCUS, m_ui->separateScreenFocus->isChecked()); cg.writeEntry(KWIN_ACTIVE_MOUSE_SCREEN, m_ui->activeMouseScreen->isChecked()); if (standAlone) { config->sync(); // Send signal to all kwin instances QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); QDBusConnection::sessionBus().send(message); } emit KCModule::changed(false); }
void KFocusConfig::defaults() { setAutoRaiseInterval(0); setDelayFocusInterval(0); setFocus(CLICK_TO_FOCUS); setAutoRaise(false); setClickRaise(true); setSeparateScreenFocus(false); // setFocusStealing(2); // TODO default to low for now setFocusStealing(1); // on by default for non click to focus policies setActiveMouseScreen(getFocus() != 0); setDelayFocusEnabled(); emit KCModule::changed(true); }
void KFocusConfig::load(void) { QString key; KConfigGroup cg(config, "Windows"); const bool focusNextToMouse = cg.readEntry("NextFocusPrefersMouse", false); key = cg.readEntry(KWIN_FOCUS); if (key == "ClickToFocus") setFocus(CLICK_TO_FOCUS + focusNextToMouse); else if (key == "FocusFollowsMouse") setFocus(FOCUS_FOLLOWS_MOUSE + focusNextToMouse); else if (key == "FocusUnderMouse") setFocus(FOCUS_UNDER_MOUSE); else if (key == "FocusStrictlyUnderMouse") setFocus(FOCUS_STRICTLY_UNDER_MOUSE); int k = cg.readEntry(KWIN_AUTORAISE_INTERVAL, 750); setAutoRaiseInterval(k); k = cg.readEntry(KWIN_DELAYFOCUS_INTERVAL, 300); setDelayFocusInterval(k); setAutoRaise(cg.readEntry(KWIN_AUTORAISE, false)); setClickRaise(cg.readEntry(KWIN_CLICKRAISE, true)); focusPolicyChanged(); // this will disable/hide the auto raise delay widget if focus==click setSeparateScreenFocus(cg.readEntry(KWIN_SEPARATE_SCREEN_FOCUS, false)); // on by default for non click to focus policies setActiveMouseScreen(cg.readEntry(KWIN_ACTIVE_MOUSE_SCREEN, getFocus() != 0)); // setFocusStealing( cg.readEntry(KWIN_FOCUS_STEALING, 2 )); // TODO default to low for now setFocusStealing(cg.readEntry(KWIN_FOCUS_STEALING, 1)); emit KCModule::changed(false); }
//! Returns the next element in the tab group starting at the focused element Widget* Ui::next(bool reverse, bool group) { // start the search at the root of the current tab group Widget *startPos = getFocus() ? getFocus()->tabgroup() : 0; int startOrder = -1; // if we're searching for a group if (group && startPos) { startOrder = startPos->tabOrder(); } else if (!group && getFocus() && !getFocus()->hasTabgroup()) { startOrder = getFocus()->tabOrder(); if (startOrder == -1) { // this element is not part of the tab cycle, // but its parent might be... Widget *el = getFocus(); while (el && el->parent() && startOrder == -1) { el = el->parent(); startOrder = el->tabOrder(); } } } if (group || !startPos) startPos = rootWidget(); // start at the root // find the element Widget *closest = 0; Widget *first = 0; startPos->next(startOrder, reverse, group, first, closest); if (closest) return closest; // we found an element else if (first) return first; // go to the end or the start else if (group) return rootWidget(); // no group found? root group else return 0; }
void Button::drawComponent(Graphics& gfx) { // printf("Button drawComponent\n"); gfx.setColor(inactiveColor); //activate relevant texture if(active) { //draw normalImage with/without gray mask and with alpha test on //printf("Button Active\n"); gfx.setColor(activeColor); } if(getFocus()) { //draw focus indicator (extra border for button?) //printf("Button in Focus\n"); gfx.setColor(focusColor); } //draw buttonLabel? gfx.enableBlending(true); // gfx.setTEV(GX_PASSCLR); gfx.setTEV(GX_MODULATE); // gfx.setColor(focusColor); gfx.setDepth(-10.0f); gfx.newModelView(); gfx.loadModelView(); gfx.loadOrthographic(); switch (buttonStyle) { case BUTTON_DEFAULT: // gfx.fillRect(x, y, width, height); normalImage->activateImage(GX_TEXMAP0); gfx.drawImage(0, x, y, width/2, height/2, 0.0, width/16.0, 0.0, height/16.0); gfx.drawImage(0, x+width/2, y, width/2, height/2, width/16.0, 0.0, 0.0, height/16.0); gfx.drawImage(0, x, y+height/2, width/2, height/2, 0.0, width/16.0, height/16.0, 0.0); gfx.drawImage(0, x+width/2, y+height/2, width/2, height/2, width/16.0, 0.0, height/16.0, 0.0); // gfx.drawImage(0, x, y, width, height, 0.0, 1.0, 0.0, 1.0); if (selected) { gfx.setColor(selectedColor); if(selectedImage) selectedImage->activateImage(GX_TEXMAP0); gfx.drawImage(0, x, y, width/2, height/2, 0.0, width/16.0, 0.0, height/16.0); gfx.drawImage(0, x+width/2, y, width/2, height/2, width/16.0, 0.0, 0.0, height/16.0); gfx.drawImage(0, x, y+height/2, width/2, height/2, 0.0, width/16.0, height/16.0, 0.0); gfx.drawImage(0, x+width/2, y+height/2, width/2, height/2, width/16.0, 0.0, height/16.0, 0.0); } break; case BUTTON_STYLEA_NORMAL: if (getFocus()) focusImage->activateImage(GX_TEXMAP0); else normalImage->activateImage(GX_TEXMAP0); gfx.drawImage(0, x, y, width/2, height, 0.0, width/8.0, 0.0, 1.0); gfx.drawImage(0, x+width/2, y, width/2, height, width/8.0, 0.0, 0.0, 1.0); break; case BUTTON_STYLEA_SELECT: if (selected) { if (getFocus()) selectedFocusImage->activateImage(GX_TEXMAP0); else selectedImage->activateImage(GX_TEXMAP0); } else { if (getFocus()) focusImage->activateImage(GX_TEXMAP0); else normalImage->activateImage(GX_TEXMAP0); } gfx.drawImage(0, x, y, width/2, height, 0.0, width/8.0, 0.0, 1.0); gfx.drawImage(0, x+width/2, y, width/2, height, width/8.0, 0.0, 0.0, 1.0); break; } if (buttonText) { int strWidth, strHeight; unsigned long CurrentTime; float scrollWidth, time_sec, scrollOffset; gfx.enableScissor(x + labelScissor, y, width - 2*labelScissor, height); if(active) IplFont::getInstance().drawInit(labelColor); else IplFont::getInstance().drawInit(inactiveColor); switch (labelMode) { case LABEL_CENTER: IplFont::getInstance().drawString((int) (x+width/2), (int) (y+height/2), *buttonText, fontSize, true); break; case LABEL_LEFT: strWidth = IplFont::getInstance().getStringWidth(*buttonText, fontSize); strHeight = IplFont::getInstance().getStringHeight(*buttonText, fontSize); IplFont::getInstance().drawString((int) (x+labelScissor), (int) (y+(height-strHeight)/2), *buttonText, fontSize, false); break; case LABEL_SCROLL: strHeight = IplFont::getInstance().getStringHeight(*buttonText, fontSize); scrollWidth = IplFont::getInstance().getStringWidth(*buttonText, fontSize)-width+2*labelScissor; scrollWidth = scrollWidth < 0.0f ? 0.0 : scrollWidth; CurrentTime = ticks_to_microsecs(gettick()); time_sec = (float)(CurrentTime - StartTime)/1000000.0f; if (time_sec > SCROLL_PERIOD) StartTime = ticks_to_microsecs(gettick()); scrollOffset = fabsf(fmodf(time_sec,SCROLL_PERIOD)-SCROLL_PERIOD/2)/(SCROLL_PERIOD/2); IplFont::getInstance().drawString((int) (x+labelScissor-(int)(scrollOffset*scrollWidth)), (int) (y+(height-strHeight)/2), *buttonText, fontSize, false); break; case LABEL_SCROLLONFOCUS: if(getFocus()) { strHeight = IplFont::getInstance().getStringHeight(*buttonText, fontSize); scrollWidth = IplFont::getInstance().getStringWidth(*buttonText, fontSize)-width+2*labelScissor; scrollWidth = scrollWidth < 0.0f ? 0.0 : scrollWidth; CurrentTime = ticks_to_microsecs(gettick()); time_sec = (float)(CurrentTime - StartTime)/1000000.0f; if (time_sec > SCROLL_PERIOD) StartTime = ticks_to_microsecs(gettick()); scrollOffset = fabsf(fmodf(time_sec,SCROLL_PERIOD)-SCROLL_PERIOD/2)/(SCROLL_PERIOD/2); IplFont::getInstance().drawString((int) (x+labelScissor-(int)(scrollOffset*scrollWidth)), (int) (y+(height-strHeight)/2), *buttonText, fontSize, false); } else { strWidth = IplFont::getInstance().getStringWidth(*buttonText, fontSize); strHeight = IplFont::getInstance().getStringHeight(*buttonText, fontSize); IplFont::getInstance().drawString((int) (x+labelScissor), (int) (y+(height-strHeight)/2), *buttonText, fontSize, false); } break; } gfx.disableScissor(); } }
void LLViewerMediaFocus::update() { if(mFocusedImplID.notNull()) { // We have a focused impl/face. if(!getFocus()) { // We've lost keyboard focus -- check to see whether the media controls have it if(mMediaControls.get() && mMediaControls.get()->hasFocus()) { // the media controls have focus -- don't clear. } else { // Someone else has focus -- back off. clearFocus(); } } else if(LLToolMgr::getInstance()->inBuildMode()) { // Build tools are selected -- clear focus. clearFocus(); } } LLViewerMediaImpl *media_impl = getFocusedMediaImpl(); LLViewerObject *viewer_object = getFocusedObject(); S32 face = mFocusedObjectFace; LLVector3 normal = mFocusedObjectNormal; bool focus = true; if(!media_impl || !viewer_object) { focus = false; media_impl = getHoverMediaImpl(); viewer_object = getHoverObject(); face = mHoverObjectFace; normal = mHoverObjectNormal; } if(media_impl && viewer_object) { // We have an object and impl to point at. // Make sure the media HUD object exists. if(! mMediaControls.get()) { LLPanelPrimMediaControls* media_controls = new LLPanelPrimMediaControls(); mMediaControls = media_controls->getHandle(); gHUDView->addChild(media_controls); } mMediaControls.get()->setMediaFace(viewer_object, face, media_impl, normal); } else { // The media HUD is no longer needed. if(mMediaControls.get()) { mMediaControls.get()->setMediaFace(NULL, 0, NULL); } } }
void appl::TextViewer::onRegenerateDisplay() { if (needRedraw() == false) { return; } //tic(); // For the scrooling windows m_displayDrawing.clear(); m_displayText.clear(); // reset the background : m_displayDrawing.setPos(vec3(0, 0, 0)); m_displayDrawing.setColor((*m_paintingProperties)[m_colorBackground].getForeground()); m_displayDrawing.rectangleWidth(m_size); if (m_buffer == nullptr) { m_maxSize.setX(256); m_maxSize.setY(256); float textEndAlignament = std::max(11.0f, m_size.x()-20.0f); m_displayText.setTextAlignement(10, textEndAlignament, ewol::compositing::alignLeft); m_displayText.setRelPos(vec3(10, 0, 0)); std::string tmpString("<br/>\n" "<font color=\"red\">\n" " <b>\n" " edn - Editeur De N'ours\n" " </b>\n" "</font>\n" "<br/>\n" "<br/>\n" "<font color=\"indigo\">\n" " <i>\n" " No Buffer Availlable to display\n" " </i>\n" "</font>\n"); m_displayText.setPos(vec3(0.0f, m_size.y(), 0.0f) ); m_displayText.forceLineReturn(); m_displayText.printDecorated(tmpString); // call the herited class... WidgetScrolled::onRegenerateDisplay(); return; } // normal displa of the buffer : vec3 tmpCursorPosition(0, 0, -1); float tmpCursorLenght = -1.0; // real display ... m_displayText.setColor(etk::Color<>(0, 0, 0, 255)); float countNbLine = 1; int32_t countColomn = 0; // the siplay string : std::u32string stringToDisplay; appl::Buffer::Iterator selectPosStart = m_buffer->begin(); appl::Buffer::Iterator selectPosStop = m_buffer->begin(); if (m_buffer->hasTextSelected() == true) { selectPosStart = m_buffer->selectStart(); selectPosStop = m_buffer->selectStop(); } m_displayText.setPos(vec3(-m_originScrooled.x(), m_size.y()+m_originScrooled.y(), 0)); m_displayText.forceLineReturn(); appl::Buffer::Iterator startingIt = m_buffer->begin(); int64_t startLineId = 0; if (m_size.y() < m_displayText.getPos().y()) { for (startingIt = m_buffer->begin(); (bool)startingIt == true; ++startingIt) { if (*startingIt == u32char::Return) { ++startLineId; m_displayText.forceLineReturn(); if (m_size.y() >= m_displayText.getPos().y()) { ++startingIt; break; } } } } // Display line number : m_lastOffsetDisplay = 0; vec3 tmpLetterSize = m_displayText.calculateSize((char32_t)'A'); { int32_t nbLine = m_buffer->getNumberOfLines(); float nbLineCalc = nbLine; int32_t nbChar = 0; while (nbLineCalc >= 1.0f) { ++nbChar; nbLineCalc /= 10.0f; } m_lastOffsetDisplay = tmpLetterSize.x() * (float)nbChar + 1.0f; m_displayText.setFontItalic((*m_paintingProperties)[m_colorLineNumber].getItalic()); m_displayText.setFontBold((*m_paintingProperties)[m_colorLineNumber].getBold()); m_displayText.setColorBg((*m_paintingProperties)[m_colorLineNumber].getBackground()); m_displayText.setColor((*m_paintingProperties)[m_colorLineNumber].getForeground()); m_displayText.setClippingMode(false); vec3 startWriteRealPosition = m_displayText.getPos(); m_displayText.setPos(vec3(0.0f, startWriteRealPosition.y(), 0.0f)); for (int32_t iii=startLineId; iii<nbLine; ++iii) { char tmpLineNumber[50]; sprintf(tmpLineNumber, "%*d", nbChar, iii+1); m_displayText.print(tmpLineNumber); m_displayText.forceLineReturn(); if (m_displayText.getPos().y() < -20.0f ) { break; } } m_displayText.setPos(vec3(-m_originScrooled.x()+m_lastOffsetDisplay, startWriteRealPosition.y(), 0.0f)); m_displayText.setClipping(vec2(m_lastOffsetDisplay, 0), m_size); } appl::DisplayHLData displayLocalSyntax; m_buffer->hightlightGenerateLines(displayLocalSyntax, startingIt, (m_size.y()/tmpLetterSize.y()) + 5); float maxSizeX = 0; appl::HighlightInfo * HLColor = nullptr; bool DisplayCursorAndSelection = isSelectedLast(); appl::Buffer::Iterator it; for (it = startingIt; (bool)it == true; ++it) { if (it == m_buffer->cursor()) { // need to display the cursor : tmpCursorPosition = m_displayText.getPos(); tmpCursorLenght = 0.0f; } //APPL_DEBUG("display element '" << currentValue << "'at pos : " << m_displayText.getPos() ); //APPL_DEBUG(" element size : " << iii << " : " << bufferElementSize); if (*it == u32char::Return) { countNbLine += 1; countColomn = 0; maxSizeX = std::max(m_displayText.getPos().x(), maxSizeX); // Display the end line position only if we have the focus ... if (DisplayCursorAndSelection == true) { if (it >= selectPosStart && it < selectPosStop) { ewol::compositing::Drawing& draw = m_displayText.getDrawing(); draw.setColor(etk::Color<>(0xFF, 0x00, 0x00, 0xFF)); draw.setPos(m_displayText.getPos() + tmpLetterSize/4.0f); draw.rectangle(m_displayText.getPos() + tmpLetterSize*3.0f/4.0f); } } if (tmpCursorLenght == 0.0f) { tmpCursorLenght = tmpLetterSize.x(); } m_displayText.forceLineReturn(); m_displayText.setPos(vec3(-m_originScrooled.x()+m_lastOffsetDisplay, m_displayText.getPos().y(), 0.0f)); if (m_displayText.getPos().y() < -20.0f ) { break; } continue; } HLColor = m_buffer->getElementColorAtPosition(displayLocalSyntax, (int64_t)it); bool haveBackground = false; if ( HLColor != nullptr && HLColor->patern != nullptr) { m_displayText.setColor(HLColor->patern->getColorGlyph().getForeground()); m_displayText.setColorBg(HLColor->patern->getColorGlyph().getBackground()); haveBackground = HLColor->patern->getColorGlyph().haveBackground(); m_displayText.setFontItalic(HLColor->patern->getColorGlyph().getItalic()); m_displayText.setFontBold(HLColor->patern->getColorGlyph().getBold()); } else { m_displayText.setFontItalic((*m_paintingProperties)[m_colorNormal].getItalic()); m_displayText.setFontBold((*m_paintingProperties)[m_colorNormal].getBold()); m_displayText.setColorBg((*m_paintingProperties)[m_colorNormal].getBackground()); m_displayText.setColor((*m_paintingProperties)[m_colorNormal].getForeground()); } if (haveBackground == false) { if (*it == u32char::Space) { m_displayText.setColorBg((*m_paintingProperties)[m_colorSpace].getForeground()); } else if (*it == u32char::Tabulation) { m_displayText.setColorBg((*m_paintingProperties)[m_colorTabulation].getForeground()); } } m_buffer->expand(countColomn, *it, stringToDisplay); // Display selection only if we have the focus ... if (DisplayCursorAndSelection == true) { if (it >= selectPosStart && it < selectPosStop) { m_displayText.setColor((*m_paintingProperties)[m_colorSelection].getForeground()); m_displayText.setColorBg((*m_paintingProperties)[m_colorSelection].getBackground()); } } //APPL_DEBUG("display : '" << currentValue << "' == > '" << stringToDisplay << "'"); m_displayText.print(stringToDisplay); if (tmpCursorLenght == 0.0f) { tmpCursorLenght = m_displayText.getPos().x()-tmpCursorPosition.x(); } countColomn += stringToDisplay.size(); } if (it == m_buffer->cursor()) { tmpCursorPosition = m_displayText.getPos(); tmpCursorLenght = 5; } maxSizeX = std::max(m_displayText.getPos().x(), maxSizeX); // Display cursor only if we have the focus ... if ( tmpCursorPosition.z() != -1 && getFocus() == true) { // display the cursor: //APPL_DEBUG("display cursor at position : " << tmpCursorPosition); m_displayText.setPos(tmpCursorPosition); if (m_buffer->hasTextSelected() == true) { m_displayText.setColorBg((*m_paintingProperties)[m_colorCursor].getForeground()); m_displayText.printCursor(false); } else { if (m_insertMode == true) { m_displayText.setColorBg((*m_paintingProperties)[m_colorSelection].getBackground()); } else { m_displayText.setColorBg((*m_paintingProperties)[m_colorCursor].getForeground()); } m_displayText.printCursor(m_insertMode, tmpCursorLenght); } } // set maximum size (X&Y) : { vec3 tmpLetterSize = m_displayText.calculateSize((char32_t)'A'); int64_t nbLines = m_buffer->getNumberOfLines(); m_maxSize.setX(maxSizeX+m_originScrooled.x()); m_maxSize.setY((float)nbLines*tmpLetterSize.y()); } //toc("Display time : "); // call the herited class... WidgetScrolled::onRegenerateDisplay(); }
void lcl_OnyxLineEdit::focusInEvent(QFocusEvent *e) { QLineEdit::focusInEvent(e); emit getFocus(this); }
bool Menu::isFocusOnHomeEdit() { return getFocus() == m_ppViewNodeList[2]; }
bool Menu::isFocusOnWallpaper() { return getFocus() == m_ppViewNodeList[4]; }
//! posts an input event to the environment bool Ui::handleEvent( const NEvent& event ) { switch(event.EventType) { case sEventGui: // hey, why is the user sending gui events..? break; case sEventMouse: _d->cursorPos = event.mouse.pos(); //!!! android fix. update hovered element on every mouse event, //! that beforeDraw() function cannot do it correctly #ifdef CAESARIA_PLATFORM_ANDROID _updateHovered( _d->cursorPos ); #endif //!!! end android fix switch( event.mouse.type ) { case mouseLbtnPressed: case mouseRbtnPressed: { if ( (_d->hovered.current.isValid() && _d->hovered.current != getFocus()) || !getFocus() ) { setFocus( _d->hovered.current.object() ); } // sending input to focus Widget* inFocus = getFocus(); if( inFocus ) { bool eventResolved = getFocus()->onEvent(event); if( eventResolved ) { return true; } } // focus could have died in last call inFocus = getFocus(); if( !inFocus && _d->hovered.current.isValid() ) { return _d->hovered.current->onEvent(event); } } break; case mouseLbtnRelease: if( getFocus() ) { return getFocus()->onEvent( event ); } break; default: if( _d->hovered.current.isValid() ) { return _d->hovered.current->onEvent( event ); } break; } break; case sTextInput: case sEventKeyboard: { if( _d->console ) { if( _d->console->initKey() == (int)event.keyboard.symbol ) { if( _d->console && !event.keyboard.control && event.keyboard.pressed ) _d->console->toggleVisible(); return true; } if( _d->console->visible() && !event.keyboard.control && event.keyboard.pressed ) { _d->console->keyPress( event ); return true; } } if( getFocus() && getFocus()->onEvent(event)) return true; // For keys we handle the event before changing focus to give elements the chance for catching the TAB // Send focus changing event if( event.EventType == sEventKeyboard && event.keyboard.pressed && event.keyboard.key == KEY_TAB) { Widget *wdg = next(event.keyboard.shift, event.keyboard.control); if (wdg && wdg != getFocus()) { if( setFocus(wdg) ) return true; } } } break; default: break; } // end switch return false; }