Skip to content

Commit

Permalink
Merge pull request #16 from darkxex/master
Browse files Browse the repository at this point in the history
beautiful subtitle customization.
  • Loading branch information
darkxex authored Feb 7, 2022
2 parents b9083e2 + 5d5c2bc commit 899fbdb
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/libmpv.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class libMpv{
void setSubPos(int value,bool osd);
void setSubFontSize(int value,bool osd);
void setSubBorderSize(int value,bool osd);
void setShadowIntensity(double value,bool osd);
void setShadowOffset(int value,bool osd);
void setSubFontColor(std::string hexcolor);

void setDeinterlace(int value);
Expand Down
21 changes: 21 additions & 0 deletions source/UI/playerWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ namespace playerWindows{
static float drag_subdelay = 0.0f;
static int drag_subfontsize = 55;
static int drag_subfontbordersize = 3;
static int drag_shadowposition = 1;
static float drag_shadowintensity = 0.25f;

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"};
Expand Down Expand Up @@ -637,6 +639,20 @@ namespace playerWindows{
libmpv->setSubBorderSize(drag_subfontbordersize,item.playershowcontrols);
}
//endbordersize
//shadowintensity
ImGui::SetCursorPosX((windowWidth - ImGui::CalcTextSize("Shadow Intensity", NULL, true).x) * 0.5f);
ImGui::Text("Shadow Intensity");
if(ImGui::DragFloat("Shadow Intensity", &drag_shadowintensity, 0.010f, 0.0f, 1.0f, "%.3f", ImGuiSliderFlags_NoInput)){
libmpv->setShadowIntensity(drag_shadowintensity,item.playershowcontrols);
}
//shadowintensity
//shadowOffset
ImGui::SetCursorPosX((windowWidth - ImGui::CalcTextSize("Shadow Position", NULL, true).x) * 0.5f);
ImGui::Text("Shadow Position");
if(ImGui::DragInt("Shadow Position", &drag_shadowposition, 0.5f, 0, 5, "%d", ImGuiSliderFlags_NoInput)){
libmpv->setShadowOffset(drag_shadowposition,item.playershowcontrols);
}
//ShadowOffset
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 @@ -650,6 +666,11 @@ namespace playerWindows{
drag_subdelay = 0.0f;
drag_subfontsize = configini->getSubFontSize(false);
drag_subfontbordersize = 3;
drag_shadowposition = 1;
drag_shadowintensity = 0.25f;
libmpv->setShadowOffset(drag_shadowposition,false);
libmpv->setShadowIntensity(drag_shadowintensity,false);
libmpv->setSubBorderSize(drag_subfontbordersize,false);
libmpv->setSubPos(drag_subpos,false);
libmpv->setSubDelay(drag_subdelay,false);
libmpv->setSubFontSize(drag_subfontsize,false);
Expand Down
24 changes: 23 additions & 1 deletion source/libmpv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ libMpv::libMpv(const std::string &configDir) {
mpv_set_option_string(handle, "gpu-nxmp-deint", std::to_string(configini->getDeinterlace(false)).c_str());
mpv_set_option_string(handle, "volume-max", "200");
mpv_set_option_string(handle, "opengl-pbo", "yes");

//default Font Style
mpv_set_option_string(handle, "sub-border-size", "3");
mpv_set_option_string(handle, "sub-shadow-offset", "1");
mpv_set_option_string(handle, "sub-shadow-color", "0.0/0.0/0.0/0.25");


if(configini->getUseAlang(false)){
Expand Down Expand Up @@ -565,6 +568,25 @@ void libMpv::setSubBorderSize(int value,bool osd){
}
}

void libMpv::setShadowIntensity(double value,bool osd){
if(osd){
std::string cmd = "set sub-shadow-color 0.0/0.0/0.0/" + std::to_string(value);
mpv_command_string(handle, cmd.c_str());
}else{
std::string cmd = "no-osd set sub-shadow-color 0.0/0.0/0.0/" + std::to_string(value);
mpv_command_string(handle, cmd.c_str());
}
}

void libMpv::setShadowOffset(int value,bool osd){
if(osd){
std::string cmd = "set sub-shadow-offset " + std::to_string(value);
mpv_command_string(handle, cmd.c_str());
}else{
std::string cmd = "no-osd set sub-shadow-offset " + 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 899fbdb

Please sign in to comment.