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

Add bold and underline functionality #46

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mgazza
Copy link
Contributor

@mgazza mgazza commented Oct 18, 2023

Punt/ Preview PR
Change the font to one that has a bold derivative - (I probably should use fyne bundle instead of go embed).
Add the handling code for supporting underlining and bold.
Make that info available for downstream consumption for fyne.

depends on :
#45
fyne-io/fyne#4244

@andydotxyz andydotxyz marked this pull request as draft October 18, 2023 16:41
@andydotxyz andydotxyz changed the title Draft: Add bold and underline functionality Add bold and underline functionality Oct 18, 2023
@andydotxyz
Copy link
Member

(converted to draft on GitHub rather than in the text)

@mgazza mgazza force-pushed the add-bold-underline branch 2 times, most recently from fa0ae3b to be74aa6 Compare October 24, 2023 09:21
@andydotxyz
Copy link
Member

Trying to come back to a backlog of PRs and I see this one - it seems to have blinking work in it as well, maybe the wrong base branch?
Also as there is discussion about underline and strikethrough in TextStyle I wonder if that changes the API design here?

@mgazza
Copy link
Contributor Author

mgazza commented Nov 13, 2023

Hey, sorry I've been really busy with other things recently. Certainly there's mention of blinking in this PR. That is because it depends on #45

@mgazza mgazza force-pushed the add-bold-underline branch from be74aa6 to 43baa67 Compare February 2, 2024 10:45
@mgazza
Copy link
Contributor Author

mgazza commented Jun 14, 2024

image

depends on
fyne-io/fyne#4244
#85 ( cherry-picked into this )

@mgazza mgazza force-pushed the add-bold-underline branch from 43baa67 to b4a2dc9 Compare June 14, 2024 12:12
@andydotxyz
Copy link
Member

I had a glance through this, I'm not sure about the weight of the renderer on this - it seems like a lot of TextGrid is copied in, but I'm not sure why.

@mgazza
Copy link
Contributor Author

mgazza commented Jun 17, 2024

I can't encapsulate it because the renderer isn't exported. This a huge issue IMO. I don't know the best way to resolve it.

@mgazza
Copy link
Contributor Author

mgazza commented Jun 17, 2024

We could move the blinking down to the text grid render but I'm not sure what value that would give

@andydotxyz
Copy link
Member

I can't encapsulate it because the renderer isn't exported. This a huge issue IMO. I don't know the best way to resolve it.

But why do you need to tweak the renderer implementation? Can't it be delegated to?

@mgazza
Copy link
Contributor Author

mgazza commented Jun 17, 2024 via email

@andydotxyz
Copy link
Member

For blink I need to swap the fg and bg colours and I can either do that in the renderer or via the style.

Oh I see, this pattern was adopted earlier - I kinda missed how much was duplicated sorry.
Something between the two was in my head. The first was new public APIs which were not needed, and putting it all in the renderer is fine but we've got much more code to manage now.

What I had thought was happening before was that the style information was being used as the source, internally it was toggling when blinking and so the renderer had the updated model to get the visuals right. The TextGridStyle is an interface after all so it can return different colour values as it blinks. By delegating I meant that we encapsulate a TextGrid (along with its renderer) and provide a layer on top that manages complex things like toggling blink or handling hyperlink taps etc... the core rendering is still in the UI library...

But that leaves us with this PR. Is it right to pull in all the new code from Fyne TextGrid here to get the copy of the code working as it is upstream? I guess we kindof have to with what is in place now? Unless a simplification refactor could be done first?

@mgazza
Copy link
Contributor Author

mgazza commented Jun 19, 2024 via email

@andydotxyz
Copy link
Member

No, renderers cannot be made public. However is the BgColor and FgColor being methods not exactly the thing you need to be able to influence the colours on any particular render pass?

@mgazza
Copy link
Contributor Author

mgazza commented Jun 19, 2024 via email

@andydotxyz
Copy link
Member

In my mind that is where our "wrapping" widget comes in - we know the original state and we track a blink flag, toggling the state that is passed into the embedded TextGrid

@andydotxyz
Copy link
Member

Anything more I can do to help with the tidy-up here?

@mgazza mgazza force-pushed the add-bold-underline branch from b4a2dc9 to 707591b Compare October 27, 2024 12:49
@mgazza
Copy link
Contributor Author

mgazza commented Oct 27, 2024

If it's not public, we can't employ consumption over inheritance. Could you maybe take a stab at what your thinking here?

@andydotxyz
Copy link
Member

If it's not public, we can't employ consumption over inheritance. Could you maybe take a stab at what your thinking here?

I don't understand this question sorry. My point about blinking was that the colours are being asked for from an interface - and we can return different colours for the fg/bg as the blink occurs. Internally we manage blink state but the renderer would remain entirely the standard textgrid as we are just manipulating the widget state - no need to hook into a renderer.

@mgazza
Copy link
Contributor Author

mgazza commented Oct 27, 2024

Blinking is already in the main branch. This PR is about bold and underlining. I think I'm confused as these couple of features have been left for awhile.

@andydotxyz
Copy link
Member

The discussion, as far as I'm aware, is what was done with blinking is now resulting in constantly pulling renderer from upstream Fyne into this project to maintain a tweak for blinking.

I don't know if it was missed at the time but this is really undesirable, causes a maintenance overhead and goes against the design of widget and renderer separation.

This PR should be trivial but because of earlier decisions it is not - this is what I was hoping we could resolve.

If you are keen to land this feature we could back out the blinking, add this in easily, and then review the renderer situation with fresh eyes to get blinking back?
I think it's not until this PR demonstrated the tight coupling that had been introduced that I realised how much of an issue it was.

@mgazza
Copy link
Contributor Author

mgazza commented Oct 28, 2024

it was discussed here.
the previous commits were a lot less invasive.
I wonder if the way forward is to push this widget down into fyne?

@andydotxyz
Copy link
Member

I wonder if the way forward is to push this widget down into fyne?

I don't understand this - the widget is already in Fyne. What exists here seems to be a copy/paste of the renderer which you're now working to keep in sync as the upstream widget changes.

@mgazza
Copy link
Contributor Author

mgazza commented Oct 28, 2024

The widget for a text grid exists in fyne, but it doesn't respect The Open-closed principal, the term grid was added in #45. This PR add's bold and underline to the termgrid. The confusion may come from the diff as the termgrid renderer was moved to its own file in this commit

@mgazza mgazza force-pushed the add-bold-underline branch from 24e9952 to b1ea76f Compare October 28, 2024 12:15
@andydotxyz
Copy link
Member

I'm not confused and have tried to outline before that I am aware this is not new code but has come to light it's tight connection to an existing widget.

Without getting into the semantics of it all widgets are open to extension so I don't think it's correct to say that it's not open-closed. I have illustrated above ways that I think it is in fact possible to do what was achieved through copy and paste last time.

Do you think it is untrue to say that without the copying out of the renderer this PR would have been far simpler?

I think the issue is on me for having agreed to cloning the renderer in the first place, I did not fully understand how tightly this caused the two to be tied - which is what has become clear in this PR.

I hope this explains at least my previous messages, I don't think that I am confused about the scope of this change. But with the required render changes it looks like this requires more custom rendering which is not the case.

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

Successfully merging this pull request may close these issues.

2 participants