Skip to content

Commit

Permalink
Merge pull request #15 from darkxex/master
Browse files Browse the repository at this point in the history
Better subtitle customization.
  • Loading branch information
darkxex authored Feb 7, 2022
2 parents 53f037e + ef5020b commit 75f202a
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"files.associations": {
"xstring": "cpp",
"string": "cpp"
}
}
1 change: 1 addition & 0 deletions include/libmpv.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class libMpv{
void setSubDelay(double value,bool osd);
void setSubPos(int value,bool osd);
void setSubFontSize(int value,bool osd);
void setSubBorderSize(int value,bool osd);
void setSubFontColor(std::string hexcolor);

void setDeinterlace(int value);
Expand Down
42 changes: 40 additions & 2 deletions source/UI/playerWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace playerWindows{
static int drag_gamma = 0;
static int drag_hue = 0;
static int rotateidx = 0;
static int ignorestyleidx = 0;
static int shaderidx = 0;


Expand All @@ -30,7 +31,8 @@ namespace playerWindows{
static int drag_subpos = 100;
static float drag_subdelay = 0.0f;
static int drag_subfontsize = 55;

static int drag_subfontbordersize = 3;

static int slider_eq[6] = {0,0,0,0,0,0};
static char slider_hz[][8] = {"20-200","200-800","800-2K","2K-4K","4K-8K","20K"};
static float slider_supereq[18] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
Expand Down Expand Up @@ -566,6 +568,35 @@ namespace playerWindows{
if (ImGui::Begin("Right Menu Sub", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar)) {
ImGui::PushItemWidth(200-10);
auto windowWidth = ImGui::GetWindowSize().x;
//ignore styles
ImGui::SetCursorPosX((windowWidth - ImGui::CalcTextSize("Embedded Styles", NULL, true).x) * 0.5f);
ImGui::PushItemWidth(200-10);
ImGui::Text("Embedded Styles");
std::vector<std::string> stylemenu = {"Activated","Deactivated"};
if (ImGui::BeginCombo("Embedded Styles", stylemenu[ignorestyleidx].c_str(), 0))
{
for (int n = 0; n < stylemenu.size(); n++)
{
const bool is_selected = (ignorestyleidx == n);
if (ImGui::Selectable(stylemenu[n].c_str(), is_selected)){
if(n == 0){
ignorestyleidx = 0;
mpv_command_string(libmpv->getHandle(),"set sub-ass yes ; no-osd seek -1");
}
if(n == 1){
ignorestyleidx = 1;
mpv_command_string(libmpv->getHandle(),"set sub-ass no ; no-osd seek -1");
}
}


if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
ImGui::PopItemWidth();
}
//end ignore styles
ImGui::SetCursorPosX((windowWidth - ImGui::CalcTextSize("Audio Delay", NULL, true).x) * 0.5f);
ImGui::Text("Sub Delay");
if(ImGui::DragFloat("Sub Delay", &drag_subdelay, 0.100f, -5.0f, 5.0f, "%.3f", ImGuiSliderFlags_NoInput)){
Expand All @@ -582,7 +613,13 @@ namespace playerWindows{
if(ImGui::DragInt("Sub Font Size", &drag_subfontsize, 0.5f, 1, 120, "%d", ImGuiSliderFlags_NoInput)){
libmpv->setSubFontSize(drag_subfontsize,item.playershowcontrols);
}

//bordersize
ImGui::SetCursorPosX((windowWidth - ImGui::CalcTextSize("Sub Border Size", NULL, true).x) * 0.5f);
ImGui::Text("Sub Border Size");
if(ImGui::DragInt("Sub Border Size", &drag_subfontbordersize, 0.5f, 0, 8, "%d", ImGuiSliderFlags_NoInput)){
libmpv->setSubBorderSize(drag_subfontbordersize,item.playershowcontrols);
}
//endbordersize
ImGui::Text("Sub Font Color");
float * subcolor = configini->getSubFontColor(true);
if(ImGui::ColorButton("##subfontcolor", ImVec4(subcolor[0],subcolor[1],subcolor[2],subcolor[3]), ImGuiColorEditFlags_NoAlpha| ImGuiColorEditFlags_NoPicker|ImGuiColorEditFlags_InputRGB , ImVec2(190, 40))){
Expand All @@ -595,6 +632,7 @@ namespace playerWindows{
drag_subpos = 100;
drag_subdelay = 0.0f;
drag_subfontsize = configini->getSubFontSize(false);
drag_subfontbordersize = 3;
libmpv->setSubPos(drag_subpos,false);
libmpv->setSubDelay(drag_subdelay,false);
libmpv->setSubFontSize(drag_subfontsize,false);
Expand Down
10 changes: 10 additions & 0 deletions source/libmpv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,16 @@ void libMpv::setSubFontSize(int value,bool osd){
}
}

void libMpv::setSubBorderSize(int value,bool osd){
if(osd){
std::string cmd = "set sub-border-size " + std::to_string(value);
mpv_command_string(handle, cmd.c_str());
}else{
std::string cmd = "no-osd set sub-border-size " + std::to_string(value);
mpv_command_string(handle, cmd.c_str());
}
}

void libMpv::setSubFontColor(std::string hexcolor){
std::string cmd = "no-osd set sub-color '" + hexcolor + std::string("'");
mpv_command_string(handle, cmd.c_str());
Expand Down

0 comments on commit 75f202a

Please sign in to comment.