void VisualToolDrag::OnFrameChanged() { if (primary && !IsDisplayed(primary->line)) primary = 0; feature_iterator feat = features.begin(); feature_iterator end = features.end(); for (auto diag : c->ass->Line | agi::of_type<AssDialogue>()) { if (IsDisplayed(diag)) { // Features don't exist and should if (feat == end || feat->line != diag) MakeFeatures(diag, feat); // Move past already existing features for the line else while (feat != end && feat->line == diag) ++feat; } else { // Remove all features for this line (if any) while (feat != end && feat->line == diag) { if (feat == active_feature) active_feature = features.end(); feat->line = 0; RemoveSelection(feat); feat = features.erase(feat); } } } }
//-------------------------------------------------------------------------------- CStatus::CStatus(eLevel nLevel, LPCTSTR pMsg, CResult* pRes, long nThreadId, LPCTSTR pObjName, LPCTSTR pFuncName) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); m_nRefCount++; if(! IsDisplayed(nLevel)) return; CStatusOutThreadMsgParam* pParam = new CStatusOutThreadMsgParam(nLevel, pMsg, pRes, nThreadId, pObjName, pFuncName, this); if(m_pOutThread == NULL) { m_pOutThread = (CStatusOutThread*) ::AfxBeginThread(RUNTIME_CLASS(CStatusOutThread)); if(m_pOutThread == NULL) return; ::Sleep(1000); } m_pOutThread->PostThreadMessage(CStatusOutThread::OUTPUT, (WPARAM)pParam, 0); if(m_pOutThreads != NULL) { for(int i = 0; i < m_pOutThreads->GetSize(); i++) { CStatusOutThreadMsgParam* pParam2 = new CStatusOutThreadMsgParam(*pParam); m_pOutThreads->GetAt(i)->PostThreadMessage(CStatusOutThread::OUTPUT, (WPARAM)pParam2, 0); } } }
void PageGraphicsItem::paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *w) { if (Invalid_ && IsDisplayed ()) { auto backendObj = Doc_->GetBackendPlugin (); if (qobject_cast<IBackendPlugin*> (backendObj)->IsThreaded ()) { if (!RenderFuture_) RequestThreadedRender (); auto size = Doc_->GetPageSize (PageNum_); size.rwidth () *= XScale_; size.rheight () *= YScale_; QPixmap px (size); px.fill (); setPixmap (px); } else { const auto& img = Doc_->RenderPage (PageNum_, XScale_, YScale_); setPixmap (QPixmap::fromImage (img)); } Invalid_ = false; Core::Instance ().GetPixmapCacheManager ()->PixmapChanged (this); } QGraphicsPixmapItem::paint (painter, option, w); Core::Instance ().GetPixmapCacheManager ()->PixmapPainted (this); }
void VisualToolBase::OnActiveLineChanged(AssDialogue *new_line) { if (!IsDisplayed(new_line)) new_line = nullptr; holding = false; dragging = false; if (new_line != active_line) { active_line = new_line; OnLineChanged(); parent->Render(); } }
void VisualToolDrag::OnFileChanged() { /// @todo it should be possible to preserve the selection in some cases features.clear(); sel_features.clear(); primary = 0; active_feature = features.end(); for (auto diag : c->ass->Line | agi::of_type<AssDialogue>()) { if (IsDisplayed(diag)) MakeFeatures(diag); } UpdateToggleButtons(); }
///////////////////////// // Selects visible lines void BaseGrid::SelectVisible() { int rows = GetRows(); bool selectedOne = false; for (int i=0;i<rows;i++) { if (IsDisplayed(GetDialogue(i))) { if (!selectedOne) { SelectRow(i,false); MakeCellVisible(i,0); selectedOne = true; } else { SelectRow(i,true); } } } }
//-------------------------------------------------------------------------------- int CStatus::Error(LPCTSTR pFormat, ...) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); if(! IsDisplayed()) return 0; va_list marker; va_start(marker, pFormat); char temp[2048]; int nCount = vsprintf(temp, pFormat, marker); CStatus(temp, EVENTLOG_ERROR_TYPE); return nCount; }
//-------------------------------------------------------------------------------- int CStatus::Log(WORD nEventType, LPCTSTR pFormat, ...) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); if(! IsDisplayed()) return 0; va_list marker; va_start(marker, pFormat); char temp[2048]; int nCount = vsprintf(temp, pFormat, marker); CStatus(temp, nEventType); return nCount; }
//-------------------------------------------------------------------------------- int CStatus::Trace(CStatus::eLevel nLevel, LPCTSTR pFormat, ...) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); if(! IsDisplayed(nLevel)) return 0; va_list marker; va_start(marker, pFormat); char temp[2048]; int nCount = vsprintf(temp, pFormat, marker); CStatus(nLevel, temp); return nCount; }
void GOrgueSwitch::SetupCombinationState() { m_StoreDivisional = m_organfile->CombinationsStoreNonDisplayedDrawstops() || IsDisplayed(); m_StoreGeneral = m_organfile->CombinationsStoreNonDisplayedDrawstops() || IsDisplayed(); }
void GOrgueTremulant::SetupCombinationState() { m_StoreDivisional = m_organfile->DivisionalsStoreTremulants() && (m_organfile->CombinationsStoreNonDisplayedDrawstops() || IsDisplayed()); m_StoreGeneral = m_organfile->CombinationsStoreNonDisplayedDrawstops() || IsDisplayed(); }
////////////// // Draw image void BaseGrid::DrawImage(wxDC &dc) { dc.BeginDrawing(); // Get size and pos int w = 0; int h = 0; GetClientSize(&w,&h); // Set font dc.SetFont(font); // Clear background dc.SetBackground(wxBrush(Options.AsColour(_T("Grid Background")))); dc.Clear(); // Draw labels dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(wxBrush(Options.AsColour(_T("Grid left column")))); dc.DrawRectangle(0,lineHeight,colWidth[0],h-lineHeight); // Visible lines int drawPerScreen = h/lineHeight + 1; int nDraw = MID(0,drawPerScreen,GetRows()-yPos); int maxH = (nDraw+1) * lineHeight; // Row colors std::vector<wxBrush> rowColors; std::vector<wxColor> foreColors; rowColors.push_back(wxBrush(Options.AsColour(_T("Grid Background")))); // 0 = Standard foreColors.push_back(Options.AsColour(_T("Grid standard foreground"))); rowColors.push_back(wxBrush(Options.AsColour(_T("Grid Header")))); // 1 = Header foreColors.push_back(Options.AsColour(_T("Grid standard foreground"))); rowColors.push_back(wxBrush(Options.AsColour(_T("Grid selection background")))); // 2 = Selected foreColors.push_back(Options.AsColour(_T("Grid selection foreground"))); rowColors.push_back(wxBrush(Options.AsColour(_T("Grid comment background")))); // 3 = Commented foreColors.push_back(Options.AsColour(_T("Grid selection foreground"))); rowColors.push_back(wxBrush(Options.AsColour(_T("Grid inframe background")))); // 4 = Video Highlighted foreColors.push_back(Options.AsColour(_T("Grid selection foreground"))); rowColors.push_back(wxBrush(Options.AsColour(_T("Grid selected comment background")))); // 5 = Commented & selected foreColors.push_back(Options.AsColour(_T("Grid selection foreground"))); // First grid row bool drawGrid = true; if (drawGrid) { dc.SetPen(wxPen(Options.AsColour(_T("Grid lines")))); dc.DrawLine(0,0,w,0); dc.SetPen(*wxTRANSPARENT_PEN); } // Draw rows int dx = 0; int dy = 0; int curColor = 0; AssDialogue *curDiag; for (int i=0;i<nDraw+1;i++) { // Prepare int curRow = i+yPos-1; curDiag = GetDialogue(curRow); dx = 0; dy = i*lineHeight; // Check for collisions bool collides = false; if (curDiag) { AssDialogue *sel = GetDialogue(editBox->linen); if (sel && sel != curDiag) { if (curDiag->CollidesWith(sel)) collides = true; } } // Text array wxArrayString strings; // Header if (i == 0) { strings.Add(_("#")); strings.Add(_("L")); strings.Add(_("Start")); strings.Add(_("End")); strings.Add(_("Style")); strings.Add(_("Actor")); strings.Add(_("Effect")); strings.Add(_("Left")); strings.Add(_("Right")); strings.Add(_("Vert")); strings.Add(_("Text")); curColor = 1; } // Lines else if (curDiag) { // Set fields strings.Add(wxString::Format(_T("%i"),curRow+1)); strings.Add(wxString::Format(_T("%i"),curDiag->Layer)); if (byFrame) { strings.Add(wxString::Format(_T("%i"),VFR_Output.GetFrameAtTime(curDiag->Start.GetMS(),true))); strings.Add(wxString::Format(_T("%i"),VFR_Output.GetFrameAtTime(curDiag->End.GetMS(),true))); } else { strings.Add(curDiag->Start.GetASSFormated()); strings.Add(curDiag->End.GetASSFormated()); } strings.Add(curDiag->Style); strings.Add(curDiag->Actor); strings.Add(curDiag->Effect); strings.Add(curDiag->GetMarginString(1)); strings.Add(curDiag->GetMarginString(2)); strings.Add(curDiag->GetMarginString(3)); // Set text int mode = Options.AsInt(_T("Grid Hide Overrides")); wxString value = _T(""); // Hidden overrides if (mode == 1 || mode == 2) { wxString replaceWith = Options.AsText(_T("Grid hide overrides char")); curDiag->ParseASSTags(); size_t n = curDiag->Blocks.size(); for (size_t i=0;i<n;i++) { AssDialogueBlock *block = curDiag->Blocks.at(i); AssDialogueBlockPlain *plain = AssDialogueBlock::GetAsPlain(block); if (plain) { value += plain->GetText(); } else { if (mode == 1) { value += replaceWith; } } } curDiag->ClearBlocks(); } // Show overrides else value = curDiag->Text; // Cap length and set text if (value.Length() > 512) value = value.Left(512) + _T("..."); strings.Add(value); // Set color curColor = 0; bool inSel = IsInSelection(curRow,0); if (inSel && curDiag->Comment) curColor = 5; else if (inSel) curColor = 2; else if (curDiag->Comment) curColor = 3; else if (Options.AsBool(_T("Highlight subs in frame")) && IsDisplayed(curDiag)) curColor = 4; } else { for (int j=0;j<11;j++) strings.Add(_T("?")); } // Draw row background color if (curColor) { dc.SetBrush(rowColors[curColor]); dc.DrawRectangle((curColor == 1) ? 0 : colWidth[0],i*lineHeight+1,w,lineHeight); } // Set text color if (collides) dc.SetTextForeground(Options.AsColour(_T("Grid collision foreground"))); else { dc.SetTextForeground(foreColors[curColor]); } // Draw text wxRect cur; bool isCenter; for (int j=0;j<11;j++) { // Is center? isCenter = !(j == 4 || j == 5 || j == 6 || j == 10); // Calculate clipping cur = wxRect(dx+4,dy,colWidth[j]-6,lineHeight); // Set clipping dc.DestroyClippingRegion(); dc.SetClippingRegion(cur); // Draw dc.DrawLabel(strings[j],cur,isCenter ? wxALIGN_CENTER : (wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT)); dx += colWidth[j]; } //if (collides) dc.SetPen(wxPen(wxColour(255,0,0))); // Draw grid dc.DestroyClippingRegion(); if (drawGrid) { dc.SetPen(wxPen(Options.AsColour(_T("Grid lines")))); dc.DrawLine(0,dy+lineHeight,w,dy+lineHeight); dc.SetPen(*wxTRANSPARENT_PEN); } } // Draw grid columns dx = 0; if (drawGrid) { dc.SetPen(wxPen(Options.AsColour(_T("Grid lines")))); for (int i=0;i<10;i++) { dx += colWidth[i]; dc.DrawLine(dx,0,dx,maxH); } dc.DrawLine(0,0,0,maxH); dc.DrawLine(w-1,0,w-1,h); } // Draw currently active line border dc.SetPen(wxPen(Options.AsColour(_T("Grid Active border")))); dc.SetBrush(*wxTRANSPARENT_BRUSH); dy = (editBox->linen+1-yPos) * lineHeight; dc.DrawRectangle(0,dy,w,lineHeight+1); // Done dc.EndDrawing(); }
void PageGraphicsItem::UpdatePixmap () { Invalid_ = true; if (IsDisplayed ()) update (); }
AssDialogue* VisualToolBase::GetActiveDialogueLine() { AssDialogue *diag = c->selectionController->GetActiveLine(); if (IsDisplayed(diag)) return diag; return nullptr; }
void BaseGrid::DrawImage(wxDC &dc, bool paint_columns[]) { int w = 0; int h = 0; GetClientSize(&w,&h); w -= scrollBar->GetSize().GetWidth(); dc.SetFont(font); dc.SetBackground(rowColors[COLOR_DEFAULT]); dc.Clear(); // Draw labels dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(rowColors[COLOR_LEFT_COL]); dc.DrawRectangle(0,lineHeight,colWidth[0],h-lineHeight); // Visible lines int drawPerScreen = h/lineHeight + 1; int nDraw = mid(0,drawPerScreen,GetRows()-yPos); int maxH = (nDraw+1) * lineHeight; // Row colors wxColour text_standard(to_wx(OPT_GET("Colour/Subtitle Grid/Standard")->GetColor())); wxColour text_selection(to_wx(OPT_GET("Colour/Subtitle Grid/Selection")->GetColor())); wxColour text_collision(to_wx(OPT_GET("Colour/Subtitle Grid/Collision")->GetColor())); // First grid row wxPen grid_pen(to_wx(OPT_GET("Colour/Subtitle Grid/Lines")->GetColor())); dc.SetPen(grid_pen); dc.DrawLine(0, 0, w, 0); dc.SetPen(*wxTRANSPARENT_PEN); wxString strings[] = { _("#"), _("L"), _("Start"), _("End"), _("Style"), _("Actor"), _("Effect"), _("Left"), _("Right"), _("Vert"), _("Text") }; int override_mode = OPT_GET("Subtitle/Grid/Hide Overrides")->GetInt(); wxString replace_char; if (override_mode == 1) replace_char = lagi_wxString(OPT_GET("Subtitle/Grid/Hide Overrides Char")->GetString()); for (int i = 0; i < nDraw + 1; i++) { int curRow = i + yPos - 1; RowColor curColor = COLOR_DEFAULT; // Header if (i == 0) { curColor = COLOR_HEADER; dc.SetTextForeground(text_standard); } // Lines else if (AssDialogue *curDiag = GetDialogue(curRow)) { GetRowStrings(curRow, curDiag, paint_columns, strings, !!override_mode, replace_char); bool inSel = !!selection.count(curDiag); if (inSel && curDiag->Comment) curColor = COLOR_SELECTED_COMMENT; else if (inSel) curColor = COLOR_SELECTION; else if (curDiag->Comment) curColor = COLOR_COMMENT; else if (OPT_GET("Subtitle/Grid/Highlight Subtitles in Frame")->GetBool() && IsDisplayed(curDiag)) curColor = COLOR_VISIBLE; else curColor = COLOR_DEFAULT; if (active_line != curDiag && curDiag->CollidesWith(active_line)) dc.SetTextForeground(text_collision); else if (inSel) dc.SetTextForeground(text_selection); else dc.SetTextForeground(text_standard); } else { assert(false); } // Draw row background color if (curColor) { dc.SetBrush(rowColors[curColor]); dc.DrawRectangle((curColor == 1) ? 0 : colWidth[0],i*lineHeight+1,w,lineHeight); } // Draw text int dx = 0; int dy = i*lineHeight; for (int j = 0; j < 11; j++) { if (colWidth[j] == 0) continue; if (paint_columns[j]) { wxSize ext = dc.GetTextExtent(strings[j]); int left = dx + 4; int top = dy + (lineHeight - ext.GetHeight()) / 2; // Centered columns if (!(j == 4 || j == 5 || j == 6 || j == 10)) { left += (colWidth[j] - 6 - ext.GetWidth()) / 2; } dc.DrawText(strings[j], left, top); } dx += colWidth[j]; } // Draw grid dc.DestroyClippingRegion(); dc.SetPen(grid_pen); dc.DrawLine(0,dy+lineHeight,w,dy+lineHeight); dc.SetPen(*wxTRANSPARENT_PEN); } // Draw grid columns int dx = 0; dc.SetPen(grid_pen); for (int i=0;i<10;i++) { dx += colWidth[i]; dc.DrawLine(dx,0,dx,maxH); } dc.DrawLine(0,0,0,maxH); dc.DrawLine(w-1,0,w-1,maxH); // Draw currently active line border if (GetActiveLine()) { dc.SetPen(wxPen(to_wx(OPT_GET("Colour/Subtitle Grid/Active Border")->GetColor()))); dc.SetBrush(*wxTRANSPARENT_BRUSH); int dy = (line_index_map[GetActiveLine()]+1-yPos) * lineHeight; dc.DrawRectangle(0,dy,w,lineHeight+1); } }