31 template <
typename ItemModel = item_model>
36 using item_model_type = ItemModel;
52 if (iDropList.view_created())
58 auto backgroundColor = iDropList.list_view().palette_color(
color_role::Void);
59 if (backgroundColor == iDropList.list_view().background_color())
60 backgroundColor = backgroundColor.shaded(0x20);
61 return backgroundColor;
85 void current_index_changed(
const optional_item_presentation_model_index& aCurrentIndex,
const optional_item_presentation_model_index& aPreviousIndex)
override;
111 bool show(
bool aVisible)
override;
123 void update_placement();
182 return static_cast<drop_list_style>(
static_cast<uint32_t
>(aLhs) |
static_cast<uint32_t
>(aRhs));
187 return static_cast<drop_list_style>(
static_cast<uint32_t
>(aLhs) &
static_cast<uint32_t
>(aRhs));
195 class drop_list :
public widget<>,
private i_drop_list_input_widget::i_visitor
197 friend class drop_list_view;
199 define_event(SelectionChanged, selection_changed, optional_item_model_index)
201 struct no_selection : std::runtime_error { no_selection() :
std::runtime_error(
"neogfx::drop_list::no_selection") {} };
206 class view_container :
public framed_widget<>
208 typedef framed_widget<> base_type;
210 view_container(i_layout& aLayout);
212 color palette_color(color_role aColorRole)
const override;
213 color frame_color()
const override;
216 struct no_view : std::logic_error { no_view() :
std::logic_error(
"neogfx::drop_list::list_proxy::no_view") {} };
218 list_proxy(drop_list& aDropList);
221 bool view_created()
const;
222 bool view_visible()
const;
223 drop_list_view& list_view()
const;
229 void update_view_placement();
231 drop_list& iDropList;
232 mutable std::optional<drop_list_popup> iPopup;
233 mutable std::optional<view_container> iViewContainer;
234 mutable std::optional<drop_list_view> iView;
238 drop_list(drop_list_style aStyle = drop_list_style::Normal);
239 drop_list(i_widget& aParent, drop_list_style aStyle = drop_list_style::Normal);
240 drop_list(i_layout& aLayout, drop_list_style aStyle = drop_list_style::Normal);
243 bool has_model()
const;
244 const i_item_model& model()
const;
245 i_item_model& model();
246 void set_model(i_item_model& aModel);
247 void set_model(i_ref_ptr<i_item_model>
const& aModel);
248 bool has_presentation_model()
const;
249 const i_item_presentation_model& presentation_model()
const;
250 i_item_presentation_model& presentation_model();
251 void set_presentation_model(i_item_presentation_model& aPresentationModel);
252 void set_presentation_model(i_ref_ptr<i_item_presentation_model>
const& aPresentationModel);
253 bool has_selection_model()
const;
254 const i_item_selection_model& selection_model()
const;
255 i_item_selection_model& selection_model();
256 void set_selection_model(i_item_selection_model& aSelectionModel);
257 void set_selection_model(i_ref_ptr<i_item_selection_model>
const& aSelectionModel);
259 bool has_selection()
const;
260 const item_model_index& selection()
const;
262 bool input_matches_current_item()
const;
263 bool input_matches_selection()
const;
265 bool view_created()
const;
266 bool view_visible()
const;
270 drop_list_view& list_view()
const;
271 void accept_selection();
272 void cancel_selection(
bool aClearInput =
false);
273 void cancel_and_restore_selection(
bool aOnlyRestoreIfViewCreated =
false);
276 void set_style(drop_list_style aStyle);
277 bool editable()
const;
278 void set_editable(
bool aEditable);
279 bool list_always_visible()
const;
280 void set_list_always_visible(
bool aListAlwaysVisible);
281 bool filter_enabled()
const;
282 void enable_filter(
bool aEnableFilter);
283 bool has_input()
const;
284 const i_drop_list_input_widget& input_widget()
const;
285 i_drop_list_input_widget& input_widget();
287 bool changing_text()
const;
288 bool handling_text_change()
const;
289 bool accepting_selection()
const;
290 bool cancelling_selection()
const;
292 neogfx::size_policy size_policy()
const override;
293 size minimum_size(optional_size
const& aAvailableSpace = optional_size{})
const override;
295 void visit(i_drop_list_input_widget& aInputWidget, push_button& aButtonWidget)
override;
296 void visit(i_drop_list_input_widget& aInputWidget, line_edit& aTextWidget)
override;
299 void update_widgets(
bool aForce =
false);
301 void handle_clicked();
302 void handle_cancel_selection(
bool aRestoreSavedSelection,
bool aUpdateEditor =
true);
306 vertical_layout iLayout0;
307 horizontal_layout iLayout1;
308 std::unique_ptr<i_drop_list_input_widget> iInputWidget;
309 ref_ptr<i_item_model> iModel;
310 ref_ptr<i_item_presentation_model> iPresentationModel;
311 ref_ptr<i_item_selection_model> iSelectionModel;
314 mutable std::optional<std::pair<color, texture>> iDownArrowTexture;
315 image_widget iDownArrow;
316 list_proxy iListProxy;
320 bool iHandlingTextChange;
321 bool iAcceptingSelection;
322 bool iCancellingSelection;
default_drop_list_presentation_model(drop_list &aDropList, item_model_type &aModel)
optional_color cell_color(item_presentation_model_index const &aIndex, color_role aColorRole) const override
item_cell_flags column_flags(item_presentation_model_index::value_type aColumn) const override
default_drop_list_presentation_model(drop_list &aDropList)
bool key_pressed(scan_code_e aScanCode, key_code_e aKeyCode, key_modifiers_e aKeyModifiers) override
drop_list_view(i_layout &aLayout, drop_list &aDropList)
void items_filtered() override
void mouse_button_released(mouse_button aButton, const point &aPosition) override
bool mouse_wheel_scrolled(mouse_wheel aWheel, const point &aPosition, delta aDelta, key_modifiers_e aKeyModifiers) override
void current_index_changed(const optional_item_presentation_model_index &aCurrentIndex, const optional_item_presentation_model_index &aPreviousIndex) override
size total_item_area(i_units_context const &aUnitsContext) const override
bool show(bool aVisible) override
#define end_declare_enum(enumName)
#define declare_enum_string(enumName, enumEnumerator)
#define begin_declare_enum(enumName)
constexpr style_aspect operator&(style_aspect aLhs, style_aspect aRhs)
audio_channel operator~(audio_channel lhs)
default_geometry_value_type dimension
constexpr style_aspect operator|(style_aspect aLhs, style_aspect aRhs)
std::optional< item_model_index > optional_item_model_index
basic_size< coordinate > size
constexpr decltype(auto) visit(Visitor &&vis, neolib::variant< Types... > &&var)
#define define_event(name, declName,...)
#define declare_event(declName,...)