text_font_scale_factor
Hi Guys, I want to change osd subtitles font size in runtime with key combination. I have some code and I can change text_font_scale_factor with step 0.1in runtime but which function I have to call after every text_font_scale_factor's change to apply the settings for running mplayer? Thanks in advance Toli
Hello, On Thu, Jul 05, 2007 at 11:44:10AM +0300, Anatoli Marinov wrote:
I want to change osd subtitles font size in runtime with key combination. I have some code and I can change text_font_scale_factor with step 0.1in runtime but which function I have to call after every text_font_scale_factor's change to apply the settings for running mplayer?
Try force_load_font = 1; Greetings, Reimar Doeffinger
It Works !!!! great :))) I want this feature for a long time :) it is very useful (for me and I hope for others). Is it possible to add my solution to the svn repository ? 2007/7/5, Reimar Doeffinger <Reimar.Doeffinger@stud.uni-karlsruhe.de>:
Hello, On Thu, Jul 05, 2007 at 11:44:10AM +0300, Anatoli Marinov wrote:
I want to change osd subtitles font size in runtime with key combination. I have some code and I can change text_font_scale_factor with step 0.1in runtime but which function I have to call after every text_font_scale_factor's change to apply the settings for running mplayer?
Try force_load_font = 1;
Greetings, Reimar Doeffinger _______________________________________________ MPlayer-dev-eng mailing list MPlayer-dev-eng@mplayerhq.hu http://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
Guys, May I post may patch here. It is quite simple but useful. I want to know your opinion about it? Toli
Hello, On Thu, Jul 05, 2007 at 02:30:10PM +0300, Anatoli Marinov wrote:
May I post may patch here. It is quite simple but useful.
I want to know your opinion about it?
Of course, that is the point of this list. If it will be accepted or not of course depends on whether it is clean enough or not. Greetings, Reimar Doeffinger
Hello, The attached file is my patch that enables runtime changing of osd font scale factor. Please let me know if there is something wrong and I will fix it as fast as I can. For me was so hard to find unused keys. Finally I've binded scale factor increment to *b* and decrement to *n* (default values). Of course if you have a different vision about that it will be ease for me to change them. In addition in the sources I saw that border values for text_font_scale_factor are from 0 to 100 but i think the usable values are from 0 to 10. Anatoli Marinov Bulgaria
On Fri, 06 Jul 2007 11:03:24 +0300, Anatoli Marinov scribed:
+ { MP_CMD_SUB_FONT_SCALE_FACTOR, "sub_font_scale_factor",1,
i wonder if it would be easier to just name it sub_scale also dont forget to add your command to DOCS/tech/slave.txt (and the table at the bottom of slave.txt) -compn
Hi,
+ { MP_CMD_SUB_FONT_SCALE_FACTOR, "sub_font_scale_factor",1,
i wonder if it would be easier to just name it sub_scale
What do you mean exactly? MP_CMD_SUB_FONT_SCALE_FACTOR -> MP_CMD_SUB_SCALE or sub_font_scale_factor -> sub_scale or both of them ? :)
also dont forget to add your command to DOCS/tech/slave.txt (and the table at the bottom of slave.txt)
I will add it in the table. Thanks Toli
On Fri, Jul 06, 2007 at 11:03:24AM +0300, Anatoli Marinov wrote:
The attached file is my patch that enables runtime changing of osd font scale factor. Please let me know if there is something wrong and I will fix it as fast as I can. For me was so hard to find unused keys. Finally I've binded scale factor increment to *b* and decrement to *n* (default values). Of course if you have a different vision about that it will be ease for me to change them.
IMO don't bind them at all by default, we have too many default keybinds already. Feel free to add them to our example input.conf though.
{ MP_CMD_VF_CHANGE_RECTANGLE, "change_rectangle", 2, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}}}}, - + { MP_CMD_SUB_FONT_SCALE_FACTOR, "sub_font_scale_factor",1, { {MP_CMD_ARG_FLOAT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, #ifdef HAVE_NEW_GUI
leave the empty line before the #ifdef in. Also you are only using one argument but specify that it accepts two... It probably would be nicer to add this as a property, too, if you have the time. The things you need for that are in command.c, esp. the mp_properties table around line 1461 and if you want to keep the osd message the set_prop_cmd array around line 1648. Maybe mp_property_volume or so is a good template for a property handling function. And I agree with Compn suggestion for shorter names (both command string and both defines).
@@ -1670,6 +1671,7 @@ { "sub_pos", MP_CMD_SUB_POS, 0, 0, -1, MSGTR_SubPosStatus }, { "sub_alignment", MP_CMD_SUB_ALIGNMENT, 1, 0, -1, MSGTR_SubAlignStatus }, { "sub_delay", MP_CMD_SUB_DELAY, 0, 0, OSD_MSG_SUB_DELAY, MSGTR_SubDelayStatus }, + { "sub_font_scale_factor", MP_CMD_SUB_FONT_SCALE_FACTOR, 0, 0, OSD_MSG_SUB_FONT_SCALE_FACTOR, MSGTR_SubScaleFactor }, { "sub_visibility", MP_CMD_SUB_VISIBILITY, 1, 0, -1, MSGTR_SubVisibleStatus }, { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY, 1, 0, -1, MSGTR_SubForcedOnlyStatus },
Hmm.. while this is what I suggested to do if you implement it as a property, it is wrong to add it here if you do not implement it as a property as this patch does.
+ case MP_CMD_SUB_FONT_SCALE_FACTOR: + if ((cmd->args[0].v.f < 0 && text_font_scale_factor > 0.1) || + (cmd->args[0].v.f > 0 && text_font_scale_factor < 100)) {
There are some useless () and it's not aligned nicely, should be more like this:
if (cmd->args[0].v.f < 0 && text_font_scale_factor > 0.1 || cmd->args[0].v.f > 0 && text_font_scale_factor < 100) {
Should you implement it as a property you won't need this kind of check though since you can specify the limits in the mp_properties array.
+ text_font_scale_factor += cmd->args[0].v.f; + force_load_font = 1;
You used tabs here while the surrounding code does not. Greetings, Reimar Döffinger
On Fri, 6 Jul 2007 17:33:35 +0200 Reimar Döffinger <Reimar.Doeffinger@stud.uni-karlsruhe.de> wrote:
It probably would be nicer to add this as a property, too, if you have the time.
imho it _must_ be done as a property and i would oppose adding new commands that should be done as property (ie. they are not a pure action where querying make no sense).
The things you need for that are in command.c, esp. the mp_properties table around line 1461 if you want to keep the osd message the set_prop_cmd array around line 1648. Maybe mp_property_volume or so is a good template for a property handling function.
Maybe not, the volume is none trivial bcs of mute and edl. fullscreen and panscan are a bit simpler iirc. Otherwise looking at the doxygen comments in m_property.h and at the thread for the balance patch might be useful. Albeu
Hi, All 2007/7/7, Alban Bedel <albeu@free.fr>:
On Fri, 6 Jul 2007 17:33:35 +0200 Reimar Döffinger <Reimar.Doeffinger@stud.uni-karlsruhe.de> wrote:
It probably would be nicer to add this as a property, too, if you have the time.
imho it _must_ be done as a property and i would oppose adding new commands that should be done as property (ie. they are not a pure action where querying make no sense).
The things you need for that are in command.c, esp. the mp_properties table around line 1461 if you want to keep the osd message the set_prop_cmd array around line 1648. Maybe mp_property_volume or so is a good template for a property handling function.
Maybe not, the volume is none trivial bcs of mute and edl. fullscreen and panscan are a bit simpler iirc. Otherwise looking at the doxygen comments in m_property.h and at the thread for the balance patch might be useful.
This feature will be usefull for future teletext support too. What about attached version? -- Regards, Vladimir Voroshilov mailto:voroshil@gmail.com JID: voroshil@gmail.com, voroshil@jabber.ru ICQ: 95587719
Hi guys, I have new version with code for property. See the atached file. Toli 2007/7/8, Vladimir Voroshilov <voroshil@gmail.com>:
Hi, All
2007/7/7, Alban Bedel <albeu@free.fr>:
On Fri, 6 Jul 2007 17:33:35 +0200 Reimar Döffinger <Reimar.Doeffinger@stud.uni-karlsruhe.de> wrote:
It probably would be nicer to add this as a property, too, if you have the time.
imho it _must_ be done as a property and i would oppose adding new commands that should be done as property (ie. they are not a pure action where querying make no sense).
The things you need for that are in command.c, esp. the mp_properties table around line 1461 if you want to keep the osd message the set_prop_cmd array around line 1648. Maybe mp_property_volume or so is a good template for a property handling function.
Maybe not, the volume is none trivial bcs of mute and edl. fullscreen and panscan are a bit simpler iirc. Otherwise looking at the doxygen comments in m_property.h and at the thread for the balance patch might be useful.
This feature will be usefull for future teletext support too. What about attached version?
-- Regards, Vladimir Voroshilov mailto:voroshil@gmail.com JID: voroshil@gmail.com, voroshil@jabber.ru ICQ: 95587719
_______________________________________________ MPlayer-dev-eng mailing list MPlayer-dev-eng@mplayerhq.hu http://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
Hi, Anatoli 2007/7/9, Anatoli Marinov <anatoli.marinov@gmail.com>:
Hi guys, I have new version with code for property. See the atached file.
+ case M_PROPERTY_SET: + case M_PROPERTY_STEP_UP: + case M_PROPERTY_STEP_DOWN: + text_font_scale_factor += *(float *) arg; + M_PROPERTY_CLAMP(prop, text_font_scale_factor); Totally wrong. In case of M_PROPERTY_SET, you will increase scale factor by *(float*)arg instead of setting it as new scale factor value.
@@ -1568,6 +1591,8 @@ M_OPT_RANGE, 0, 1, NULL }, { "sub_forced_only", mp_property_sub_forced_only, CONF_TYPE_FLAG, M_OPT_RANGE, 0, 1, NULL }, + { "sub_scale", mp_property_sub_scale, CONF_TYPE_FLOAT, + M_OPT_RANGE, 0, 10, NULL }, Here should be 100 instead of 10, IMHO (see subfont_text_scale option).
Others things looks ok. P.S. Don't forget to modify DOCS/tech/slave.txt (as i did :( in my patch) -- Regards, Vladimir Voroshilov mailto:voroshil@gmail.com JID: voroshil@gmail.com, voroshil@jabber.ru ICQ: 95587719
Hi, My last and maybe final patch is attached. I am waiting for your comments. Toli
Hi, Anatoli. 2007/7/9, Anatoli Marinov <anatoli.marinov@gmail.com>:
Hi, My last and maybe final patch is attached. I am waiting for your comments.
+sub_scale <value> + Adjust the subtitle size by +/- <value>. +
I'm afraid "sub_scale" will set scale factor to <value> (not adjust it by +/- <value>). But, i'm not 100% sure. Please make additional test.
+#? sub_scale +0.1 # increase subtitle font size +#? sub_scale -0.1 # decrease subtitle font size Same here.
+sub_scale float 0 100 X X X adjust subtitles font size just "subtitles font size" or similiar (this is property description, not command)
The rest looks ok for me. -- Regards, Vladimir Voroshilov mailto:voroshil@gmail.com JID: voroshil@gmail.com, voroshil@jabber.ru ICQ: 95587719
+sub_scale <value> + Adjust the subtitle size by +/- <value>. +
I'm afraid "sub_scale" will set scale factor to <value> (not adjust it by +/- <value>). But, i'm not 100% sure. Please make additional test.
It increments and decrements the value. I've tested it. I am not sure how M_PROPERTY_SET works but I never reived it.
+#? sub_scale +0.1 # increase subtitle font size +#? sub_scale -0.1 # decrease subtitle font size Same here.
It works.
+sub_scale float 0 100 X X X adjust subtitles font size just "subtitles font size" or similiar (this is property description, not command)
Ok :) I will change it see the new patch. Now I am confused about M_PROPERTY_SET how I can generate it and why I never received it. However current patch looks better than my first. Regards Anatoli Marinov
Hi, Anatoli. 2007/7/9, Anatoli Marinov <anatoli.marinov@gmail.com>:
+sub_scale <value> + Adjust the subtitle size by +/- <value>. +
I'm afraid "sub_scale" will set scale factor to <value> (not adjust it by +/- <value>). But, i'm not 100% sure. Please make additional test.
It increments and decrements the value. I've tested it. I am not sure how M_PROPERTY_SET works but I never reived it.
You are right. By default sub_scale will adjust scale value. To set up exact value users should use "sub_scale <value> 1" (with any non-zero value as second parameter)
+#? sub_scale +0.1 # increase subtitle font size +#? sub_scale -0.1 # decrease subtitle font size Same here.
It works.
+sub_scale float 0 100 X X X adjust subtitles font size just "subtitles font size" or similiar (this is property description, not command)
Ok :) I will change it see the new patch. Now I am confused about M_PROPERTY_SET how I can generate it and why I never received it.
See above.
However current patch looks better than my first. Patch is ok for me now.
-- Regards, Vladimir Voroshilov mailto:voroshil@gmail.com JID: voroshil@gmail.com, voroshil@jabber.ru ICQ: 95587719
On Sun, 8 Jul 2007 23:23:53 +0300 "Anatoli Marinov" <anatoli.marinov@gmail.com> wrote:
+/// Subtitle scale (RW) +static int mp_property_sub_scale(m_option_t * prop, int action, void *arg, + MPContext * mpctx) +{ + if (!arg) + return M_PROPERTY_ERROR;
This is not ok some actions don't need arguments.
+ switch (action) { + case M_PROPERTY_SET: + text_font_scale_factor = *(float *) arg; + M_PROPERTY_CLAMP(prop, text_font_scale_factor); + force_load_font = 1; + return M_PROPERTY_OK; + case M_PROPERTY_STEP_UP: + case M_PROPERTY_STEP_DOWN: + text_font_scale_factor += *(float *) arg;
This is not right, it should handle the case w/o argument and reverse the direction for STEP_DOWN. So something like this is needed: text_font_scale_factor += (arg ? *(float *) arg : 0.1)* (action == M_PROPERTY_STEP_UP ? 1.0 : -1.0);
+ M_PROPERTY_CLAMP(prop, text_font_scale_factor); + force_load_font = 1; + return M_PROPERTY_OK; + default: + return m_property_float_ro(prop, action, arg, text_font_scale_factor); + } + + return M_PROPERTY_NOT_IMPLEMENTED;
This is useless, it can't be reached. Remove it or replace it with the default case code (i tend to prefer the latter but this is just taste).
+}
Otherwise it look ok. It would be nice if you also added the property to the example menu config (etc/menu.conf). Albeu
Hello, Thanks for your hints.
+ M_PROPERTY_CLAMP(prop, text_font_scale_factor); + force_load_font = 1; + return M_PROPERTY_OK; + default: + return m_property_float_ro(prop, action, arg, text_font_scale_factor); + } + + return M_PROPERTY_NOT_IMPLEMENTED;
This is useless, it can't be reached. Remove it or replace it with the default case code (i tend to prefer the latter but this is just taste).
+}
What do you mean there is useless? Toli
Thanks Alban, See the attacked file. It has all fixes. Regards Toli 2007/7/9, Anatoli Marinov <anatoli.marinov@gmail.com>:
Hello, Thanks for your hints.
+ M_PROPERTY_CLAMP(prop, text_font_scale_factor); + force_load_font = 1; + return M_PROPERTY_OK; + default: + return m_property_float_ro(prop, action, arg, text_font_scale_factor); + } + + return M_PROPERTY_NOT_IMPLEMENTED;
This is useless, it can't be reached. Remove it or replace it with the default case code (i tend to prefer the latter but this is just taste).
+}
What do you mean there is useless?
Toli
On Mon, 9 Jul 2007 12:25:39 +0300 "Anatoli Marinov" <anatoli.marinov@gmail.com> wrote:
Thanks Alban, See the attacked file. It has all fixes.
Commited with a few fix for things I forgot previously:
{ MP_CMD_SUB_LOG, "sub_log", 0, { {-1,{0}} } }, + { MP_CMD_SUB_SCALE, "sub_scale",1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } }, { MP_CMD_GET_PERCENT_POS, "get_percent_pos", 0, { {-1,{0}} } },
The second arg to allow setting instead of adjusting was missing, I also updated the docs accordingly.
+ case M_PROPERTY_SET: + if (!arg) + return M_PROPERTY_ERROR; + text_font_scale_factor = *(float *) arg; + M_PROPERTY_CLAMP(prop, text_font_scale_factor); + force_load_font = 1; + return M_PROPERTY_OK;
The argument should be clamped before setting it to allow the caller to directly read back the value really set. While at it I also moved the function to keep the same order as in the property array. Albeu
Thanks, It was a pleasure for me, and thank you for your huge help. Anatoli Marinov 2007/7/9, Alban Bedel <albeu@free.fr>:
On Mon, 9 Jul 2007 12:25:39 +0300 "Anatoli Marinov" <anatoli.marinov@gmail.com> wrote:
Thanks Alban, See the attacked file. It has all fixes.
Commited with a few fix for things I forgot previously:
{ MP_CMD_SUB_LOG, "sub_log", 0, { {-1,{0}} } }, + { MP_CMD_SUB_SCALE, "sub_scale",1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } }, { MP_CMD_GET_PERCENT_POS, "get_percent_pos", 0, { {-1,{0}} } },
The second arg to allow setting instead of adjusting was missing, I also updated the docs accordingly.
+ case M_PROPERTY_SET: + if (!arg) + return M_PROPERTY_ERROR; + text_font_scale_factor = *(float *) arg; + M_PROPERTY_CLAMP(prop, text_font_scale_factor); + force_load_font = 1; + return M_PROPERTY_OK;
The argument should be clamped before setting it to allow the caller to directly read back the value really set.
While at it I also moved the function to keep the same order as in the property array.
Albeu
_______________________________________________ MPlayer-dev-eng mailing list MPlayer-dev-eng@mplayerhq.hu http://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
And sorry for my top-posting :) Sorry Diego. Best Wishes, Anatoli Marinov
Hi, Anatoli 2007/7/9, Anatoli Marinov <anatoli.marinov@gmail.com>:
Hello, Thanks for your hints.
+ M_PROPERTY_CLAMP(prop, text_font_scale_factor); + force_load_font = 1; + return M_PROPERTY_OK; + default: + return m_property_float_ro(prop, action, arg, text_font_scale_factor); + } + + return M_PROPERTY_NOT_IMPLEMENTED;
This is useless, it can't be reached. Remove it or replace it with the default case code (i tend to prefer the latter but this is just taste).
+}
What do you mean there is useless?
All possible cases are already catched by "default: return ...." -- Regards, Vladimir Voroshilov mailto:voroshil@gmail.com JID: voroshil@gmail.com, voroshil@jabber.ru ICQ: 95587719
All possible cases are already catched by "default: return ...." Yes - Yes. It has been fixed in the last patch that I sent in my previous mail.
Regards
Vladimir, I think my new version of this patch is better. Tomorrow I'm going to complete it and will send you may final version. Best Wishes, Anatoli Marinov
participants (6)
-
Alban Bedel -
Anatoli Marinov -
Compn -
Reimar Doeffinger -
Reimar Döffinger -
Vladimir Voroshilov