Rockbox

  • Status Closed
  • Percent Complete
    100%
  • Task Type Patches
  • Category Plugins
  • Assigned To No-one
  • Operating System All players
  • Severity Low
  • Priority Very Low
  • Reported Version Version 3.2
  • Due in Version Undecided
  • Due Date Undecided
  • Votes
  • Private
Attached to Project: Rockbox
Opened by Ubuntuxer - 2009-04-05
Last edited by teru - 2009-07-14

FS#10099 - lib, which display formatted text on every target

The text is displayed on the full screen size and can also be formatted. The lib should work on every target.
The code is based on the function do_help() from Will Robertson.
Please help me to improve the lib.

Closed by  teru
2009-07-14 13:36
Reason for closing:  Accepted
Additional comments about closing:   Warning: Undefined array key "typography" in /home/rockbox/flyspray/plugins/dokuwiki/inc/parserutils.php on line 371 Warning: Undefined array key "camelcase" in /home/rockbox/flyspray/plugins/dokuwiki/inc/parserutils.php on line 407

Committed in r21861.

The patch aroses from the problem, that if you use rb→lcd_putsxy(x, y, “text”) the text doesn’t always fits on the screen, because every target has an different screen size.
Some other plugins(e.g. star) uses a function called display_text(), which displays the text in a right way on the screen, but the function doesn’t support styles, so the text is hard to read and looks a little bit boring.
The lib give you the ability to display formatted text in a nice way.
The main disadvantage of the lib is that it uses a lot of memory, but I can’t think of an other solution to combine style and adaptation to the screen size.
The remaining text will be displayed, if you press any button.

can we include different fonts on the same page?
like bold, italics or actual different fonts?

we can scale the x and y in if you use rb→lcd_putsxy(x, y, “text”) ….
we can get the actual screen size of the player and convert it to the specific screen size using a simple % calculation.

@hittudiv It’s not available to include different fonts easily in display_font(), because a bigger font needs another line distance, so the whole line have to be displayed again. It would be great to display bold and italics, but unfornunately most fonts doesn’t support it.
I have included the lib in brickmania, but I have to work on the viewport integration. The problem is, that I need the x, y, width and height from the viewport struct, but I don’t know how to get it from the current viewport.

brickmania example usage of the lib

The lib supports now also viewport, but it’s important, that you pass the viewport to the funtion. I hope the lib is useful and doesn’t use to much memory.
Please test the lib and if necessary rename it.

set drawmode to solid

teru commented on 2009-05-17 12:49

your patch seems to do some strange things for me.

unsigned short xmargin = 5, ymargin = 5;
maybe this margin is too large for the lcd with charcells.
When I tested on the simulator for player before, nothing was displayed.
xmargin = xmargin + (*vp_text).x;
> ymargin = ymargin + (*vp_text).y;
This will cause problem especially when someone wants to set vp_text→x bigger than vp_text→width/2,
because the xmargin is subtracted from text_width(==vp_text→width) at line 70.
It would be better to use “rb→screens[SCREEN_MAIN]→set_viewport(vp_text);”,
and no need to set foreground/background and branch when setting drawmode.

Declaration of standard_fcolor also shoud be surrounded by “#if LCD_DEPTH > 1”.
“standard_fcolor=(*vp_text).fg_pattern;” at line 53 is duplicated.

x=(LCD_WIDTH/2)-(width/2);
maybe should use text_width instead of LCD_WIDTH?

In my opinion, it is not necessary to restore drawmode.

Is there any reason not waiting key input aftrer displaying last word?

It would be nice if you implement scrolling up/down the text.

sorry for my bad english and description.

Thank you for your bugreports and help.
I fixed the bugs you have detected and avoid unused parameter warnings on targets without color or bitmaps.

In my opinion, it is not necessary to restore drawmode.
I don’t think so, it’s very important, because the plugin writer, who use the lib can’t know, that the drawmode is changed. So I add a reset for the foreground color, too.
Is there any reason not waiting key input aftrer displaying last word?
The lib should be so flexible as possible, so I wouldn’t change it.
It would be nice if you implement scrolling up/down the text.
At the moment the text which fits on the screen is displayed and after you select a button the rest is displayed. It’s a little bit like a book. In my view the main disadvantage is, that you can’t go back.
A scolling text would be completely different concept, but we should discuss about it.

Upps, silly bug in brickmania_display_text.diff

Fixed a bug, which occurs on Archos Player/Studio, because of its small display size.

teru commented on 2009-06-25 15:28

*cleanup a bit.
*rename text.* to display_text.* to fit name of function.
*modify some plugins to use display_text.

I committed the lib display_text; thanks Teruaki Kawashima. Actually I don’t like bitwise operation, but it’s a nice solution.
The patch, which modify the plugins to use display_text needs a review. I will do this within the next few days.

Why do you use struct style_text (and pass a struct pointer as argument for display_text) when you can simply pass an unsigned short? (I would prefer an (unsigned) int though)

teru commented on 2009-06-28 13:50

*fix crash in brickmania
repeating entering and quiting help in brickmania crash the player.
*make “formation” static.
*try to reduce size of “formation”.

As far I just look at the lib; the idea to make a struct, which consist of index and the formation is great.
But it could be a nerve limiatation, that the last text item musn’t be a formatted word. Of course you could use just “” but it isn’t elegant and can lead to problems!
I fix some minor typos and remove the limitation that the last item must be a unformatted word.

Loading...

Available keyboard shortcuts

Tasklist

Task Details

Task Editing