Skip to content

Commit

Permalink
ICompositeInteractiveComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Dec 13, 2023
1 parent b370182 commit e15b0ae
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 23 deletions.
3 changes: 2 additions & 1 deletion haxe/ui/components/Button.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import haxe.ui.behaviours.DefaultBehaviour;
import haxe.ui.constants.Priority;
import haxe.ui.core.Component;
import haxe.ui.core.CompositeBuilder;
import haxe.ui.core.ICompositeInteractiveComponent;
import haxe.ui.core.InteractiveComponent;
import haxe.ui.core.ItemRenderer;
import haxe.ui.core.Screen;
Expand Down Expand Up @@ -65,7 +66,7 @@ import haxe.ui.util.Variant;

@:dox(icon = "ui-button.png")
@:composite(ButtonEvents, ButtonBuilder, ButtonLayout)
class Button extends InteractiveComponent {
class Button extends InteractiveComponent implements ICompositeInteractiveComponent {
//***********************************************************************************************************
// Styles
//***********************************************************************************************************
Expand Down
3 changes: 2 additions & 1 deletion haxe/ui/components/CheckBox.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import haxe.ui.actions.ActionType;
import haxe.ui.behaviours.DataBehaviour;
import haxe.ui.core.Component;
import haxe.ui.core.CompositeBuilder;
import haxe.ui.core.ICompositeInteractiveComponent;
import haxe.ui.core.InteractiveComponent;
import haxe.ui.events.ActionEvent;
import haxe.ui.events.Events;
Expand All @@ -17,7 +18,7 @@ import haxe.ui.styles.Style;
* A basic checkbox component.
*/
@:composite(Events, CheckBoxBuilder, CheckBoxLayout)
class CheckBox extends InteractiveComponent {
class CheckBox extends InteractiveComponent implements ICompositeInteractiveComponent {
//***********************************************************************************************************
// Public API
//***********************************************************************************************************
Expand Down
3 changes: 2 additions & 1 deletion haxe/ui/components/NumberStepper.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import haxe.ui.components.Button;
import haxe.ui.components.TextField;
import haxe.ui.core.Component;
import haxe.ui.core.CompositeBuilder;
import haxe.ui.core.ICompositeInteractiveComponent;
import haxe.ui.core.InteractiveComponent;
import haxe.ui.events.ActionEvent;
import haxe.ui.events.FocusEvent;
Expand All @@ -24,7 +25,7 @@ import haxe.ui.util.Timer;
* visual arrow buttons, arrow keys or just by typing in the stepper's text field.
*/
@:composite(Events, Builder)
class NumberStepper extends InteractiveComponent {
class NumberStepper extends InteractiveComponent implements ICompositeInteractiveComponent {

/**
* The actual value of the number stepper.
Expand Down
3 changes: 2 additions & 1 deletion haxe/ui/components/OptionStepper.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import haxe.ui.behaviours.DefaultBehaviour;
import haxe.ui.components.Label;
import haxe.ui.core.Component;
import haxe.ui.core.CompositeBuilder;
import haxe.ui.core.ICompositeInteractiveComponent;
import haxe.ui.core.IDataComponent;
import haxe.ui.core.InteractiveComponent;
import haxe.ui.data.DataSource;
Expand All @@ -23,7 +24,7 @@ import haxe.ui.util.Variant;
* A stepper that allows the user to switch between items using the visual arrow buttons/arrow keys.
*/
@:composite(Events, Builder, Layout)
class OptionStepper extends InteractiveComponent implements IDataComponent {
class OptionStepper extends InteractiveComponent implements IDataComponent implements ICompositeInteractiveComponent {

/**
* The index of the currently selected option.
Expand Down
3 changes: 2 additions & 1 deletion haxe/ui/components/Range.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import haxe.ui.behaviours.DefaultBehaviour;
import haxe.ui.behaviours.InvalidatingBehaviour;
import haxe.ui.core.Component;
import haxe.ui.core.CompositeBuilder;
import haxe.ui.core.ICompositeInteractiveComponent;
import haxe.ui.core.IDirectionalComponent;
import haxe.ui.core.InteractiveComponent;
import haxe.ui.core.Screen;
Expand All @@ -19,7 +20,7 @@ import haxe.ui.util.Variant;
* A range bar component, that starts from `min` and ends at `max`, defaults to 0-100.
*/
@:composite(RangeBuilder)
class Range extends InteractiveComponent implements IDirectionalComponent {
class Range extends InteractiveComponent implements IDirectionalComponent implements ICompositeInteractiveComponent {

/**
* Creates a new range bar.
Expand Down
11 changes: 6 additions & 5 deletions haxe/ui/components/Scroll.hx
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package haxe.ui.components;

import haxe.ui.events.Events;
import haxe.ui.events.ScrollEvent;
import haxe.ui.util.Variant;
import haxe.ui.behaviours.DataBehaviour;
import haxe.ui.behaviours.DefaultBehaviour;
import haxe.ui.behaviours.LayoutBehaviour;
import haxe.ui.core.ICompositeInteractiveComponent;
import haxe.ui.core.IDirectionalComponent;
import haxe.ui.core.InteractiveComponent;
import haxe.ui.behaviours.LayoutBehaviour;
import haxe.ui.events.Events;
import haxe.ui.events.MouseEvent;
import haxe.ui.events.ScrollEvent;
import haxe.ui.events.UIEvent;
import haxe.ui.geom.Point;
import haxe.ui.util.Variant;

/**
* A scrollbar component, like the ones you see in a browser.
*/
class Scroll extends InteractiveComponent implements IDirectionalComponent {
class Scroll extends InteractiveComponent implements IDirectionalComponent implements ICompositeInteractiveComponent {

/**
* Creates a new scrollbar.
Expand Down
5 changes: 3 additions & 2 deletions haxe/ui/components/Slider.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@ import haxe.ui.behaviours.DataBehaviour;
import haxe.ui.behaviours.DefaultBehaviour;
import haxe.ui.core.Component;
import haxe.ui.core.CompositeBuilder;
import haxe.ui.core.ICompositeInteractiveComponent;
import haxe.ui.core.IDirectionalComponent;
import haxe.ui.core.InteractiveComponent;
import haxe.ui.core.Screen;
import haxe.ui.events.ActionEvent;
import haxe.ui.events.DragEvent;
import haxe.ui.events.DragEvent;
import haxe.ui.events.Events;
import haxe.ui.events.MouseEvent;
import haxe.ui.events.UIEvent;
import haxe.ui.geom.Point;
import haxe.ui.util.MathUtil;
import haxe.ui.util.Variant;
import haxe.ui.events.DragEvent;

/**
* A slider component, containing a thumb and a track to move the thumb along.
*/
@:composite(SliderBuilder)
class Slider extends InteractiveComponent implements IDirectionalComponent {
class Slider extends InteractiveComponent implements IDirectionalComponent implements ICompositeInteractiveComponent {

/**
* Creates a new Slider.
Expand Down
3 changes: 2 additions & 1 deletion haxe/ui/components/Switch.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import haxe.ui.behaviours.DataBehaviour;
import haxe.ui.behaviours.DefaultBehaviour;
import haxe.ui.core.Component;
import haxe.ui.core.CompositeBuilder;
import haxe.ui.core.ICompositeInteractiveComponent;
import haxe.ui.core.IValueComponent;
import haxe.ui.core.InteractiveComponent;
import haxe.ui.events.UIEvent;
Expand All @@ -15,7 +16,7 @@ import haxe.ui.util.Variant;
* A switch component that can be used to toggle between two states.
*/
@:composite(Builder, HorizontalLayout)
class Switch extends Component implements IValueComponent {
class Switch extends Component implements IValueComponent implements ICompositeInteractiveComponent {
//***********************************************************************************************************
// Public API
//***********************************************************************************************************
Expand Down
3 changes: 2 additions & 1 deletion haxe/ui/components/TabBar.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import haxe.ui.containers.Box;
import haxe.ui.containers.HBox;
import haxe.ui.core.Component;
import haxe.ui.core.CompositeBuilder;
import haxe.ui.core.ICompositeInteractiveComponent;
import haxe.ui.events.Events;
import haxe.ui.events.MouseEvent;
import haxe.ui.events.UIEvent;
Expand All @@ -17,7 +18,7 @@ import haxe.ui.styles.Style;
import haxe.ui.util.Variant;

@:composite(Builder, Events, TabBarLayout)
class TabBar extends Component {
class TabBar extends Component implements ICompositeInteractiveComponent {
//***********************************************************************************************************
// Public API
//***********************************************************************************************************
Expand Down
3 changes: 2 additions & 1 deletion haxe/ui/components/TextArea.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import haxe.ui.behaviours.DataBehaviour;
import haxe.ui.behaviours.DefaultBehaviour;
import haxe.ui.core.Component;
import haxe.ui.core.CompositeBuilder;
import haxe.ui.core.ICompositeInteractiveComponent;
import haxe.ui.core.InteractiveComponent;
import haxe.ui.core.TextInput;
import haxe.ui.data.ArrayDataSource;
Expand All @@ -21,7 +22,7 @@ import haxe.ui.util.Variant;
import haxe.ui.validation.InvalidationFlags;

@:composite(Events, TextAreaBuilder, TextAreaLayout)
class TextArea extends InteractiveComponent implements IFocusable {
class TextArea extends InteractiveComponent implements IFocusable implements ICompositeInteractiveComponent {
//***********************************************************************************************************
// Styles
//***********************************************************************************************************
Expand Down
3 changes: 2 additions & 1 deletion haxe/ui/components/TextField.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import haxe.ui.behaviours.DataBehaviour;
import haxe.ui.behaviours.ValueBehaviour;
import haxe.ui.core.Component;
import haxe.ui.core.CompositeBuilder;
import haxe.ui.core.ICompositeInteractiveComponent;
import haxe.ui.core.InteractiveComponent;
import haxe.ui.core.Platform;
import haxe.ui.events.Events;
Expand All @@ -21,7 +22,7 @@ import haxe.ui.util.Variant;
* A single line text input box. for multiline text input use `TextArea`.
*/
@:composite(Events, Builder, TextFieldLayout)
class TextField extends InteractiveComponent {
class TextField extends InteractiveComponent implements ICompositeInteractiveComponent {
//***********************************************************************************************************
// Public API
//***********************************************************************************************************
Expand Down
3 changes: 2 additions & 1 deletion haxe/ui/components/pickers/ItemPicker.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import haxe.ui.containers.HBox;
import haxe.ui.core.BasicItemRenderer;
import haxe.ui.core.Component;
import haxe.ui.core.CompositeBuilder;
import haxe.ui.core.ICompositeInteractiveComponent;
import haxe.ui.core.IDataComponent;
import haxe.ui.core.InteractiveComponent;
import haxe.ui.core.ItemRenderer;
Expand All @@ -18,7 +19,7 @@ import haxe.ui.geom.Size;
import haxe.ui.layouts.DefaultLayout;

@:composite(ItemPickerBuilder, Layout)
class ItemPicker extends InteractiveComponent implements IDataComponent {
class ItemPicker extends InteractiveComponent implements IDataComponent implements ICompositeInteractiveComponent {
public var selectionType = "dropPanel";
public var panelPosition = "auto";
public var panelOrigin = "auto";
Expand Down
20 changes: 14 additions & 6 deletions haxe/ui/core/Component.hx
Original file line number Diff line number Diff line change
Expand Up @@ -817,19 +817,27 @@ class Component extends ComponentImpl
match = false;
}

// bit of a special case here: if we are looking for interactive components
// we DONT want to include all the interactives that are built out of other
// interactives, for example, as number stepper has buttons and a textfield,
// none of which we want when looking for interactives, we would expect just
// the number stepper
var continueRecursion = true;
if ((child is ICompositeInteractiveComponent) && type == cast InteractiveComponent) {
continueRecursion = false;
}

if (match == true) {
r.push(cast child);
var childArray = child.findComponents(styleName, type, maxDepth);
for (c in childArray) { // r.concat caused issues here on hxcpp
r.push(c);
}
} else {
}

if (continueRecursion) {
var childArray = child.findComponents(styleName, type, maxDepth);
for (c in childArray) { // r.concat caused issues here on hxcpp
r.push(c);
}
}
}
}

return r;
}
Expand Down
10 changes: 10 additions & 0 deletions haxe/ui/core/ICompositeInteractiveComponent.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package haxe.ui.core;

// Lets haxeui know that this interactive components is built out of other
// sub interactive components. This is useful to know for things like
// findComponents(InteractiveComponent) where you DO NOT want to find
// all of the sub interactive components, you just want the top level
// interactive component
interface ICompositeInteractiveComponent {

}

0 comments on commit e15b0ae

Please sign in to comment.