Home » Developing U++ » U++ Developers corner » Know what you're using. Size of some common types.
Re: Know what you're using. Size of some common types. [message #57988 is a reply to message #57987] |
Mon, 10 January 2022 02:00 |
Lance
Messages: 527 Registered: March 2007
|
Contributor |
|
|
Great. For WithSpin<> which in turn contains SpinButtons, this can roughly reduce the object size by 2*sizeof(Button) - sizeof(Ctrl). That's a great achievement with minimal impact on existing code. It will just work.(Well, SpinButtons exposed Button inc, dec; but it should not be referenced much except in the library implementation anyways).
And it's a generic solution. No matter how many buttons it fakes, it will take up room of only sizeof(Ctrl).
For WithSpin in particular, another route I was considering (I am not versed with Upp enough to know whether it will work) is to start from EditField. Basically add 2 bitfield bool
class EditField:....
{
....
public:
void Paint(Draw& d)override{
PaintSpinButtons();
DoOriginalEditFieldPaintOnReducedSize();
}
void LeftDown(Point p, dword f)override{
if(p not in SpinPart)
Parent::LeftDown(p,f);
else if(p in UpperPart of Spin)
WhenSpin(false);
else// (p in LowerPart of Spin)
WhenSpin(true);
}
void LeftRepeat(Point p, dword f)override{
LeftDown(p,f);
}
Image CursorImage(Point p, dword)override{
// Image according to part of the Ctrl
}
//... maybe more to be override'd or rewrite to take care of Fake SpinButton part.
Event<bool> WhenSpin;
private:
bool with_spin : 1;
bool spin_visible : 1;
Size GetReducedSize(){
Size sz=GetSize();
if(with_spin && spin_visible)
reduce_size_to_leave_room_for_spin_buttons(sz);
}
}
Then in actual types(EditIntWithSpin, EditInt64WithSpin, etc) that needs SpinButtons, we just turn the flags on in respective constructors, and connect to WhenSpin event.
I am not sure if we claim part of EditField as Frame without actully AddFrame, etc, will work as wished.
If you figure this route is worth considering, I can do a preliminary implementation. Otherwise (if you prefer the more normal Buttons route), I will wait and see.
[Updated on: Mon, 10 January 2022 02:29] Report message to a moderator
|
|
|
|
|
Know what you're using. Size of some common types.
By: Lance on Mon, 27 December 2021 19:33
|
|
|
Re: Know what you're using. Size of some common types.
By: Klugier on Mon, 27 December 2021 19:58
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Mon, 27 December 2021 20:32
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Mon, 27 December 2021 20:37
|
|
|
Re: Know what you're using. Size of some common types.
By: Klugier on Mon, 27 December 2021 21:42
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 28 December 2021 02:29
|
|
|
Re: Know what you're using. Size of some common types.
By: Novo on Tue, 28 December 2021 05:17
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 28 December 2021 20:27
|
|
|
Re: Know what you're using. Size of some common types.
By: Novo on Tue, 28 December 2021 23:49
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Wed, 29 December 2021 01:42
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Thu, 30 December 2021 02:39
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 31 December 2021 19:51
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 31 December 2021 20:20
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 31 December 2021 20:28
|
|
|
Re: Know what you're using. Size of some common types.
By: mirek on Wed, 05 January 2022 10:47
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 07 January 2022 17:25
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 07 January 2022 17:44
|
|
|
Re: Know what you're using. Size of some common types.
By: mirek on Fri, 07 January 2022 18:34
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 07 January 2022 19:01
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Fri, 07 January 2022 19:26
|
|
|
Re: Know what you're using. Size of some common types.
By: mirek on Fri, 07 January 2022 22:22
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Sun, 09 January 2022 20:36
|
|
|
Re: Know what you're using. Size of some common types.
By: mirek on Mon, 10 January 2022 01:07
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Mon, 10 January 2022 02:00
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Mon, 10 January 2022 21:43
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 11 January 2022 02:29
|
|
|
Re: Know what you're using. Size of some common types.
By: mirek on Tue, 11 January 2022 13:41
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 11 January 2022 15:19
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 11 January 2022 17:40
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 11 January 2022 22:07
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Tue, 11 January 2022 22:25
|
|
|
Re: Know what you're using. Size of some common types.
By: mirek on Wed, 11 May 2022 09:42
|
|
|
Re: Know what you're using. Size of some common types.
By: Novo on Thu, 12 May 2022 08:26
|
|
|
Re: Know what you're using. Size of some common types.
By: Lance on Sat, 14 May 2022 21:30
|
|
|
Re: Know what you're using. Size of some common types.
By: mirek on Fri, 07 January 2022 18:32
|
Goto Forum:
Current Time: Sat May 04 00:52:52 CEST 2024
Total time taken to generate the page: 0.02021 seconds
|