// ******************************************** GLBoidsScreen::on_mouse_move void on_mouse_move( double xpos, double ypos ) { // En fonction des actions switch( _action ) { case MouseAction::ZOOM: _zoom = _zoom * (1.0 - (_start.y - ypos) / _screen_height); if( _zoom > ZOOM_MAX ) _zoom = ZOOM_MAX; else if( _zoom < ZOOM_MIN ) _zoom = ZOOM_MIN; _start = ScreenPos(xpos,ypos); break; case MouseAction::ROTATE: Quaternion d_quat; trackball( d_quat, (2.0 * _start.x - _screen_width) / _screen_width, (_screen_height - 2.0 * _start.y) / _screen_height, (2.0 * xpos - _screen_width) / _screen_width, (_screen_height - 2.0 * ypos) / _screen_height); add_quats( d_quat, _orient, _orient ); _start = ScreenPos(xpos,ypos); break; case MouseAction::MOVE: _pos += ScreenPos(2*(xpos-_start.x)/_screen_width, -2*(ypos-_start.y)/_screen_height); _start = ScreenPos(xpos,ypos); break; case MouseAction::NOTHING: default: break; } }
int EBuffer::MoveTabEnd() { PELine X = VLine(CP.Row); int C = CharOffset(X, CP.Col); if (C < X->Count) if (X->Chars[C] == 9) if (ScreenPos(X, C) < CP.Col) return SetPos(ScreenPos(X, C + 1), CP.Row); return 1; }
int EBuffer::TypeChar(char aCh) { // does abbrev expansion if appropriate if (BFI(this, BFI_InsertKillBlock) == 1) if (CheckBlock() == 1) if (BlockKill() == 0) return 0; if (ChClass(aCh) == 0 && BFI(this, BFI_Abbreviations) == 1) { PELine L = VLine(CP.Row); int C, P, P1, C1, Len, R; char Str[256]; EAbbrev *ab; R = VToR(CP.Row); C = CP.Col; P = CharOffset(L, C); if (P >= 0 && P <= L->Count) { //fprintf(stderr, "TypeChar 1\n"); P1 = P; C1 = ScreenPos(L, P); while ((P > 0) && ((ChClass(L->Chars[P - 1]) == 1) || (L->Chars[P - 1] == '_'))) P--; Len = P1 - P; C = ScreenPos(L, P); assert(C1 - C == Len); if (Len > 0 && Len < int (sizeof(Str))) { //fprintf(stderr, "TypeChar 2\n"); memcpy(Str, L->Chars + P, Len); Str[Len] = 0; ab = Mode->FindAbbrev(Str); if (ab) { //fprintf(stderr, "TypeChar 3\n"); if (ab->Replace != 0) { //fprintf(stderr, "TypeChar 4\n"); if (DelText(R, C, C1 - C) == 0) return 0; if (ab->Replace) { //fprintf(stderr, "TypeChar 5 %s <- %s\n", ab->Replace, ab->Match); Len = strlen(ab->Replace); if (InsText(R, C, Len, ab->Replace) == 0) return 0; if (SetPos(C + Len, CP.Row) == 0) return 0; } else { if (SetPos(C, CP.Row) == 0) return 0; } } else { if (((EGUI *)gui)->ExecMacro(View->MView->Win, ab->Cmd) == 0) return 0; } } } } } return InsertString(&aCh, 1); }
int EBuffer::InsertString(const char *aStr, int aCount) { int P; int C, L; int Y = VToR(CP.Row); if (BFI(this, BFI_InsertKillBlock) == 1) if (CheckBlock() == 1) if (BlockKill() == 0) return 0; if (BFI(this, BFI_Insert) == 0) if (CP.Col < LineLen()) if (KillChar() == 0) return 0; if (InsText(Y, CP.Col, aCount, aStr) == 0) return 0; C = CP.Col; L = VToR(CP.Row); P = CharOffset(RLine(L), C); P += aCount; C = ScreenPos(RLine(L), P); if (SetPos(C, CP.Row) == 0) return 0; if (BFI(this, BFI_Trim) && *aStr != '\t') if (TrimLine(L) == 0) return 0; if (BFI(this, BFI_WordWrap) == 2) { if (DoWrap(0) == 0) return 0; } else if (BFI(this, BFI_WordWrap) == 1) { int P, C = CP.Col; PELine LP; int L; if (C > BFI(this, BFI_RightMargin)) { L = CP.Row; C = BFI(this, BFI_RightMargin); P = CharOffset(LP = RLine(L), C); while ((C > BFI(this, BFI_LeftMargin)) && ((LP->Chars[P] != ' ') && (LP->Chars[P] != 9))) C = ScreenPos(LP, --P); if (P <= BFI(this, BFI_LeftMargin)) { C = BFI(this, BFI_RightMargin); } else C = ScreenPos(LP, P); if (SplitLine(L, C) == 0) return 0; IndentLine(L + 1, BFI(this, BFI_LeftMargin)); if (SetPos(CP.Col - C - 1 + BFI(this, BFI_LeftMargin), CP.Row + 1) == 0) return 0; } } return 1; }
int EBuffer::TrimLine(int Row) { PELine L = RLine(Row); int P, X, E; if (L->Count == 0) return 1; P = L->Count; while ((P > 0) && ((L->Chars[P - 1] == ' ') || (L->Chars[P - 1] == 9))) P--; X = ScreenPos(L, P); E = ScreenPos(L, L->Count); if (E - X > 0) if (DelText(Row, X, E - X, 1) == 0) return 0; return 1; }
int EBuffer::LineIndented(int Row, const char *indentchars) { ELine *l; if (Row < 0) return 0; if (Row >= RCount) return 0; l = RLine(Row); return ScreenPos(l, LineIndentedCharCount(l, indentchars)); }
// ****************************************** GLBoidsScreen::on_mouse_button void on_mouse_button( int button, int action, int mods ) { double x, y; glfwGetCursorPos( _window, &x, &y); //std::cout <<"Mouse Button at (" << x << ", " << y << ")\n"; if( action == GLFW_PRESS ) { if( button == GLFW_MOUSE_BUTTON_LEFT ) { // Infer the model that has been clicked. auto pt = glm::vec4{ (float)x, (float)y, 0.f, 1.f }; if( get_mouse_horizontal( pt )){ std::cout << " cliked on " << glm::to_string(pt) << std::endl; } } else if( button == GLFW_MOUSE_BUTTON_MIDDLE ) { // With SHIFT ?? if( mods & GLFW_MOD_SHIFT ) { //_scene->mouse_action_start ("move-resize",x,y); //std::cout << "move-resize at " << x << ", " << y << std::endl; _start = ScreenPos(x,y); _action = MouseAction::MOVE; } else if( mods & GLFW_MOD_CONTROL ) { //std::cout << "zoom at " << x << ", " << y << std::endl; } else { //_scene->mouse_action_start ("rotate",x,y); _start = ScreenPos(x,y); _action = MouseAction::ROTATE; //std::cout << "rotate at " << x << ", " << y << std::endl; } } else if( button == GLFW_MOUSE_BUTTON_RIGHT ) { //_scene->mouse_action_start( "zoom", x, y); _start = ScreenPos(x,y); _action = MouseAction::ZOOM; //std::cout << "btn right " << x << ", " << y << std::endl; } } else if( action == GLFW_RELEASE ) { //_scene->mouse_action_end( x, y); _action = MouseAction::NOTHING; //std::cout << "end_action " << x << ", " << y << std::endl; //std::cout << " start= " << glm::to_string(_start) << std::endl; } }
int EBuffer::BlockSelectWord() { int Y = VToR(CP.Row); PELine L = RLine(Y); int P; int C; if (BlockUnmark() == 0) return 0; BlockMode = bmStream; P = CharOffset(L, CP.Col); if (P >= L->Count) return 0; C = ChClassK(L->Chars[P]); while ((P > 0) && (C == ChClassK(L->Chars[P - 1]))) P--; if (SetBB(EPoint(Y, ScreenPos(L, P))) == 0) return 0; while ((P < L->Count) && (C == ChClassK(L->Chars[P]))) P++; if (SetBE(EPoint(Y, ScreenPos(L, P))) == 0) return 0; return 1; }
int EBuffer::MoveLastNonWhite() { int C = LineLen(), P; PELine L = VLine(CP.Row); while (C > 0) { if (L->Chars[C - 1] == ' ' || L->Chars[C - 1] == 9) C--; else break; } P = ScreenPos(VLine(CP.Row), C); if (SetPos(P, CP.Row) == 0) return 0; return 1; }
int EBuffer::Delete() { int Y = VToR(CP.Row); if (CheckBlock() == 1 && BFI(this, BFI_DeleteKillBlock)) { if (BlockKill() == 0) return 0; } else if (CP.Col < LineLen()) { if (BFI(this, BFI_DeleteKillTab)) { int P; int C = CP.Col, C1; P = CharOffset(RLine(Y), C); C1 = ScreenPos(RLine(Y), P + 1); if (DelText(Y, C, C1 - C) == 0) return 0; } else { ELine *L = RLine(Y); int C = CharOffset(L, CP.Col); if (L->Count > 0 && L->Chars[C] == '\t') { /* We're on top of tab character. Skip over all spaces and tabs so that only the last space/tab gets deleted. */ while (C < L->Count && (L->Chars[C+1] == '\t' || L->Chars[C+1] == ' ')) C++; } if (DelText(Y, ScreenPos(L, C), 1) == 0) return 0; } } else if (LineJoin() == 0) return 0; if (BFI(this, BFI_WordWrap) == 2) { if (DoWrap(0) == 0) return 0; if (CP.Col >= LineLen(Y)) if (CP.Row < VCount - 1) { if (SetPos(BFI(this, BFI_LeftMargin), CP.Row + 1) == 0) return 0; } } if (BFI(this, BFI_Trim)) if (TrimLine(VToR(CP.Row)) == 0) return 0; return 1; }
int EBuffer::MoveWordRightX(int start) { PELine L = VLine(CP.Row); int C, P; int wS = start, wE = 1 - start; C = CP.Col; P = CharOffset(L, C); if (P >= L->Count) return 0; while ((P < L->Count) && (WGETBIT(Flags.WordChars, L->Chars[P]) == wS)) P++; while ((P < L->Count) && (WGETBIT(Flags.WordChars, L->Chars[P]) == wE)) P++; C = ScreenPos(L, P); return SetPos(C, CP.Row); }
int EBuffer::MoveWordOrCapEndRight() { PELine L = VLine(CP.Row); int C, P; C = CP.Col; P = CharOffset(L, C); if (P >= L->Count) return 0; while ((P < L->Count) && (WGETBIT(Flags.WordChars, L->Chars[P]) == 0)) P++; while ((P < L->Count) && (WGETBIT(Flags.CapitalChars, L->Chars[P]) == 1)) P++; while ((P < L->Count) && (WGETBIT(Flags.WordChars, L->Chars[P]) == 1) && (WGETBIT(Flags.CapitalChars, L->Chars[P]) == 0)) P++; C = ScreenPos(L, P); return SetPos(C, CP.Row); }
int EBuffer::KillWord() { int Y = VToR(CP.Row); if (CP.Col >= LineLen()) { if (KillChar() == 0) return 0; } else { PELine L = RLine(Y); int P = CharOffset(L, CP.Col); int C; int Class = ChClassK(L->Chars[P]); while ((P < L->Count) && (ChClassK(L->Chars[P]) == Class)) P++; C = ScreenPos(L, P); if (DelText(Y, CP.Col, C - CP.Col) == 0) return 0; } return 1; }
int EBuffer::MoveWordLeftX(int start) { if (CP.Col > 0) { int wS = start, wE = 1 - start; PELine L = VLine(CP.Row); int C, P; C = CP.Col; P = CharOffset(L, C); if (P > L->Count) P = L->Count; if (P > 0) { while ((P > 0) && (WGETBIT(Flags.WordChars, L->Chars[P - 1]) == wE)) P--; while ((P > 0) && (WGETBIT(Flags.WordChars, L->Chars[P - 1]) == wS)) P--; C = ScreenPos(L, P); return SetPos(C, CP.Row); } else return 0; } else return 0; }
int EBuffer::MoveWordOrCapEndLeft() { if (CP.Col > 0) { PELine L = VLine(CP.Row); int C, P; C = CP.Col; P = CharOffset(L, C); if (P > L->Count) P = L->Count; if (P > 0) { while ((P > 0) && (WGETBIT(Flags.WordChars, L->Chars[P - 1]) == 1) && (WGETBIT(Flags.CapitalChars, L->Chars[P - 1]) == 0)) P--; while ((P > 0) && (WGETBIT(Flags.CapitalChars, L->Chars[P - 1]) == 1)) P--; while ((P > 0) && (WGETBIT(Flags.WordChars, L->Chars[P - 1]) == 0)) P--; C = ScreenPos(L, P); return SetPos(C, CP.Row); } else return 0; } else return 0; }
int EBuffer::KillWordOrCap() { int Y = VToR(CP.Row); if (CP.Col >= LineLen()) { if (KillChar() == 0) return 0; } else { PELine L = VLine(CP.Row); int P = CharOffset(L, CP.Col); int C; int Class = ChClassK(L->Chars[P]); if (Class == 1) { if (WGETBIT(Flags.CapitalChars, L->Chars[P]) == 1) while ((P < L->Count) && (WGETBIT(Flags.CapitalChars, L->Chars[P]) == 1)) P++; while ((P < L->Count) && (WGETBIT(Flags.WordChars, L->Chars[P]) == 1) && (WGETBIT(Flags.CapitalChars, L->Chars[P]) == 0)) P++; } else while ((P < L->Count) && (ChClassK(L->Chars[P]) == Class)) P++; C = ScreenPos(L, P); if (DelText(Y, CP.Col, C - CP.Col) == 0) return 0; } return 1; }
int EBuffer::KillWordPrev() { int Y = VToR(CP.Row); if (CP.Col == 0) { if (KillCharPrev() == 0) return 0; } else if (CP.Col > LineLen()) { if (SetPos(LineLen(), CP.Row) == 0) return 0; } else { PELine L = RLine(Y); int P = CharOffset(L, CP.Col); int C; int Class = ChClassK(L->Chars[P - 1]); while ((P > 0) && (ChClassK(L->Chars[P - 1]) == Class)) P--; C = ScreenPos(L, P); if (DelText(Y, C, CP.Col - C) == 0) return 0; if (SetPos(C, CP.Row) == 0) return 0; } return 1; }
int WinWindowCapture::Left() { return ScreenPos().x + Rect().left; }
int EBuffer::GetMatchBrace(EPoint &M, int MinLine, int MaxLine, int show) { int StateLen; hsState *StateMap = 0; int Pos; PELine L = VLine(M.Row); int dir = 0; hsState State; char Ch1, Ch2; int CountX = 0; int StateRow = -1; M.Row = VToR(CP.Row); Pos = CharOffset(L, M.Col); if (Pos >= L->Count) return 0; switch (L->Chars[Pos]) { case '{': dir = + 1; Ch1 = '{'; Ch2 = '}'; break; case '[': dir = + 1; Ch1 = '['; Ch2 = ']'; break; case '<': dir = + 1; Ch1 = '<'; Ch2 = '>'; break; case '(': dir = + 1; Ch1 = '('; Ch2 = ')'; break; case '}': dir = -1; Ch1 = '}'; Ch2 = '{'; break; case ']': dir = -1; Ch1 = ']'; Ch2 = '['; break; case '>': dir = -1; Ch1 = '>'; Ch2 = '<'; break; case ')': dir = -1; Ch1 = ')'; Ch2 = '('; break; default: return 0; } StateMap = 0; if (GetMap(M.Row, &StateLen, &StateMap) == 0) return 0; State = StateMap[Pos]; StateRow = M.Row; while (M.Row >= MinLine && M.Row < MaxLine) { while (Pos >= 0 && Pos < L->Count) { if (L->Chars[Pos] == Ch1 || L->Chars[Pos] == Ch2) { // update syntax state if needed if (StateRow != M.Row) { free(StateMap); StateMap = 0; GetMap(M.Row, &StateLen, &StateMap); if (StateMap == 0) return 0; StateRow = M.Row; } if (StateMap[Pos] == State) { if (L->Chars[Pos] == Ch1) CountX++; if (L->Chars[Pos] == Ch2) CountX--; if (CountX == 0) { M.Col = ScreenPos(L, Pos); free(StateMap); return 1; } } } Pos += dir; } M.Row += dir; if (M.Row >= 0 && M.Row < RCount) { L = RLine(M.Row); Pos = (dir == 1) ? 0 : (L->Count - 1); } } if (StateMap) free(StateMap); if (show) Msg(S_INFO, "No match (%d missing).", CountX); return 0; }
int EBuffer::FindStr(const char *Data, int Len, SearchReplaceOptions &opt) { int Options = opt.Options; int LLen, Start, End; int C, L; PELine X; char *P; if (Options & SEARCH_RE) return 0; if (Len <= 0) return 0; if (Options & SEARCH_NOPOS) { C = Match.Col; L = Match.Row; } else { C = CP.Col; L = VToR(CP.Row); } if (Match.Row != -1) Draw(Match.Row, Match.Row); Match.Row = -1; Match.Col = -1; X = RLine(L); C = CharOffset(X, C); if (Options & SEARCH_NEXT) { int CC = MatchCount ? 1 : 0; if (Options & SEARCH_BACK) { C -= CC; if (C < 0) { if (L == 0) return 0; L--; X = RLine(L); C = X->Count; } } else { if (Options & SEARCH_REPLACE && opt.lastInsertLen > 0) { C += CC * opt.lastInsertLen; // 0 or opt.lastInsertLen } else { C += CC; } if (C >= X->Count) { C = 0; L++; if (L == RCount) return 0; } } } MatchLen = 0; MatchCount = 0; if (Options & SEARCH_BLOCK) { if (Options & SEARCH_BACK) { if (BlockMode == bmStream) { if (L > BE.Row) { L = BE.Row; C = BE.Col; } if (L == BE.Row && C > BE.Col) C = BE.Col; } else { if (L >= BE.Row && BE.Row > 0) { L = BE.Row - 1; C = RLine(L)->Count; } if (BlockMode == bmColumn) if (L == BE.Row - 1 && C >= BE.Col) C = BE.Col; } } else { if (L < BB.Row) { L = BB.Row; C = 0; } if (L == BB.Row && C < BB.Col) C = BB.Col; } } while (1) { if (Options & SEARCH_BLOCK) { if (BlockMode == bmStream) { if (L > BE.Row || L < BB.Row) break; } else if (L >= BE.Row || L < BB.Row) break; } else if (L >= RCount || L < 0) break; X = RLine(L); LLen = X->Count; P = X->Chars; Start = 0; End = LLen; if (Options & SEARCH_BLOCK) { if (BlockMode == bmColumn) { Start = CharOffset(X, BB.Col); End = CharOffset(X, BE.Col); } else if (BlockMode == bmStream) { if (L == BB.Row) Start = CharOffset(X, BB.Col); if (L == BE.Row) End = CharOffset(X, BE.Col); } } if (Options & SEARCH_BACK) { if (C >= End - Len) C = End - Len; } else { if (C < Start) C = Start; } while (((!(Options & SEARCH_BACK)) && (C <= End - Len)) || ((Options & SEARCH_BACK) && (C >= Start))) { if ((!(Options & SEARCH_WORDBEG) || (C == 0) || (WGETBIT(Flags.WordChars, P[C - 1]) == 0)) && (!(Options & SEARCH_WORDEND) || (C + Len >= End) || (WGETBIT(Flags.WordChars, P[C + Len]) == 0)) && ((!(Options & SEARCH_NCASE) && (P[C] == Data[0]) && (memcmp(P + C, Data, Len) == 0)) || ((Options & SEARCH_NCASE) && (toupper(P[C]) == toupper(Data[0])) && (strnicmp(P + C, Data, Len) == 0))) /* && BOL | EOL */ ) { Match.Col = ScreenPos(X, C); Match.Row = L; MatchCount = Len; MatchLen = ScreenPos(X, C + Len) - Match.Col; if (!(Options & SEARCH_NOPOS)) { if (Options & SEARCH_CENTER) CenterPosR(Match.Col, Match.Row); else SetPosR(Match.Col, Match.Row); } Draw(L, L); return 1; } if (Options & SEARCH_BACK) C--; else C++; } if (Options & SEARCH_BACK) { L--; if (L >= 0) C = RLine(L)->Count; } else { C = 0; L++; } } //SetPos(OC, OL); return 0; }
int EBuffer::FindRx(RxNode *Rx, SearchReplaceOptions &opt) { int Options = opt.Options; int LLen, Start, End; int C, L; char *P; PELine X; RxMatchRes b; if (!(Options & SEARCH_RE)) return 0; if (Options & SEARCH_BACK) { // not supported View->MView->Win->Choice(GPC_ERROR, "FindRx", 1, "O&K", "Reverse regexp search not supported."); return 0; } if (Rx == 0) return 0; if (Match.Row != -1) Draw(Match.Row, Match.Row); Match.Row = -1; Match.Col = -1; C = CP.Col; L = VToR(CP.Row); X = RLine(L); C = CharOffset(X, C); if (Options & SEARCH_NEXT) { int CC = MatchCount ? MatchCount : 1; if (Options & SEARCH_BACK) { C -= CC; if (Options & SEARCH_BLOCK) { if (C < BB.Col && L == BB.Row) return 0; L--; X = RLine(L); C = X->Count; if (BlockMode == bmColumn) if (BE.Col < C) C = BE.Col; } else { if (C < 0 && L == 0) return 0; L--; X = RLine(L); C = X->Count; } } else { C += CC; if (Options & SEARCH_BLOCK) { if (BlockMode == bmStream || BlockMode == bmLine) { if (C >= X->Count) { C = 0; L++; if (BlockMode == bmLine) { if (L == BE.Row) return 0; } else if (L == BE.Row && (C >= BE.Col || C >= X->Count)) return 0; } } else if (BlockMode == bmColumn) { if (C >= X->Count || C >= BE.Col) { C = BB.Col; L++; if (L == BE.Row) return 0; } } } else { if (C >= X->Count) { C = 0; L++; if (L == RCount) return 0; } } } } MatchLen = 0; MatchCount = 0; if (Options & SEARCH_BLOCK) { if (Options & SEARCH_BACK) { if (BlockMode == bmStream) { if (L > BE.Row) { L = BE.Row; C = BE.Col; } if (L == BE.Row && C > BE.Col) C = BE.Col; } else { if (L >= BE.Row && BE.Row > 0) { L = BE.Row - 1; C = RLine(L)->Count; } if (BlockMode == bmColumn) if (L == BE.Row - 1 && C >= BE.Col) C = BE.Col; } } else { if (L < BB.Row) { L = BB.Row; C = 0; } if (L == BB.Row && C < BB.Col) C = BB.Col; } } while (1) { if (Options & SEARCH_BLOCK) { if (BlockMode == bmStream) { if (L > BE.Row || L < BB.Row) break; } else if (L >= BE.Row || L < BB.Row) break; } else if (L >= RCount || L < 0) break; X = RLine(L); LLen = X->Count; P = X->Chars; Start = 0; End = LLen; if (Options & SEARCH_BLOCK) { if (BlockMode == bmColumn) { Start = CharOffset(X, BB.Col); End = CharOffset(X, BE.Col); } else if (BlockMode == bmStream) { if (L == BB.Row) Start = CharOffset(X, BB.Col); if (L == BE.Row) End = CharOffset(X, BE.Col); } if (End > LLen) End = LLen; } if (Options & SEARCH_BACK) { if (C >= End) C = End; } else { if (C < Start) C = Start; } if (Start <= End) { if (RxExec(Rx, P + Start, End - Start, P + C, &b, (Options & SEARCH_NCASE) ? 0 : RX_CASE) == 1) { C = ScreenPos(X, b.Open[0] + Start); Match.Col = C; Match.Row = L; MatchCount = b.Close[0] - b.Open[0]; MatchLen = ScreenPos(X, b.Close[0] + Start) - C; for (int mm = 0; mm < NSEXPS; mm++) { b.Open[mm] += Start; b.Close[mm] += Start; } MatchRes = b; if (!(Options & SEARCH_NOPOS)) { if (Options & SEARCH_CENTER) CenterPosR(C, L); else SetPosR(C, L); } Draw(L, L); return 1; } } C = 0; L++; } //SetPos(OC, OL); return 0; }
void FDestructibleMeshEditorViewportClient::ProcessClick( class FSceneView& View, class HHitProxy* HitProxy, FKey Key, EInputEvent Event, uint32 HitX, uint32 HitY ) { #if WITH_APEX bool bKeepSelection = Viewport->KeyState(EKeys::LeftControl) || Viewport->KeyState(EKeys::RightControl); bool bSelectionChanged = false; if (Key == EKeys::LeftMouseButton && Event == EInputEvent::IE_Released) { UDestructibleComponent* Comp = PreviewDestructibleComp.Get(); NxDestructibleAsset* Asset = Comp->DestructibleMesh->ApexDestructibleAsset; const NxRenderMeshAsset* RenderMesh = Asset->getRenderMeshAsset(); FVector2D ScreenPos(HitX, HitY); FVector ClickOrigin, ViewDir; View.DeprojectFVector2D(ScreenPos, ClickOrigin, ViewDir); float NearestHitDistance = FLT_MAX; int32 ClickedChunk = -1; for (uint32 i=0; i < Asset->getChunkCount(); ++i) { int32 PartIdx = Asset->getPartIndex(i); int32 BoneIdx = i+1; if (!Comp->IsBoneHidden(BoneIdx)) { PxBounds3 PBounds = RenderMesh->getBounds(PartIdx); FVector Center = P2UVector(PBounds.getCenter()) + Comp->GetBoneLocation(Comp->GetBoneName(BoneIdx)); FVector Extent = P2UVector(PBounds.getExtents()); FBox Bounds(Center - Extent, Center + Extent); FVector HitLoc, HitNorm; float HitTime; if (FMath::LineExtentBoxIntersection(Bounds, ClickOrigin, ClickOrigin + ViewDir * 1000.0f, FVector(0,0,0), HitLoc, HitNorm, HitTime)) { float dist = (HitLoc - ClickOrigin).SizeSquared(); if (dist < NearestHitDistance) { NearestHitDistance = dist; ClickedChunk = i; } } } } if (ClickedChunk >= 0) { int32 Idx = SelectedChunkIndices.Find(ClickedChunk); if (Idx < 0) { if (!bKeepSelection) { SelectedChunkIndices.Empty(); } SelectedChunkIndices.Add(ClickedChunk); bSelectionChanged = true; } else { SelectedChunkIndices.RemoveAt(Idx); bSelectionChanged = true; } } else if (!bKeepSelection) { SelectedChunkIndices.Empty(); bSelectionChanged = true; } } if (bSelectionChanged) { UpdateChunkSelection(SelectedChunkIndices); } #endif // WITH_APEX }
int EBuffer::BackSpace() { int Y = VToR(CP.Row); if (CheckBlock() == 1 && BFI(this, BFI_BackSpKillBlock)) { if (BlockKill() == 0) return 0; } else if (BFI(this, BFI_WordWrap) == 2 && CP.Row > 0 && !IsLineBlank(Y - 1) && CP.Col <= BFI(this, BFI_LeftMargin) && CP.Col <= LineIndented(Y)) { if (SetPos(LineLen(Y - 1), CP.Row - 1) == 0) return 0; } else if (CP.Col == 0) { if (CP.Row > 0) if (ExposeRow(VToR(CP.Row) - 1) == 0) return 0; if (MoveUp() == 0) return 0; if (MoveLineEnd() == 0) return 0; if (LineJoin() == 0) return 0; } else { if (BFI(this, BFI_BackSpUnindents) && (LineIndented(Y) == CP.Col)) { int C = CP.Col, C1 = 0; int L = VToR(CP.Row); C1 = C; while (L > 0 && (IsLineBlank(L - 1) || (C1 = LineIndented(L - 1)) >= C)) L--; if (L == 0) C1 = 0; if (C1 == C) C1--; if (C1 < 0) C1 = 0; if (C1 > C) C1 = C; if (SetPos(C1, CP.Row) == 0) return 0; if (C > LineIndented(Y)) return 0; if (DelText(Y, C1, C - C1) == 0) return 0; if (BFI(this, BFI_Insert) == 0) if (InsText(Y, C1, 1, " ") == 0) return 0; } else if (BFI(this, BFI_BackSpKillTab)) { int P; int C = CP.Col, C1; P = CharOffset(RLine(Y), C - 1); C1 = ScreenPos(RLine(Y), P); if (SetPos(C1, CP.Row) == 0) return 0; if (DelText(Y, C1, C - C1) == 0) return 0; if (BFI(this, BFI_Insert) == 0) if (InsText(Y, C1, 1, " ") == 0) return 0; } else { if (MovePrev() == 0) return 0; ELine *L = RLine(Y); int C = CharOffset(L, CP.Col); if (L->Count > 0 && L->Chars[C] == 9) { /* We're on top of tab character. Skip over all spaces and tabs so that only the last space/tab gets deleted. */ while (C < L->Count && (L->Chars[C+1] == 9 || L->Chars[C+1] == ' ')) C++; } if (DelText(Y, ScreenPos(L, C), 1) == 0) return 0; if (BFI(this, BFI_Insert) == 0) if (InsText(Y, ScreenPos(L, C), 1, " ") == 0) return 0; } } if (BFI(this, BFI_WordWrap) == 2) { if (DoWrap(0) == 0) return 0; } if (BFI(this, BFI_Trim)) { Y = VToR(CP.Row); if (TrimLine(Y) == 0) return 0; } return 1; }
int EBuffer::DoWrap(int WrapAll) { int L, Len, C, P, Ind; PELine LP; int Left = BFI(this, BFI_LeftMargin), Right = BFI(this, BFI_RightMargin); int FirstParaLine; int NoChange = 0, NoChangeX = 0; if (Left >= Right) return 0; L = VToR(CP.Row); FirstParaLine = 0; if (L > 0) if (IsLineBlank(L - 1)) FirstParaLine = L; while (L < RCount) { NoChange = 1; if (VToR(CP.Row) != L || L != FirstParaLine) { if (VToR(CP.Row) == L) if (CP.Col <= LineIndented(L)) if (SetPos(Left, CP.Row) == 0) WFAIL(1); Ind = IndentLine(L, Left); if (VToR(CP.Row) == L) if (SetPos((CP.Col + Ind > 0) ? CP.Col + Ind : 0, CP.Row) == 0) WFAIL(2); NoChange = 0; } Len = LineLen(L); if (IsLineBlank(L)) break; if (Len < Right) { int firstwordbeg = -1; int firstwordend = -1; int X; PELine lp; if (L < RCount - 1) { IndentLine(L + 1, 0); if ((ScreenPos(RLine(L + 1), RLine(L + 1)->Count) == 0) || (RLine(L + 1)->Chars[0] == '>') || (RLine(L + 1)->Chars[0] == '<')) break; } else break; if (L + 1 >= RCount) break; lp = RLine(L + 1); for (X = 0; X < lp->Count; X++) { if (firstwordbeg == -1 && ((lp->Chars[X] != ' ') && (lp->Chars[X] != '\t'))) { firstwordbeg = X; } else if (firstwordend == -1 && ((lp->Chars[X] == ' ' || lp->Chars[X] == '\t'))) { firstwordend = X - 1; } } if (firstwordbeg != -1) if (firstwordend == -1) firstwordend = lp->Count; if (firstwordend == -1) break; if (Right - Len > firstwordend - firstwordbeg) { if (JoinLine(L, Len + 1) == 0) WFAIL(3); NoChange = 0; continue; } else IndentLine(L + 1, Left); } else if (Len > Right) { C = Right; P = CharOffset(LP = RLine(L), C); while ((C > Left) && ((LP->Chars[P] != ' ') && (LP->Chars[P] != 9))) C = ScreenPos(LP, --P); if (P <= Left) { L++; continue; } C = ScreenPos(LP, P); if (SplitLine(L, C) == 0) WFAIL(4); IndentLine(L + 1, Left); if (L < RCount - 2 && LineLen(L + 1) == Left) { if (!IsLineBlank(L + 2)) { if (JoinLine(L + 1, Left) == 0) WFAIL(5); } } if (L == VToR(CP.Row) && CP.Col > C) { if (SetPos(Left + CP.Col - C - 1, CP.Row + 1) == 0) WFAIL(6); } NoChange = 0; L++; continue; } if (WrapAll == 0) if (NoChangeX) { //printf("\n\nBreak OUT = %d\n\x7", L); break; } L++; NoChangeX = NoChange; } if (WrapAll == 1) if (SetPosR(Left, (L < RCount - 2) ? (L + 2) : (L < RCount - 1) ? (L + 1) : (RCount - 1)) == 0) WFAIL(7); return 1; }
int WinWindowCapture::Top() { return ScreenPos().y + Rect().top; }