Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL Container <input> tag positioned incorrectly using table rows #108

Open
abhijitnandy2011 opened this issue Sep 29, 2019 · 3 comments
Open

Comments

@abhijitnandy2011
Copy link

abhijitnandy2011 commented Sep 29, 2019

I am trying to use the input tag with the SDL Container written by bnolan here(https://gist.github.com/bnolan/436dd93893a6067406ce1a0b9e2dc0f3). I am rendering just the widget borders for now.

This is the code:
https://github.com/abhijitnandy2011/SDL-Browser-litehtml/tree/master/SDLBrowser/src

I tried to render this file:

<html>
<body>
    <table>
        <tr>
            <td><input type="text" name="search text"></td>
        </tr>
        <tr>
            <td><input type="button" name="lname"></td>
        </tr>
    </table>
</body>
</html>

Two input tags in 2 different rows. The one in the bottom is positioned incorrectly:
image

If I have some text in the row above it, then the first input tag positions correctly:

<html>
<body>
    <table>
        <tr>
            <td>First</td>
        </tr>
        <tr>
            <td><input type="text" name="search text"></td>
        </tr>
        <tr>
            <td><input type="button" name="lname"></td>
        </tr>
    </table>
</body>
</html>

image

Also text positioning works perfectly in the row and column direction. I am trying to figure out what I am missing in the implementation of the el_input:
https://github.com/abhijitnandy2011/SDL-Browser-litehtml/blob/master/SDLBrowser/src/el_input.cpp
and tried comparing it to el_text in the litehtml library code:
https://github.com/abhijitnandy2011/SDL-Browser-litehtml/blob/master/SDLBrowser/libs/litehtml/src/el_text.cpp

No luck yet, though it seems to me that the height of the first input tag is not set correctly as any text after it renders almost on it too:

<html>
<body>
    <table>
        <tr>
            <td>First</td>
        </tr>
        <tr>
            <td><input type="text" name="search text"></td>
        </tr>
        <tr>
            <td>Second</td>
        </tr>
    </table>
</body>
</html>

image

@abhijitnandy2011
Copy link
Author

abhijitnandy2011 commented Sep 30, 2019

Another thing I noticed is that setting the display style to litehtml::display_inline_block fixes the row rendering but messes up the column positioning(and widths)
image

Using litehtml::display_table_cell does the opposite:
image

@abhijitnandy2011
Copy link
Author

abhijitnandy2011 commented Sep 30, 2019

Ok, I have managed to cobble together something based on the el_image tag which seems to work:
https://github.com/abhijitnandy2011/SDL-Browser-litehtml/blob/master/SDLBrowser/src/el_input.h
https://github.com/abhijitnandy2011/SDL-Browser-litehtml/blob/master/SDLBrowser/src/el_input.cpp

It seems the render() function had to be implemented similarly to el_image, for the correct positions to be calculated:
image

This is for the following HTML:

<html>
<body>
    <table>       
        <tr>
            <td><input type="button" name="search text"></td><td><input type="button" name="search text"></td>
        </tr>
        <tr>
            <td><input type="button" name="search text"></td><td><input type="button" name="search text"></td>
        </tr>
        <tr>        
            <td>
                <table>
                    <tr>
                        <td><input type="button" name="search text"></td><td><input type="button" name="search text"></td>
                    </tr>
                     <tr>
                        <td><input type="button" name="search text"></td><td><input type="button" name="search text"></td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</body>
</html>

@cirospaciari
Copy link

Cool any progress on it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants