mirror of https://github.com/odrling/Aegisub
Fixed crash on assistants and more tweaks to grid
Originally committed to SVN as r70.
This commit is contained in:
parent
f0351f6d27
commit
b8c0e2e7f8
|
@ -129,6 +129,7 @@ void BaseGrid::BeginBatch() {
|
|||
// End batch
|
||||
void BaseGrid::EndBatch() {
|
||||
//Thaw();
|
||||
AdjustScrollbar();
|
||||
}
|
||||
|
||||
|
||||
|
@ -147,8 +148,7 @@ void BaseGrid::MakeCellVisible(int row, int col) {
|
|||
|
||||
// Make visible
|
||||
if (forceCenter || row < minVis || row > maxVis) {
|
||||
yPos = MID(0,row - h/lineHeight/2 + 1,GetRows()+2 - h/lineHeight);
|
||||
scrollBar->SetThumbPosition(yPos);
|
||||
ScrollTo(row - h/lineHeight/2 + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,9 @@ void BaseGrid::OnPaint (wxPaintEvent &event) {
|
|||
bool direct = false;
|
||||
|
||||
if (direct) {
|
||||
dc.BeginDrawing();
|
||||
DrawImage(dc);
|
||||
dc.EndDrawing();
|
||||
}
|
||||
|
||||
else {
|
||||
|
@ -509,9 +511,7 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
|
|||
if (row > maxVis) delta = +1;
|
||||
|
||||
// Scroll
|
||||
yPos = MID(0,yPos+delta*3,GetRows()+2 - h/lineHeight);
|
||||
scrollBar->SetThumbPosition(yPos);
|
||||
Refresh(false);
|
||||
ScrollTo(yPos+delta*3);
|
||||
}
|
||||
|
||||
// Click
|
||||
|
@ -566,9 +566,7 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
|
|||
// Mouse wheel
|
||||
if (event.GetWheelRotation() != 0) {
|
||||
int step = 3 * event.GetWheelRotation() / event.GetWheelDelta();
|
||||
yPos = MID(0,yPos - step,GetRows()+2 - h/lineHeight);
|
||||
scrollBar->SetThumbPosition(yPos);
|
||||
Refresh(false);
|
||||
ScrollTo(yPos - step);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -576,21 +574,41 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
|
|||
}
|
||||
|
||||
|
||||
/////////////
|
||||
// Scroll to
|
||||
void BaseGrid::ScrollTo(int y) {
|
||||
int w,h;
|
||||
GetClientSize(&w,&h);
|
||||
int nextY = MID(0,y,GetRows()+2 - h/lineHeight);
|
||||
if (yPos != nextY) {
|
||||
yPos = nextY;
|
||||
if (scrollBar->IsEnabled()) scrollBar->SetThumbPosition(yPos);
|
||||
Refresh(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////
|
||||
// Adjust scrollbar
|
||||
void BaseGrid::AdjustScrollbar() {
|
||||
// Set size
|
||||
// Variables
|
||||
int w,h,sw,sh;
|
||||
GetClientSize(&w,&h);
|
||||
int drawPerScreen = h/lineHeight;
|
||||
int rows = GetRows();
|
||||
bool barToEnable = drawPerScreen < rows+2;
|
||||
bool barEnabled = scrollBar->IsEnabled();
|
||||
|
||||
// Set size
|
||||
scrollBar->Freeze();
|
||||
scrollBar->GetSize(&sw,&sh);
|
||||
scrollBar->SetSize(w-sw,0,sw,h);
|
||||
|
||||
// Set parameters
|
||||
int drawPerScreen = h/lineHeight;
|
||||
int rows = GetRows();
|
||||
scrollBar->SetScrollbar(yPos,drawPerScreen,rows+2,drawPerScreen-2,true);
|
||||
scrollBar->Enable(drawPerScreen < rows);
|
||||
if (barEnabled) {
|
||||
scrollBar->SetScrollbar(yPos,drawPerScreen,rows+2,drawPerScreen-2,true);
|
||||
}
|
||||
if (barToEnable != barEnabled) scrollBar->Enable(barToEnable);
|
||||
scrollBar->Thaw();
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,6 @@ class BaseGrid : public wxWindow {
|
|||
private:
|
||||
int lineHeight;
|
||||
int colWidth[16];
|
||||
int yPos;
|
||||
int lastRow;
|
||||
bool holding;
|
||||
wxFont font;
|
||||
|
@ -73,12 +72,14 @@ private:
|
|||
void OnScroll(wxScrollEvent &event);
|
||||
void OnMouseEvent(wxMouseEvent &event);
|
||||
|
||||
void AdjustScrollbar();
|
||||
void DrawImage(wxDC &dc);
|
||||
|
||||
protected:
|
||||
FrameMain *parentFrame;
|
||||
virtual void OnPopupMenu() {}
|
||||
void AdjustScrollbar();
|
||||
void ScrollTo(int y);
|
||||
int yPos;
|
||||
|
||||
public:
|
||||
SubsEditBox *editBox;
|
||||
|
|
|
@ -180,8 +180,9 @@ void DialogStyling::JumpToLine(int n) {
|
|||
if (n == -1) return;
|
||||
|
||||
// Get line
|
||||
line = grid->GetDialogue(n);
|
||||
if (!line) return;
|
||||
AssDialogue *nextLine = grid->GetDialogue(n);
|
||||
if (!nextLine) return;
|
||||
line = nextLine;
|
||||
|
||||
// Set number
|
||||
linen = n;
|
||||
|
|
|
@ -134,12 +134,14 @@ DialogTranslation::DialogTranslation (wxWindow *parent,AssFile *_subs,SubtitlesG
|
|||
// Jumps to line at block
|
||||
bool DialogTranslation::JumpToLine(int n,int block) {
|
||||
using std::vector;
|
||||
AssDialogue *nextLine;
|
||||
try {
|
||||
current = grid->GetDialogue(n);
|
||||
nextLine = grid->GetDialogue(n);
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
if (!current) return false;
|
||||
if (!nextLine) return false;
|
||||
current = nextLine;
|
||||
|
||||
// Count blocks
|
||||
int nblocks = 0;
|
||||
|
|
|
@ -814,6 +814,8 @@ void SubtitlesGrid::Clear () {
|
|||
//if (GetNumberRows() > 0) DeleteRows(0,GetNumberRows());
|
||||
diagMap.clear();
|
||||
selMap.clear();
|
||||
yPos = 0;
|
||||
AdjustScrollbar();
|
||||
}
|
||||
|
||||
|
||||
|
@ -869,6 +871,7 @@ void SubtitlesGrid::LoadFromAss (AssFile *_ass,bool keepSelection,bool dontModif
|
|||
|
||||
// Finish setting layout
|
||||
EndBatch();
|
||||
AdjustScrollbar();
|
||||
|
||||
// Commit
|
||||
if (!AssFile::Popping) {
|
||||
|
|
Loading…
Reference in New Issue