mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 18:32:28 -05:00
LibGUI: Implement calculated sizes for Slider
This commit is contained in:
parent
caf6dd5680
commit
6d79d932f9
2 changed files with 19 additions and 0 deletions
|
@ -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…
Add table
Reference in a new issue