BRect CPitchBendEventRenderer::Extent( const CEvent &ev) const { float yStart = Editor()->ValueToViewCoords(ev.pitchBend.startBend - 0x2000); float yStop = Editor()->ValueToViewCoords(ev.pitchBend.targetBend - 0x2000); BRect r; r.left = Editor()->TimeToViewCoords(ev.Start()) - 5.0; r.right = Editor()->TimeToViewCoords(ev.Stop()) + 5.0; r.bottom = MAX(yStart, yStop) + 5.0; r.top = MIN(yStart, yStop) - 5.0; return r; }
EXPORT_C TKeyResponse CEikListBoxTextEditor::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) { _AKNTRACE_FUNC_ENTER; _AKNTRACE( "aKeyEvent.iCode is %d", aKeyEvent.iCode ); _AKNTRACE( "aKeyEvent.iScanCode is %d", aKeyEvent.iScanCode ); _AKNTRACE( "aType is %d", aType ); if (!Editor() || aType!=EEventKey) { _AKNTRACE_FUNC_EXIT; return EKeyWasNotConsumed; } if(iEditorObserver && iEditorObserver->HandleListBoxEditorEventL(this,aKeyEvent)==EKeyWasConsumed) { // gives owning dialogs or listboxes a chance to intecept keys prior to or instead of passing to editor // eg the CCknFileSaveAsDialog needs to check if a file exists when the enter key is pressed // and prevent the Enter key being passed on to the editor, or intecept the up/down keys to // allow scrolling out of the editor _AKNTRACE_FUNC_EXIT; return EKeyWasConsumed; } const TInt code=aKeyEvent.iCode; if (aKeyEvent.iModifiers&(EModifierCtrl|EModifierShift)==(EModifierCtrl|EModifierShift)) { TBuf<24> buf; iCoeEnv->ReadResource(buf,R_EIK_EDWIN_SHIFT_CTRL_HOTKEYS); const TInt pos=buf.Locate(TChar(code+'a'-1)); if (pos==CEikEdwin::EHotKeyInsertChar) { _AKNTRACE_FUNC_EXIT; return EKeyWasConsumed; } } switch (code) { case EKeyEnter: // stop editing and update data case EKeyOK: UpdateModelL(); StopEditingL(); break; case EKeyEscape: // stop editing and don't update data StopEditingL(); break; default: Editor()->OfferKeyEventL(aKeyEvent,aType); } _AKNTRACE_FUNC_EXIT; return EKeyWasConsumed; }
EXPORT_C void CEikListBoxTextEditor::StartEditingL(const CCoeControl& aContainer, const TRect& aRect, TInt aItemIndex, TInt aMaxLength ) { _AKNTRACE_FUNC_ENTER; if (Editor()) { _AKNTRACE_FUNC_EXIT; return; // quit if editing is currently on } iItemIndex=aItemIndex; TRect rect=aRect; TPtrC itemtext=EditableItemText(&rect); // get text (also partly editable) // create edwin (make it into own window, no wrapping) TGulBorder border; LafListBoxTextEditor::GetDefaultBorder(border); CEikEdwin* editor=new(ELeave) CEikEdwin(border); CleanupStack::PushL(editor); TInt edwinFlags=EEikEdwinOwnsWindow | EEikEdwinNoWrap | EEikEdwinNoLineOrParaBreaks | EEikEdwinNoCustomDraw; editor->CEikEdwin::ConstructL(edwinFlags,0,(iItemLen?iItemLen:aMaxLength),1); editor->SetContainerWindowL(aContainer); editor->SetRect(rect); UseFontL(*editor,*iFont); // need this to change CEikEdwin font... editor->SetTextL(&itemtext); editor->SetCursorPosL(editor->TextLength(),ETrue); editor->SetFocus(ETrue); editor->ActivateL(); iEikonEnv->EikAppUi()->AddToStackL(this,ECoeStackPriorityDialog,ECoeStackFlagRefusesFocus); CleanupStack::Pop(); // editor iEditor=editor; iCoeEnv->InputCapabilitiesChanged(); _AKNTRACE_FUNC_EXIT; }
bool GUI::LoadMap(FileName name) { if(GetCurrentEditor() && !GetCurrentMap().hasChanged() && !GetCurrentMap().hasFile()) g_gui.CloseCurrentEditor(); Editor* editor; try { editor = newd Editor(copybuffer, name); } catch(std::runtime_error& e) { PopupDialog(root, wxT("Error!"), wxString(e.what(), wxConvUTF8), wxOK); return false; } MapTab* mapTab = newd MapTab(tabbook, editor); mapTab->OnSwitchEditorMode(mode); root->AddRecentFile(name); mapTab->GetView()->FitToMap(); UpdateTitle(); ListDialog(wxT("Map loader errors"), mapTab->GetMap()->getWarnings()); root->DoQueryImportCreatures(); FitViewToMap(mapTab); root->UpdateMenubar(); return true; }
int main(int argc, char **argv) { int tmp; context_t context; if(SDL_Init(SDL_INIT_VIDEO) < 0) return EXIT_FAILURE; atexit(SDL_Quit); if(!InitContext(&context)) { fprintf(stderr, "Unable to load screen\n"); return EXIT_FAILURE; } SDL_ShowCursor(0); SDL_WM_SetCaption("Minecraft Sokoban", NULL); SDL_WM_SetIcon(SDL_LoadBMP("ico32.bmp"), NULL); SDL_EnableKeyRepeat(125, 125); do { SDL_FreeSurface(context.screen); context.screen = SDL_SetVideoMode(768, 768, 32, SDL_HWSURFACE|SDL_DOUBLEBUF); tmp = Menu(context.screen); if(tmp == PLAY) Play(&context, 1); else if(tmp == EDIT) Editor(&context); else if(tmp == TILE) ChoseTileset(&context); } while(tmp != EXIT); FreeContext(&context); return EXIT_SUCCESS; (void)argc; (void)argv; }
void UJavascriptAssetEditorToolkit::Open(const TArray<UObject*>& InObjects, TSharedPtr<IToolkitHost> EditWithinLevelEditor) { TSharedRef<FAssetEditorToolkit_Javascript> Editor(new FAssetEditorToolkit_Javascript(this)); Editor->Open(InObjects, EditWithinLevelEditor); SpawnedEditors.Add(Editor); }
/** * Stops editing the current item, if editing was taking place. Does not Leave. * * @since Uikon1.2 */ EXPORT_C void CEikListBoxTextEditor::StopEditingL() { iEikonEnv->EikAppUi()->RemoveFromStack(this); if ( Editor() == NULL ) return; // quit if editing is not currently on iEditor->SetFocus(EFalse); // BUG? - cursor remains on screen without this delete iEditor; iEditor=NULL; iCoeEnv->InputCapabilitiesChanged(); }
long CPitchBendEventRenderer::QuantizeDragTime( const CEvent &ev, short partCode, BPoint clickPos, BPoint dragPos, bool initial) const { return Editor()->ViewCoordsToTime(dragPos.x - clickPos.x); }
int main (int argc, char **argv) { int accionARealizar; //0:juego,1:cargar,2:salir int pantallaActual = 0; int retornoJuego; ConfigManager::LoadConfigFile("config.cfg"); InicializarSDL ( ); CharacterBuilder::LoadCharacterTypes(); LevelData::LoadLevels(); TileBuilder::LoadTileTypes(); while ( ( accionARealizar = Menu ( ) ) != EXIT ) { switch ( accionARealizar ) { case ENTER_GAME: retornoJuego = LEVEL_FINNISHED; while ( retornoJuego == LEVEL_FINNISHED ) { retornoJuego = Juego ( screen, LevelData::GetLevelData(pantallaActual)); switch ( retornoJuego ) { case GAME_OVER: // muerto mostrarMenu ( (ConfigManager::gamedataPath+string("gameover.jpg")).c_str() ); pantallaActual = 0; break; case LEVEL_FINNISHED: // fin de nivel if (++pantallaActual == LevelData::GetNumberOfLevelsLoaded()) //has acabao el juego { mostrarMenu ( (ConfigManager::gamedataPath+string("gamecompleted.jpg")).c_str() ); mostrarMenu ( (ConfigManager::gamedataPath+string("creditos.jpg")).c_str() ); pantallaActual = 0; retornoJuego = GAME_OVER; }else{ mostrarMenu ( (ConfigManager::gamedataPath+string("levelcompleted.jpg")).c_str() ); } break; case USER_EXIT:default: // peticion de user retornoJuego = USER_EXIT; break; } } break; case ENTER_EDITOR: Editor ( screen ); //^--Ahora mismo vuelve a ejecutar el men˙ break; } } SDL_Quit ( ); return 0; }
EXPORT_C TBool CEikListBoxTextEditor::UpdateModelL() // virtual - needs to be rewritten if editing other than single column text list { _AKNTRACE_FUNC_ENTER; if (!Editor()) { _AKNTRACE_FUNC_EXIT; return EFalse; // quit if editing is not currently on } const MDesCArray* matchableTextArray=ListBoxModel()->MatchableTextArray(); CDesCArray* textArray=(CDesCArray*)matchableTextArray; TPtrC itemtext = ItemText(); if ( iItemPos ) // partly editable item? { HBufC* itemBuffer= HBufC::New(itemtext.Length()); CleanupStack::PushL( itemBuffer ); TPtr itemPointer = itemBuffer->Des(); itemPointer.Append( itemtext.Left( iItemPos ) ); HBufC* ptr=iEditor->GetTextInHBufL(); TPtrC newText; if (ptr) { newText.Set(ptr->Des()); } TInt addSpaces = iItemLen - newText.Length(); for (TInt index=0; ((addSpaces>0) && (index<addSpaces)); index++) itemPointer.Append(_L(" ")); itemPointer.Append( newText ); itemPointer.Append( itemtext.Right( itemtext.Length()-iItemPos-iItemLen ) ); delete ptr; textArray->InsertL( ItemIndex(), *itemBuffer ); CleanupStack::PopAndDestroy(); // itemBuffer textArray->Delete( ItemIndex()+1 ); } else // replace the whole list item { HBufC* newText = iEditor->GetTextInHBufL(); if (!newText) return ETrue; // if user tries to insert an empty text... CleanupStack::PushL(newText); textArray->InsertL(ItemIndex(),*newText); CleanupStack::PopAndDestroy(); // newText textArray->Delete( ItemIndex() + 1 ); } _AKNTRACE_FUNC_EXIT; return ETrue; }
long CPitchBendEventRenderer::QuantizeDragValue( const CEvent &ev, short partCode, BPoint clickPos, BPoint dragPos) const { // Simply scale the dragged value by the pixel step value double val = (clickPos.y - dragPos.y) / Editor()->pixelsPerValue; return static_cast<long>(val); }
/** * Loads editor configuration parameters. * @param settings The QSettings object to use for loading */ void Editor::Config::load(QSettings& settings) { Editor::Config config; Editor().getConfig(config); font_ = settings.value("Font", config.font_).value<QFont>(); hlCurLine_ = settings.value("HighlightCurrentLine", config.hlCurLine_).toBool(); indentTabs_ = settings.value("IndentWithTabs", config.indentTabs_).toBool(); tabWidth_ = settings.value("TabWidth", config.tabWidth_).toInt(); }
EventOp * CPitchBendEventRenderer::CreateTimeOp( const CEvent &ev, short partCode, long timeDelta, long valueDelta) const { if (partCode == Part_End) { return new DurationOffsetOp(timeDelta); } else { timeDelta = MAX(timeDelta, - Editor()->Track()->MinSelectTime()); return new TimeOffsetOp(timeDelta); } }
long CPitchBendEventRenderer::Pick( const CEvent &ev, BPoint pickPt, short &partCode) const { if (ev.Duration() > 0) { BPoint start(Editor()->TimeToViewCoords(ev.Start()), Editor()->ValueToViewCoords(ev.pitchBend.startBend - 0x2000)); BPoint stop(Editor()->TimeToViewCoords(ev.Stop()), Editor()->ValueToViewCoords(ev.pitchBend.targetBend - 0x2000)); float best = MAX(fabs(pickPt.x - stop.x), fabs(pickPt.y - stop.y)); float dist = MAX(fabs(pickPt.x - start.x), fabs(pickPt.y - start.y)); partCode = Part_End; if (dist < best) { best = dist; partCode = Part_Start; } if (best > 3.0) { dist = MathUtils::DistanceFromPointToLine(pickPt, start, stop); if (dist < best) { best = dist + 2.0; partCode = Part_Whole; } } if (best > 8.0) return LONG_MAX; return static_cast<long>(best); } else { BPoint diff(pickPt.x - Editor()->TimeToViewCoords(ev.Start()), pickPt.y - Editor()->ValueToViewCoords(ev.pitchBend.startBend - 0x2000)); if ((diff.y > 8) || (diff.y < -8) || (diff.x > 10) || (diff.x < -8)) return LONG_MAX; if (diff.x >= 3.0) partCode = Part_End; else partCode = Part_Whole; return static_cast<long>(MAX(fabs(diff.x), fabs(diff.y))); } }
void CInstrumentEditorDPCM::OnBnClickedEdit() { CDSample *pSample = GetSelectedSample(); if (pSample == NULL) return; CSampleEditorDlg Editor(this, pSample); INT_PTR nRes = Editor.DoModal(); if (nRes == IDOK) { // Save edited sample Editor.CopySample(pSample); } // Update sample list BuildSampleList(); }
bool GUI::NewMap() { Editor* editor; try { editor = newd Editor(copybuffer); } catch(std::runtime_error& e) { PopupDialog(root, wxT("Error!"), wxString(e.what(), wxConvUTF8), wxOK); return false; } MapTab* mapTab = newd MapTab(tabbook, editor); mapTab->OnSwitchEditorMode(mode); SetStatusText(wxT("Created new map")); UpdateTitle(); RefreshPalettes(); root->UpdateMenubar(); root->Refresh(); return true; }
void FAssetTypeActions_PathFollowerBlueprint::OpenAssetEditor(const TArray<UObject*>& InObjects, TSharedPtr<class IToolkitHost> EditWithinLevelEditor) { EToolkitMode::Type Mode = EditWithinLevelEditor.IsValid() ? EToolkitMode::WorldCentric : EToolkitMode::Standalone; for (UObject* Object : InObjects) { if (UBlueprint* Blueprint = Cast<UBlueprint>(Object)) { bool isFirstCreate = Blueprint->bIsNewlyCreated; TSharedRef<FPathFollowerEditor> Editor(new FPathFollowerEditor()); TArray<UBlueprint*> Blueprints; Blueprints.Add(Blueprint); Editor->InitPathFollowerEditor(Mode, EditWithinLevelEditor, Blueprints, ShouldUseDataOnlyEditor(Blueprint)); //第一次打开, 初始化部分对象. if(isFirstCreate) { Editor->AddComponent(USphereComponent::StaticClass(), TEXT("Sphere")); Editor->AddComponent(USplineComponent::StaticClass(), TEXT("Spline")); } } } }
void CPitchBendEventRenderer::Draw( const CEvent &ev, bool shadowed) const { CDestination *dest = Editor()->TrackWindow()->Document()->FindDestination(ev.GetVChannel()); BRect r; if (shadowed) Editor()->SetDrawingMode( B_OP_BLEND ); Editor()->SetHighColor(dest->Color()); if ((ev.Duration() > 0) && (ev.pitchBend.updatePeriod > 0)) { Editor()->BeginLineArray(ev.Duration() / ev.pitchBend.updatePeriod); for (int i = ev.pitchBend.updatePeriod; i < ev.Duration(); i += ev.pitchBend.updatePeriod) { long v = ev.pitchBend.startBend - 0x2000 + ((ev.pitchBend.targetBend - ev.pitchBend.startBend) * i / ev.Duration()); BPoint point(Editor()->TimeToViewCoords(ev.Start() + i), Editor()->ValueToViewCoords(v)); Editor()->AddLine(point, point, Editor()->HighColor()); } Editor()->EndLineArray(); r.left = Editor()->TimeToViewCoords(ev.Stop() ) - 2.0; r.top = Editor()->ValueToViewCoords(ev.pitchBend.targetBend - 0x2000) - 2.0; r.right = r.left + 4.0; r.bottom = r.top + 4.0; Editor()->FillEllipse(r); r.InsetBy(-1.0, -1.0); if (ev.IsSelected() && !shadowed && Editor()->IsSelectionVisible()) Editor()->SetHighColor(0, 0, 255); else Editor()->SetHighColor(0, 0, 0); Editor()->StrokeEllipse(r); } r.left = Editor()->TimeToViewCoords(ev.Start()) - 2.0; r.top = Editor()->ValueToViewCoords(ev.pitchBend.startBend - 0x2000) - 2.0; r.right = r.left + 4.0; r.bottom = r.top + 4.0; Editor()->SetHighColor(dest->Color()); Editor()->FillEllipse(r); if (ev.IsSelected() && !shadowed && Editor()->IsSelectionVisible()) Editor()->SetHighColor(0, 0, 255); else Editor()->SetHighColor(0, 0, 0); r.InsetBy(-1.0, -1.0); Editor()->StrokeEllipse(r); }
void SceneEditor::createInterface(ApplicationBuilderPtr TheApplicationBuilder) { //Component Editors std::vector< ::osg::UInt32 > EditorTypeIdVector(getEditorTypeIds()); FieldContainerPtr Editor(NullFC); beginEditCP(SceneEditorPtr(this), EditorsFieldMask); for(std::vector< ::osg::UInt32 >::const_iterator Itor(EditorTypeIdVector.begin()) ; Itor != EditorTypeIdVector.end(); ++Itor) { Editor = FieldContainerFactory::the()->findType(*Itor)->createFieldContainer(); if(Editor != NullFC) { getEditors().push_back(SceneComponentEditor::Ptr::dcast(Editor)); getEditors().back()->createInterface(TheApplicationBuilder); } } endEditCP(SceneEditorPtr(this), EditorsFieldMask); //Scene Label UIFontPtr SceneLabelFont = UIFont::create(); beginEditCP(SceneLabelFont, UIFont::SizeFieldMask); SceneLabelFont->setSize(24); endEditCP(SceneLabelFont, UIFont::SizeFieldMask); //Scene Name Label _SceneLabel = osg::Label::create(); beginEditCP(_SceneLabel, Label::TextFieldMask | Label::PreferredSizeFieldMask | Label::FontFieldMask); _SceneLabel->setText("Scene:"); _SceneLabel->setFont(SceneLabelFont); _SceneLabel->setPreferredSize(Vec2f(75,30)); endEditCP(_SceneLabel, Label::TextFieldMask | Label::PreferredSizeFieldMask | Label::FontFieldMask); _SceneNameLabel = osg::Label::create(); beginEditCP(_SceneNameLabel, Label::PreferredSizeFieldMask | Label::FontFieldMask); _SceneNameLabel->setFont(SceneLabelFont); _SceneNameLabel->setPreferredSize(Vec2f(100,30)); endEditCP(_SceneNameLabel, Label::PreferredSizeFieldMask | Label::FontFieldMask); //TabPanel _SceneEditorsTabPanel = osg::TabPanel::create(); beginEditCP(_SceneEditorsTabPanel, TabPanel::TabAlignmentFieldMask | TabPanel::TabPlacementFieldMask | TabPanel::TabsFieldMask | TabPanel::TabContentsFieldMask); _SceneEditorsTabPanel->setTabAlignment(0.0f); _SceneEditorsTabPanel->setTabPlacement(TabPanel::PLACEMENT_WEST); for(::osg::UInt32 i(0) ; i<getEditors().size() ; ++i) { _SceneEditorsTabPanel->addTab(createEditorTab(getEditors()[i], TheApplicationBuilder->getIconManager()), getEditors()[i]); } endEditCP(_SceneEditorsTabPanel,TabPanel::TabAlignmentFieldMask | TabPanel::TabPlacementFieldMask | TabPanel::TabsFieldMask | TabPanel::TabContentsFieldMask); _SceneEditorsTabPanel->setSelectedIndex(0); //Layout SpringLayoutPtr SceneEditorInterfaceLayout = SpringLayout::create(); //Scene Label SceneEditorInterfaceLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, _SceneLabel, 0, SpringLayoutConstraints::WEST_EDGE, SceneEditorPtr(this)); SceneEditorInterfaceLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, _SceneLabel, 0, SpringLayoutConstraints::NORTH_EDGE, SceneEditorPtr(this)); SceneEditorInterfaceLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, _SceneLabel, LayoutSpring::height(_SceneLabel)); SceneEditorInterfaceLayout->putConstraint(SpringLayoutConstraints::WIDTH_EDGE, _SceneLabel, LayoutSpring::width(_SceneLabel)); //Scene Name Label SceneEditorInterfaceLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, _SceneNameLabel, 1, SpringLayoutConstraints::EAST_EDGE, _SceneLabel); SceneEditorInterfaceLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _SceneNameLabel, 0, SpringLayoutConstraints::EAST_EDGE, SceneEditorPtr(this)); SceneEditorInterfaceLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, _SceneNameLabel, 0, SpringLayoutConstraints::NORTH_EDGE, SceneEditorPtr(this)); SceneEditorInterfaceLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _SceneNameLabel, 0, SpringLayoutConstraints::SOUTH_EDGE, _SceneLabel); //Scene Editors Tab Panel SceneEditorInterfaceLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, _SceneEditorsTabPanel, 0, SpringLayoutConstraints::WEST_EDGE, SceneEditorPtr(this)); SceneEditorInterfaceLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _SceneEditorsTabPanel, 0, SpringLayoutConstraints::EAST_EDGE, SceneEditorPtr(this)); SceneEditorInterfaceLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, _SceneEditorsTabPanel, 1, SpringLayoutConstraints::SOUTH_EDGE, _SceneLabel); SceneEditorInterfaceLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _SceneEditorsTabPanel, 0, SpringLayoutConstraints::SOUTH_EDGE, SceneEditorPtr(this)); beginEditCP(SceneEditorPtr(this), SceneEditor::ChildrenFieldMask | SceneEditor::LayoutFieldMask); getChildren().clear(); getChildren().push_back(_SceneLabel); getChildren().push_back(_SceneNameLabel); getChildren().push_back(_SceneEditorsTabPanel); setLayout(SceneEditorInterfaceLayout); endEditCP(SceneEditorPtr(this), SceneEditor::ChildrenFieldMask | SceneEditor::LayoutFieldMask); }
void CPitchBendEventRenderer::Invalidate( const CEvent &ev ) const { Editor()->Invalidate(Extent(ev)); }