Skip to content

Commit

Permalink
Merge pull request #25 from darkxex/master
Browse files Browse the repository at this point in the history
Border Color Selector
  • Loading branch information
darkxex committed Feb 8, 2022
2 parents d45ba25 + b7f8594 commit de84856
Show file tree
Hide file tree
Showing 10 changed files with 208 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/apppopups.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace Popups {
void SaveSettingsPopup(void);
void ResumePopup(void);
void SubFontColorPopup(void);
void SubBorderColorPopup(void);
void PlaylistStartPlaylist(void);
void DBUpdatedPopup(void);
}
Expand Down
11 changes: 10 additions & 1 deletion include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ class Config{
float * getSubFontColor(bool tmpvalue);
std::string getSubFontColorHex(bool tmpvalue);
void setSubFontColor(float *_color);

//bordercolor
float * getSubBorderColor(bool tmpvalue);
std::string getSubBorderColorHex(bool tmpvalue);
void setSubBorderColor(float *_color);
//endbordercolor

int getDeinterlace(bool tmpvalue);
void setDeinterlace(int value);
Expand Down Expand Up @@ -114,7 +120,10 @@ class Config{
float subfontcolor[4];
float tmpsubfontcolor[4];


//bordercolor
float subbordercolor[4];
float tmpsubbordercolor[4];
//end bordercolor

int tmpstartresumeperc;
int tmpstopresumeperc;
Expand Down
1 change: 1 addition & 0 deletions include/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ enum APP_POPUP_STATES {
POPUP_STATE_ADDQUEUE,
POPUP_STATE_STARTPLAYLIST,
POPUP_STATE_SUBFONTCOLOR,
POPUP_STATE_SUBBORDERCOLOR,
POPUP_STATE_DBUPDATED
};

Expand Down
2 changes: 1 addition & 1 deletion include/libmpv.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class libMpv{
void setShadowIntensity(double value,bool osd);
void setShadowOffset(int value,bool osd);
void setSubFontColor(std::string hexcolor);

void setSubBorderColor(std::string hexcolor);
void setDeinterlace(int value);

void setLoop(bool val);
Expand Down
108 changes: 108 additions & 0 deletions source/UI/apppopups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,114 @@ namespace Popups{
}
}


static ImVec4 backup_color2;
static ImVec4 color2;
static bool saved_palette_init2 = true;
static ImVec4 saved_palette2[32] = {};

//bordercolor
void SubBorderColorPopup(void) {
if (saved_palette_init2)
{
for (int n = 0; n < IM_ARRAYSIZE(saved_palette2); n++)
{
ImGui::ColorConvertHSVtoRGB(n / 31.0f, 0.8f, 0.8f,
saved_palette2[n].x, saved_palette2[n].y, saved_palette2[n].z);
saved_palette2[n].w = 1.0f; // Alpha
}
saved_palette_init2 = false;
}
ImGui::SetNextWindowPos(ImVec2(0,0));
ImGui::OpenPopup("subbordercolorpicker");

if (ImGui::BeginPopup("subbordercolorpicker")) {
float * tmpcolor = configini->getSubBorderColor(true);
float * tmpcolor_backup = configini->getSubBorderColor(false);
color2 = ImVec4(tmpcolor[0],tmpcolor[1],tmpcolor[2],tmpcolor[3]);
backup_color2 = ImVec4(tmpcolor_backup[0],tmpcolor_backup[1],tmpcolor_backup[2],tmpcolor_backup[3]);
ImGui::Separator();
if(ImGui::ColorPicker3("##picker", (float*)&color2,ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_NoSidePreview | ImGuiColorEditFlags_NoSmallPreview)){
float setcolor[4];
setcolor[0] = color2.x;
setcolor[1] = color2.y;
setcolor[2] = color2.z;
setcolor[3] = color2.w;
configini->setSubBorderColor(setcolor);
}
ImGui::SameLine();

ImGui::BeginGroup(); // Lock X position
ImGui::Text("Current");
ImGui::ColorButton("##current", color2, ImGuiColorEditFlags_NoAlpha| ImGuiColorEditFlags_NoPicker , ImVec2(60, 40));
ImGui::Text("Previous");
if (ImGui::ColorButton("##previous", backup_color2, ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoPicker , ImVec2(60, 40))){
float setcolor[4];
setcolor[0] = backup_color2.x;
setcolor[1] = backup_color2.y;
setcolor[2] = backup_color2.z;
setcolor[3] = backup_color2.w;
configini->setSubBorderColor(setcolor);
}
ImGui::Separator();
ImGui::Text("Palette");
for (int n = 0; n < IM_ARRAYSIZE(saved_palette2); n++)
{
ImGui::PushID(n);
if ((n % 8) != 0)
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemSpacing.y);

ImGuiColorEditFlags palette_button_flags = ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_NoTooltip;
if (ImGui::ColorButton("##palette", saved_palette2[n], palette_button_flags, ImVec2(20, 20))){
//color = ImVec4(saved_palette[n].x, saved_palette[n].y, saved_palette[n].z, color.w); // Preserve alpha!
float setcolor[4];
setcolor[0] = saved_palette2[n].x;
setcolor[1] = saved_palette2[n].y;
setcolor[2] = saved_palette2[n].z;
setcolor[3] = color2.w;
configini->setSubBorderColor(setcolor);
}

// Allow user to drop colors into each palette entry. Note that ColorButton() is already a
// drag source by default, unless specifying the ImGuiColorEditFlags_NoDragDrop flag.
if (ImGui::BeginDragDropTarget())
{
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F))
memcpy((float*)&saved_palette2[n], payload->Data, sizeof(float) * 3);
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F))
memcpy((float*)&saved_palette2[n], payload->Data, sizeof(float) * 4);
ImGui::EndDragDropTarget();
}

ImGui::PopID();
}
if(ImGui::Button("Use Color")){
float setcolor[4];
setcolor[0] = color2.x;
setcolor[1] = color2.y;
setcolor[2] = color2.z;
setcolor[3] = color2.w;
configini->setSubBorderColor(setcolor);
libmpv->setSubBorderColor(configini->getSubBorderColorHex(true));
item.popupstate = POPUP_STATE_NONE;
}
ImGui::SameLine();
if(ImGui::Button("Cancel")){
item.popupstate = POPUP_STATE_NONE;
float setcolor[4];
setcolor[0] = backup_color2.x;
setcolor[1] = backup_color2.y;
setcolor[2] = backup_color2.z;
setcolor[3] = backup_color2.w;
configini->setSubBorderColor(setcolor);
}

ImGui::EndGroup();
ImGui::EndPopup();
}
}
//bordercolorend

void DBUpdatedPopup(void) {
Popups::SetupPopup("Database Updated");
if (ImGui::BeginPopupModal("Database Updated", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
Expand Down
12 changes: 12 additions & 0 deletions source/UI/playerWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,14 @@ namespace playerWindows{
if(ImGui::ColorButton("##subfontcolor", ImVec4(subcolor[0],subcolor[1],subcolor[2],subcolor[3]), ImGuiColorEditFlags_NoAlpha| ImGuiColorEditFlags_NoPicker|ImGuiColorEditFlags_InputRGB , ImVec2(190, 40))){
item.popupstate = POPUP_STATE_SUBFONTCOLOR;
}

//bordercolor
ImGui::Text("Sub Border Color");
float * subcolor2 = configini->getSubBorderColor(true);
if(ImGui::ColorButton("##subbordercolor", ImVec4(subcolor2[0],subcolor2[1],subcolor2[2],subcolor2[3]), ImGuiColorEditFlags_NoAlpha| ImGuiColorEditFlags_NoPicker|ImGuiColorEditFlags_InputRGB , ImVec2(190, 40))){
item.popupstate = POPUP_STATE_SUBBORDERCOLOR;
}
//endbordercolor

//ImGui::EndDisabled();
ImGui::SetCursorPosY(ImGui::GetWindowSize().y -50);
Expand All @@ -691,6 +699,10 @@ namespace playerWindows{
libmpv->setSubFontSize(drag_subfontsize,false);
configini->setSubFontColor(configini->getSubFontColor(false));
libmpv->setSubFontColor(configini->getSubFontColorHex(true));
//bordercolor
configini->setSubBorderColor(configini->getSubBorderColor(false));
libmpv->setSubBorderColor(configini->getSubBorderColorHex(true));
//endbordercolor
}
}
playerWindows::ExitWindow();
Expand Down
3 changes: 3 additions & 0 deletions source/UI/settingsMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ namespace Windows {

configini->setSubFontSize(configini->getSubFontSize(false));
configini->setSubFontColor(configini->getSubFontColor(false));
//bordercolor
configini->setSubBorderColor(configini->getSubBorderColor(false));
//endbordercolor
configini->setDbActive(configini->getDeinterlace(false));


Expand Down
55 changes: 55 additions & 0 deletions source/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,25 @@ Config::Config(std::string inifile){
tmpsubfontcolor[1] = subfontcolor[1] = (float)tmpcolors[1]/255.0f;
tmpsubfontcolor[2] = subfontcolor[2] = (float)tmpcolors[2]/255.0f;
tmpsubfontcolor[3] = subfontcolor[3] = 1.0f;

//bordercolor

std::string fontcolorstring2 = "#000000";
const char* fontcolorpv2;
fontcolorpv2 = ini->GetValue("Main", "subbordercolor");
if(fontcolorpv2!= nullptr){
fontcolorstring2 = fontcolorpv2;
}
if(fontcolorstring2 == ""){
fontcolorstring2 = "#000000";
}
int tmpcolors2[3];
sscanf(fontcolorstring2.c_str(),"#%02X%02X%02X",&tmpcolors2[0],&tmpcolors2[1],&tmpcolors2[2]);
tmpsubbordercolor[0] = subbordercolor[0] = (float)tmpcolors2[0]/255.0f;
tmpsubbordercolor[1] = subbordercolor[1] = (float)tmpcolors2[1]/255.0f;
tmpsubbordercolor[2] = subbordercolor[2] = (float)tmpcolors2[2]/255.0f;
tmpsubbordercolor[3] = subbordercolor[3] = 1.0f;
//endbordercolor

const char* deintpv;
deintpv = ini->GetValue("Main", "deinterlace");
Expand Down Expand Up @@ -336,6 +355,28 @@ void Config::setSubFontColor(float *_color){
tmpsubfontcolor[2] = _color[2];
}

//bordercolor
float * Config::getSubBorderColor(bool tmpvalue){
if(tmpvalue){
return tmpsubbordercolor;
}
return subbordercolor;
}
std::string Config::getSubBorderColorHex(bool tmpvalue){
char subfontcstr2[32];
if(tmpvalue){
sprintf(subfontcstr2,"#%02X%02X%02X",(unsigned int)(tmpsubbordercolor[0]*255.0f),(unsigned int)(tmpsubbordercolor[1]*255.0f),(unsigned int)(tmpsubbordercolor[2]*255.0f));
return std::string(subfontcstr2);
}
sprintf(subfontcstr2,"#%02X%02X%02X",(unsigned int)(subbordercolor[0]*255.0f),(unsigned int)(subbordercolor[1]*255.0f),(unsigned int)(subbordercolor[2]*255.0f));
return std::string(subfontcstr2);
}
void Config::setSubBorderColor(float *_color){
tmpsubbordercolor[0] = _color[0];
tmpsubbordercolor[1] = _color[1];
tmpsubbordercolor[2] = _color[2];
}
//endbordercolor

void Config::setDeinterlace(int value){
tmpdeint = value;
Expand Down Expand Up @@ -403,6 +444,12 @@ void Config::saveSettings(){
subfontcolor[1] = tmpsubfontcolor[1];
subfontcolor[2] = tmpsubfontcolor[2];

//bordercolor
subbordercolor[0] = tmpsubbordercolor[0];
subbordercolor[1] = tmpsubbordercolor[1];
subbordercolor[2] = tmpsubbordercolor[2];
//endbordercolor

themename = tmpthemename;


Expand Down Expand Up @@ -443,6 +490,14 @@ void Config::saveSettings(){
sprintf(subfontcstr,"#%02X%02X%02X",(unsigned int)subfontcolor[0]*255,(unsigned int)subfontcolor[1]*255,(unsigned int)subfontcolor[2]*255);
ini->SetValue("Main", "subfontcolor", subfontcstr);

//bordercolor
ini->Delete("Main", "subbordercolor");
char subfontcstr2[32];
sprintf(subfontcstr2,"#%02X%02X%02X",(unsigned int)subbordercolor[0]*255,(unsigned int)subbordercolor[1]*255,(unsigned int)subbordercolor[2]*255);
ini->SetValue("Main", "subbordercolor", subfontcstr2);

//endbordercolor

std::vector<std::string> deintopts = {"no","yes","auto"};
ini->Delete("Main", "deinterlace");
ini->SetValue("Main", "deinterlace", deintopts[deint].c_str());
Expand Down
10 changes: 10 additions & 0 deletions source/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,13 @@ namespace GUI {
}else{
item.rightmenustate = PLAYER_RIGHT_MENU_HOME;
}
//bordercolor
if(item.popupstate == POPUP_STATE_SUBBORDERCOLOR){
item.popupstate = POPUP_STATE_NONE;
configini->setSubBorderColor(configini->getSubBorderColor(false));
}else{
item.rightmenustate = PLAYER_RIGHT_MENU_HOME;
}
}
else if(item.rightmenustate == PLAYER_AUDIOEQ){
item.rightmenustate = PLAYER_RIGHT_MENU_AUDIO;
Expand Down Expand Up @@ -919,6 +926,9 @@ namespace GUI {
if(item.popupstate == POPUP_STATE_SUBFONTCOLOR){
Popups::SubFontColorPopup();
}
if(item.popupstate == POPUP_STATE_SUBBORDERCOLOR){
Popups::SubBorderColorPopup();
}
break;
case PLAYER_RIGHT_MENU_SHADERMANIA:
playerWindows::RightHomeShaderMania();
Expand Down
7 changes: 7 additions & 0 deletions source/libmpv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ void libMpv::loadFile(std::string _path){
setLoop(false);
setSubFontSize(configini->getSubFontSize(false),false);
setSubFontColor(configini->getSubFontColorHex(false));
setSubBorderColor(configini->getSubBorderColorHex(false));

}

Expand Down Expand Up @@ -609,6 +610,12 @@ void libMpv::setSubFontColor(std::string hexcolor){

}

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

}

void libMpv::setAudioEQ(int *eqval,bool osd){
char eqstring[1024];
sprintf(eqstring,"no-osd set af equalizer=f=64:width_type=o:w=3.3:g=%d,equalizer=f=400:width_type=o:w=2.0:g=%d,equalizer=f=1250:width_type=o:w=1.3:g=%d,equalizer=f=2830:width_type=o:w=1.0:g=%d,equalizer=f=5600:width_type=o:w=1.0:g=%d,equalizer=f=12500:width_type=o:w=1.3:g=%d",eqval[0],eqval[1],eqval[2],eqval[3],eqval[4],eqval[5]);
Expand Down

0 comments on commit de84856

Please sign in to comment.