Margin should be all Drawables' property.

Bug #1204286 reported by Jakub Sękowski
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Millennium Duel
Fix Released
Wishlist
Jakub Sękowski

Bug Description

I suggest to add member "margin" and method "SetMargin" to Drawable class definition. Why only Boxes may have it?

Related branches

Changed in millenniumduel:
status: New → Confirmed
milestone: none → 0.1
Jakub Sękowski (sequba)
Changed in millenniumduel:
assignee: nobody → Jakub Sękowski (sequba)
Revision history for this message
Rafał Cieślak (rafalcieslak256) wrote :

You may find it much much more convenient to fix this bug once https://code.launchpad.net/~rafalcieslak256/millenniumduel/cached-redrawing/ is merged (I'm going to send a MP asap).

Adam Malinowski (adayah)
Changed in millenniumduel:
status: Confirmed → Triaged
Revision history for this message
Jakub Sękowski (sequba) wrote :

I was thinking about this issue for a while and my idea is to make "_margin" a private member of IDrawable (similar to "_background_color"). But this will cause some problems.

A lot of methods, such as OnClicked(...) and GetMinimal...(...), have to be able to determine widget's margin, so I suggest, to use similar trick to the one, Rafał did with Draw(...) - make those functions non-virtual public methods of IDrawable and specify something like OnClickedNoMargin(...) and GetMinimal...NoMargin(...) (analogous to Redraw(...)), which will ignore widget's margin completely.

However, I'm not sure if this is the right way to do it. Otherwise, I can just specify public "getter" method GetMargin(), which, obviously, would be called by OnClicked(...) and GetMinimal...(...), but approach is completely different to the "_background_color"-one.

What do you think about it?

Revision history for this message
Rafał Cieślak (rafalcieslak256) wrote :

This is *exactly* the way I would do it. It's a pretty flexible approach, and it simplifies widget-specific code as much as possible.

I would, however, reconsider naming. Names containing "NoMargin" would be silly to call, because whatever wants to use them, would imply that it is interested in a particular version of the width/height.

Maybe names as "GetMinimalHeight" and "GetTotalMinimalHeight" or "GetInnerMinimalHeight" and "GetMinimalHeight" would be more clear.
Personally, I'd go for the second option, because it can be extended to OnClicked: IDrawable's "OnClicked" would call widget-specific methods "OnMarginClicked" and "OnInnerClicked".
"Insides" instead of "Inner" could do the trick too.

Revision history for this message
Jakub Sękowski (sequba) wrote :

Thanks a lot. Yesterday I was just about to start implementing it, but I wasn't concerned so I decided to wait for someone to approve my ideas.

You're right. Those names was just sample for better description of the "trick". I like the "Inner"-style too.

Changed in millenniumduel:
status: Triaged → In Progress
Jakub Sękowski (sequba)
Changed in millenniumduel:
status: In Progress → Fix Committed
Changed in millenniumduel:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.