mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
LibGUI: Implement calculated sizes for Slider
This commit is contained in:
parent
caf6dd5680
commit
6d79d932f9
|
@ -24,6 +24,8 @@ Slider::Slider(Orientation orientation)
|
|||
{ KnobSizeMode::Fixed, "Fixed" },
|
||||
{ KnobSizeMode::Proportional, "Proportional" });
|
||||
REGISTER_BOOL_PROPERTY("jump_to_cursor", jump_to_cursor, set_jump_to_cursor);
|
||||
|
||||
set_preferred_size(SpecialDimension::Fit);
|
||||
}
|
||||
|
||||
void Slider::paint_event(PaintEvent& event)
|
||||
|
@ -199,4 +201,18 @@ void Slider::set_knob_hovered(bool hovered)
|
|||
update(knob_rect());
|
||||
}
|
||||
|
||||
Optional<UISize> Slider::calculated_min_size() const
|
||||
{
|
||||
if (orientation() == Gfx::Orientation::Vertical)
|
||||
return { { knob_secondary_size(), knob_fixed_primary_size() * 2 + track_margin() * 2 } };
|
||||
return { { knob_fixed_primary_size() * 2 + track_margin() * 2, knob_secondary_size() } };
|
||||
}
|
||||
|
||||
Optional<UISize> Slider::calculated_preferred_size() const
|
||||
{
|
||||
if (orientation() == Gfx::Orientation::Vertical)
|
||||
return { { SpecialDimension::Shrink, SpecialDimension::OpportunisticGrow } };
|
||||
return { { SpecialDimension::OpportunisticGrow, SpecialDimension::Shrink } };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,6 +46,9 @@ public:
|
|||
protected:
|
||||
explicit Slider(Orientation = Orientation::Vertical);
|
||||
|
||||
virtual Optional<UISize> calculated_min_size() const override;
|
||||
virtual Optional<UISize> calculated_preferred_size() const override;
|
||||
|
||||
virtual void paint_event(PaintEvent&) override;
|
||||
void start_drag(Gfx::IntPoint);
|
||||
virtual void mousedown_event(MouseEvent&) override;
|
||||
|
|
Loading…
Reference in a new issue