void CustomColorsSystem::ProcessUIEvent(DAVA::UIEvent *event) { if (!IsLandscapeEditingEnabled()) { return; } UpdateCursorPosition(); if (event->tid == UIEvent::BUTTON_1) { Vector3 point; switch(event->phase) { case UIEvent::PHASE_BEGAN: if (isIntersectsLandscape) { UpdateToolImage(); StoreOriginalState(); editingIsEnabled = true; } break; case UIEvent::PHASE_DRAG: break; case UIEvent::PHASE_ENDED: FinishEditing(); break; } } }
bool CustomColorsSystem::DisableLandscapeEdititing( bool saveNeeded) { if (!enabled) { return true; } if (drawSystem->GetCustomColorsProxy()->GetChangesCount() && saveNeeded) { SceneSignals::Instance()->EmitCustomColorsTextureShouldBeSaved(((SceneEditor2 *) GetScene())); } FinishEditing(); selectionSystem->SetLocked(false); modifSystem->SetLocked(false); drawSystem->DisableCursor(); drawSystem->DisableCustomDraw(); drawSystem->GetLandscapeProxy()->SetCustomColorsTexture(NULL); drawSystem->GetLandscapeProxy()->SetCustomColorsTextureEnabled(false); enabled = false; return !enabled; }
static void TXT_InputBoxFocused(TXT_UNCAST_ARG(inputbox), int focused) { TXT_CAST_ARG(txt_inputbox_t, inputbox); // Stop editing when we lose focus. if (inputbox->editing && !focused) { FinishEditing(inputbox); } }
static int TXT_InputBoxKeyPress(TXT_UNCAST_ARG(inputbox), int key) { TXT_CAST_ARG(txt_inputbox_t, inputbox); unsigned int c; if (!inputbox->editing) { if (key == KEY_ABUTTON) { StartEditing(inputbox); return 1; } // Backspace or delete erases the contents of the box. if ((key == KEY_DEL || key == KEY_BACKSPACE) && inputbox->widget.widget_class == &txt_inputbox_class) { free(*((char **)inputbox->value)); *((char **) inputbox->value) = strdup(""); } return 0; } if (key == KEY_ABUTTON) { FinishEditing(inputbox); } if (key == KEY_BBUTTON) { inputbox->editing = 0; } if (key == KEY_BACKSPACE) { Backspace(inputbox); } c = TXT_KEY_TO_UNICODE(key); // Add character to the buffer, but only if it's a printable character // that we can represent on the screen. if (isprint(c) || (c >= 128 && TXT_CanDrawCharacter(c))) { AddCharacter(inputbox, c); } return 1; }
static void VKBCloseWindow(TXT_UNCAST_ARG(widget), int keep) { if (keep) { FinishEditing(vkb_inputbox); } else { vkb_inputbox->editing = 0; } TXT_CloseWindow(vkb_window); }
static int TXT_InputBoxKeyPress(TXT_UNCAST_ARG(inputbox), int key) { TXT_CAST_ARG(txt_inputbox_t, inputbox); unsigned int c; if (!inputbox->editing) { if (key == KEY_ENTER) { StartEditing(inputbox); return 1; } // Backspace or delete erases the contents of the box. if ((key == KEY_DEL || key == KEY_BACKSPACE) && inputbox->widget.widget_class == &txt_inputbox_class) { free(*((char **)inputbox->value)); *((char **) inputbox->value) = strdup(""); } return 0; } if (key == KEY_ENTER) { FinishEditing(inputbox); } if (key == KEY_ESCAPE) { inputbox->editing = 0; } if (key == KEY_BACKSPACE) { Backspace(inputbox); } c = TXT_KEY_TO_UNICODE(key); if (c >= 128 || isprint(c)) { // Add character to the buffer AddCharacter(inputbox, c); } return 1; }
bool HeightmapEditorSystem::DisableLandscapeEdititing() { if (!enabled) { return true; } FinishEditing(); selectionSystem->SetLocked(false); modifSystem->SetLocked(false); drawSystem->DisableCursor(); drawSystem->DisableCustomDraw(); enabled = false; return !enabled; }
void HeightmapEditorSystem::ProcessUIEvent(DAVA::UIEvent *event) { if (!IsLandscapeEditingEnabled()) { return; } UpdateCursorPosition(); if (event->tid == UIEvent::BUTTON_1) { Vector3 point; switch(event->phase) { case UIEvent::PHASE_BEGAN: if (drawingType == HEIGHTMAP_DRAW_ABSOLUTE_DROPPER || drawingType == HEIGHTMAP_DROPPER) { curHeight = drawSystem->GetHeightAtPoint(cursorPosition); SceneSignals::Instance()->EmitDropperHeightChanged(dynamic_cast<SceneEditor2*>(GetScene()), curHeight); } if (isIntersectsLandscape) { if (drawingType == HEIGHTMAP_COPY_PASTE) { int32 curKeyModifiers = QApplication::keyboardModifiers(); if (curKeyModifiers & Qt::AltModifier) { copyPasteFrom = cursorPosition; copyPasteTo = Vector2(-1.f, -1.f); return; } else { if (copyPasteFrom == Vector2(-1.f, -1.f)) { return; } copyPasteTo = cursorPosition; StoreOriginalHeightmap(); } } else { if (drawingType != HEIGHTMAP_DROPPER) { StoreOriginalHeightmap(); } } UpdateToolImage(); editingIsEnabled = true; } activeDrawingType = drawingType; break; case UIEvent::PHASE_DRAG: break; case UIEvent::PHASE_ENDED: FinishEditing(); break; } } }
static void TXT_SpinControlFocused(TXT_UNCAST_ARG(spincontrol), int focused) { TXT_CAST_ARG(txt_spincontrol_t, spincontrol); FinishEditing(spincontrol); }
static int TXT_SpinControlKeyPress(TXT_UNCAST_ARG(spincontrol), int key) { TXT_CAST_ARG(txt_spincontrol_t, spincontrol); // Enter to enter edit mode if (spincontrol->editing) { if (key == KEY_ENTER) { FinishEditing(spincontrol); return 1; } if (key == KEY_ESCAPE) { // Abort without saving value spincontrol->editing = 0; return 1; } if (isdigit(key) || key == '-' || key == '.') { AddCharacter(spincontrol, key); return 1; } if (key == KEY_BACKSPACE) { Backspace(spincontrol); return 1; } } else { // Non-editing mode if (key == KEY_ENTER) { spincontrol->editing = 1; strcpy(spincontrol->buffer, ""); return 1; } if (key == KEY_LEFTARROW) { switch (spincontrol->type) { case TXT_SPINCONTROL_INT: spincontrol->value->i -= spincontrol->step.i; break; case TXT_SPINCONTROL_FLOAT: spincontrol->value->f -= spincontrol->step.f; break; } EnforceLimits(spincontrol); return 1; } if (key == KEY_RIGHTARROW) { switch (spincontrol->type) { case TXT_SPINCONTROL_INT: spincontrol->value->i += spincontrol->step.i; break; case TXT_SPINCONTROL_FLOAT: spincontrol->value->f += spincontrol->step.f; break; } EnforceLimits(spincontrol); return 1; } } return 0; }