Merge branch 'rr1-maint'
Conflicts: include/core/movie.hpp src/platform/wxwidgets/editor-movie.cpp
This commit is contained in:
commit
4e2db8416d
2 changed files with 96 additions and 18 deletions
|
@ -269,6 +269,10 @@ public:
|
|||
* Recount frames.
|
||||
*/
|
||||
void recount_frames() { frames_in_movie = movie_data.count_frames(); }
|
||||
/**
|
||||
* Adjust frame count.
|
||||
*/
|
||||
void adjust_frame_count(int64_t adjust) { frames_in_movie += adjust; }
|
||||
private:
|
||||
//Sequence number.
|
||||
uint64_t seqno;
|
||||
|
|
|
@ -20,14 +20,16 @@ enum
|
|||
{
|
||||
wxID_TOGGLE = wxID_HIGHEST + 1,
|
||||
wxID_CHANGE,
|
||||
wxID_APPEND_FRAME
|
||||
wxID_APPEND_FRAME,
|
||||
wxID_CHANGE_LINECOUNT,
|
||||
wxID_INSERT_AFTER
|
||||
};
|
||||
|
||||
void update_movie_state();
|
||||
|
||||
namespace
|
||||
{
|
||||
const unsigned lines_to_display = 28;
|
||||
unsigned lines_to_display = 28;
|
||||
uint64_t divs[] = {1000000, 100000, 10000, 1000, 100, 10, 1};
|
||||
uint64_t divsl[] = {1000000, 100000, 10000, 1000, 100, 10, 0};
|
||||
const unsigned divcnt = sizeof(divs)/sizeof(divs[0]);
|
||||
|
@ -347,6 +349,7 @@ private:
|
|||
int movielines;
|
||||
int moviepos;
|
||||
unsigned new_width;
|
||||
unsigned new_height;
|
||||
std::vector<uint8_t> pixels;
|
||||
int scroll_delta;
|
||||
unsigned press_x;
|
||||
|
@ -354,9 +357,11 @@ private:
|
|||
unsigned press_index;
|
||||
bool pressed;
|
||||
bool recursing;
|
||||
uint64_t linecount;
|
||||
void do_toggle_buttons(unsigned idx, uint64_t row1, uint64_t row2);
|
||||
void do_alter_axis(unsigned idx, uint64_t row);
|
||||
void do_append_frames(uint64_t count);
|
||||
void do_insert_frame_after(uint64_t row);
|
||||
};
|
||||
_moviepanel* moviepanel;
|
||||
wxButton* closebutton;
|
||||
|
@ -375,9 +380,13 @@ namespace
|
|||
return cffs + fc.read_pollcount(pv, idx);
|
||||
}
|
||||
|
||||
void movie_framecount_change()
|
||||
void movie_framecount_change(int64_t adjust, bool known = true);
|
||||
void movie_framecount_change(int64_t adjust, bool known)
|
||||
{
|
||||
movb.get_movie().recount_frames();
|
||||
if(known)
|
||||
movb.get_movie().adjust_frame_count(adjust);
|
||||
else
|
||||
movb.get_movie().recount_frames();
|
||||
update_movie_state();
|
||||
graphics_driver_notify_status();
|
||||
}
|
||||
|
@ -393,6 +402,7 @@ wxeditor_movie::_moviepanel::_moviepanel(wxeditor_movie* v)
|
|||
m = v;
|
||||
Connect(wxEVT_PAINT, wxPaintEventHandler(_moviepanel::on_paint), NULL, this);
|
||||
new_width = 0;
|
||||
new_height = 0;
|
||||
moviepos = 0;
|
||||
scroll_delta = 0;
|
||||
spos = 0;
|
||||
|
@ -561,6 +571,7 @@ void wxeditor_movie::_moviepanel::do_toggle_buttons(unsigned idx, uint64_t row1,
|
|||
std::swap(_press_line, line);
|
||||
recursing = true;
|
||||
runemufn([idx, _press_line, line, _fcontrols]() {
|
||||
int64_t adjust = 0;
|
||||
if(!movb.get_movie().readonly_mode())
|
||||
return;
|
||||
uint64_t fedit = first_editable(*_fcontrols, idx);
|
||||
|
@ -569,10 +580,12 @@ void wxeditor_movie::_moviepanel::do_toggle_buttons(unsigned idx, uint64_t row1,
|
|||
if(i < fedit || i >= fv.size())
|
||||
continue;
|
||||
controller_frame cf = fv[i];
|
||||
_fcontrols->write_index(cf, idx, !_fcontrols->read_index(cf, idx));
|
||||
bool v = _fcontrols->read_index(cf, idx);
|
||||
_fcontrols->write_index(cf, idx, !v);
|
||||
adjust += (v ? -1 : 1);
|
||||
}
|
||||
if(idx == 0)
|
||||
movie_framecount_change();
|
||||
movie_framecount_change(adjust);
|
||||
});
|
||||
recursing = false;
|
||||
if(idx == 0)
|
||||
|
@ -630,11 +643,40 @@ void wxeditor_movie::_moviepanel::do_append_frames(uint64_t count)
|
|||
controller_frame_vector& fv = movb.get_movie().get_frame_vector();
|
||||
for(uint64_t i = 0; i < _count; i++)
|
||||
fv.append(fv.blank_frame(true));
|
||||
movie_framecount_change();
|
||||
movie_framecount_change(1);
|
||||
});
|
||||
recursing = false;
|
||||
}
|
||||
|
||||
void wxeditor_movie::_moviepanel::do_insert_frame_after(uint64_t row)
|
||||
{
|
||||
recursing = true;
|
||||
frame_controls* _fcontrols = &fcontrols;
|
||||
uint64_t _row = row;
|
||||
runemufn([_row, _fcontrols]() {
|
||||
if(!movb.get_movie().readonly_mode())
|
||||
return;
|
||||
controller_frame_vector& fv = movb.get_movie().get_frame_vector();
|
||||
uint64_t fedit = first_editable(*_fcontrols, 0);
|
||||
//Find the start of the next frame.
|
||||
uint64_t nframe = _row + 1;
|
||||
uint64_t vsize = fv.size();
|
||||
while(nframe < vsize && !fv[nframe].sync())
|
||||
nframe++;
|
||||
if(nframe < fedit)
|
||||
return;
|
||||
fv.append(fv.blank_frame(true));
|
||||
if(nframe < vsize) {
|
||||
//Okay, gotta copy all data after this point. nframe has to be at least 1.
|
||||
for(uint64_t i = vsize - 1; i >= nframe; i--)
|
||||
fv[i + 1] = fv[i];
|
||||
fv[nframe] = fv.blank_frame(true);
|
||||
}
|
||||
movie_framecount_change(1);
|
||||
});
|
||||
max_subframe = row;
|
||||
recursing = false;
|
||||
}
|
||||
|
||||
void wxeditor_movie::_moviepanel::on_mouse0(unsigned x, unsigned y, bool polarity)
|
||||
{
|
||||
|
@ -690,6 +732,25 @@ void wxeditor_movie::_moviepanel::on_popup_menu(wxCommandEvent& e)
|
|||
case wxID_APPEND_FRAME:
|
||||
do_append_frames(1);
|
||||
return;
|
||||
case wxID_INSERT_AFTER:
|
||||
do_insert_frame_after(press_line);
|
||||
return;
|
||||
case wxID_CHANGE_LINECOUNT:
|
||||
try {
|
||||
std::string text = pick_text(m, "Set number of lines", "Set number of lines visible:",
|
||||
(stringfmt() << lines_to_display).str());
|
||||
unsigned tmp = parse_value<unsigned>(text);
|
||||
if(tmp < 1 || tmp > 255)
|
||||
throw std::runtime_error("Value out of range");
|
||||
lines_to_display = tmp;
|
||||
} catch(canceled_exception& e) {
|
||||
return;
|
||||
} catch(std::exception& e) {
|
||||
wxMessageBox(wxT("Invalid value"), _T("Error"), wxICON_EXCLAMATION | wxOK, m);
|
||||
return;
|
||||
}
|
||||
signal_repaint();
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -699,36 +760,45 @@ void wxeditor_movie::_moviepanel::on_mouse2(unsigned x, unsigned y, bool polarit
|
|||
{
|
||||
if(polarity)
|
||||
return;
|
||||
if(y < 3)
|
||||
return;
|
||||
if(!movb.get_movie().readonly_mode())
|
||||
return;
|
||||
press_x = x;
|
||||
press_line = spos + y - 3;
|
||||
wxMenu menu;
|
||||
bool on_button = false;
|
||||
bool on_axis = false;
|
||||
bool on_frame = false;
|
||||
std::string title;
|
||||
if(y < 3)
|
||||
goto outrange;
|
||||
if(!movb.get_movie().readonly_mode())
|
||||
goto outrange;
|
||||
press_x = x;
|
||||
press_line = spos + y - 3;
|
||||
for(auto i : fcontrols.get_controlinfo()) {
|
||||
unsigned off = divcnt + 1;
|
||||
if(press_x >= i.position_left + off && press_x < i.position_left + i.reserved + off) {
|
||||
if(i.type == 0 && press_line >= first_editable(fcontrols, i.index)) {
|
||||
if(i.type == 0 && press_line >= first_editable(fcontrols, i.index) &&
|
||||
press_line < linecount) {
|
||||
on_button = true;
|
||||
press_index = i.index;
|
||||
title = i.title;
|
||||
}
|
||||
if(i.type == 1 && press_line >= first_editable(fcontrols, i.index)) {
|
||||
if(i.type == 1 && press_line >= first_editable(fcontrols, i.index) &&
|
||||
press_line < linecount) {
|
||||
on_axis = true;
|
||||
press_index = i.index;
|
||||
title = i.title;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(press_line + 1 >= first_editable(fcontrols, 0) && press_line < linecount)
|
||||
on_frame = true;
|
||||
if(on_button)
|
||||
menu.Append(wxID_TOGGLE, wxT("Toggle " + title));
|
||||
if(on_axis)
|
||||
menu.Append(wxID_CHANGE, wxT("Change " + title));
|
||||
if(on_frame)
|
||||
menu.Append(wxID_INSERT_AFTER, wxT("Insert frame after"));
|
||||
menu.Append(wxID_APPEND_FRAME, wxT("Append frame"));
|
||||
outrange:
|
||||
menu.Append(wxID_CHANGE_LINECOUNT, wxT("Change number of lines visible"));
|
||||
menu.Connect(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(wxeditor_movie::_moviepanel::on_popup_menu),
|
||||
NULL, this);
|
||||
PopupMenu(&menu);
|
||||
|
@ -746,9 +816,9 @@ void wxeditor_movie::_moviepanel::signal_repaint()
|
|||
return;
|
||||
auto s = m->get_scroll();
|
||||
requested = true;
|
||||
int lines, width;
|
||||
int lines, width, height;
|
||||
wxeditor_movie* m2 = m;
|
||||
runemufn([&lines, &width, m2, this]() {
|
||||
runemufn([&lines, &width, &height, m2, this]() {
|
||||
lines = this->get_lines();
|
||||
if(lines < lines_to_display)
|
||||
this->moviepos = 0;
|
||||
|
@ -757,20 +827,24 @@ void wxeditor_movie::_moviepanel::signal_repaint()
|
|||
this->render(fb, moviepos);
|
||||
auto x = fb.get_characters();
|
||||
width = x.first;
|
||||
height = x.second;
|
||||
});
|
||||
int prev_width = new_width;
|
||||
int prev_height = new_height;
|
||||
new_width = width;
|
||||
new_height = height;
|
||||
if(s)
|
||||
s->SetScrollbar(moviepos, lines_to_display, lines, lines_to_display - 1);
|
||||
auto size = fb.get_pixels();
|
||||
pixels.resize(size.first * size.second * 3);
|
||||
fb.render((char*)&pixels[0]);
|
||||
if(prev_width != new_width) {
|
||||
if(prev_width != new_width || prev_height != new_height) {
|
||||
auto cell = fb.get_cell();
|
||||
SetMinSize(wxSize(new_width * cell.first, (lines_to_display + 3) * cell.second));
|
||||
if(new_width > 0 && s)
|
||||
m->Fit();
|
||||
}
|
||||
linecount = lines;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue