shoes4 icon indicating copy to clipboard operation
shoes4 copied to clipboard

Replace the opts hash with... something (maybe a Style object)

Open PragTob opened this issue 11 years ago • 6 comments

Right now most shoes objects have all their styling information in the opts hash, which gets passed on and modified until drawing is reached. In some places it's still called style.

It's a major smell that penetrates the whole code base. I think it'd be best to create a style object...

Comments/ideas/objections? :)

PragTob avatar Mar 19 '14 15:03 PragTob

Yes please! Definitely found this to be true digging around in the text flow styling.

Probably deserves its own issue/PR too but building off that, how the TextBlock tracks the sub-styling regions (https://github.com/shoes/shoes4/blob/master/lib/shoes/text_block.rb#L110-L123) has similar pain points... an array of arrays each containing a range and control. Crying out for a class in there somewhere.

jasonrclark avatar Mar 19 '14 16:03 jasonrclark

Yes totally!!!

However, it's definitely at its worst in the whole TextBlock family... it's better but yeah sometimes information just gets thrown in there if you want another object to access it. It's like everybodies messenger :P

Feel free to open an issue about the whole ranges thingy... could be something like a tree structure?

PragTob avatar Mar 19 '14 16:03 PragTob

I think it's worthwhile to extract a Style object, and especially one for TextBlocks. The options hash does get used for lots of different things, but that flexibility is important, I think. Maybe we keep the options hash, but give it a :style key?

wasnotrice avatar Mar 19 '14 16:03 wasnotrice

Entered #614 about the specifics of what the TextBlock should track around the inner-segment styling.

jasonrclark avatar Mar 21 '14 04:03 jasonrclark

How do we feel this issue relates to my recent work on style. Is it done, or do we still want a Style object?

KCErb avatar Aug 29 '14 03:08 KCErb

I feel like your work has gone a long way to making things more consistent, but I do still wonder if there's a class in there somewhere lurking. We also still have things like https://github.com/shoes/shoes4/blob/master/lib/shoes/swt/text_block/text_style_factory.rb which does a lot of deep nested hash lookups... maybe no easy way around it, but it's ugly and fiddly.

So my 2 cents, this isn't a priority with how you've improved the styles situation, but if someone can see a path to improve it further by extracting more classes, I'd still be in favor of that.

jasonrclark avatar Aug 29 '14 15:08 jasonrclark