Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bar): add bar's orientation #6212

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

TridentTD
Copy link
Contributor

@TridentTD TridentTD commented May 10, 2024

Description of the feature or fix

image

Add feature bar's orientation.

Notes

- add bar' orientation feature
- add feature bar orientation
- add test_case for bar orientation
@TridentTD TridentTD changed the title [featBar orientation [feat] add bar's orientation May 10, 2024
@TridentTD TridentTD changed the title [feat] add bar's orientation feat(bar) : add bar's orientation May 10, 2024
@TridentTD TridentTD changed the title feat(bar) : add bar's orientation feat(bar): add bar's orientation May 10, 2024
Copy link
Collaborator

@liamHowatt liamHowatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes #6172

The test took me a moment to understand but it seems reliable 😁

@@ -109,6 +120,13 @@ void lv_bar_set_range(lv_obj_t * obj, int32_t min, int32_t max);
*/
void lv_bar_set_mode(lv_obj_t * obj, lv_bar_mode_t mode);

/**
* Set the type of bar.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated docstring

Suggested change
* Set the type of bar.
* Set the orientation of the bar.

@@ -148,6 +166,13 @@ int32_t lv_bar_get_max_value(const lv_obj_t * obj);
*/
lv_bar_mode_t lv_bar_get_mode(lv_obj_t * obj);

/**
* Get the type of bar.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liamHowatt

Thank you for reviewing and checking the wording.

- change comment
type --> orientation  for orientation APIs
@@ -58,6 +68,7 @@ typedef struct {
_lv_bar_anim_t cur_value_anim;
_lv_bar_anim_t start_value_anim;
lv_bar_mode_t mode : 2; /**< Type of bar*/
lv_bar_orientation_t orient : 2; /**< Orientation of bar*/
Copy link
Collaborator

@PGNetHun PGNetHun May 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use full name: orientation instead of shortened name orient
(see: clean code -> "avoid mental mapping")

In C / C++ languages using full names instead of shortenings does not influence code behaviour and code size, but makes code easier to read. No need to figure out what names mean ("mental mapping")

/**
* Set the orientation of bar.
* @param obj pointer to bar object
* @param orient bar orientation from ::lv_bar_orientation_t
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could write full parameter name: orientation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree!

@@ -399,4 +403,92 @@ void test_bar_render_corner(void)
render_test_screen_create(true, LV_GRAD_DIR_VER, "widgets/bar_corner_6.png");
}

void test_bar_orientation(void)
Copy link
Collaborator

@PGNetHun PGNetHun May 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to add reference image also to compare the result with that.

Please simplify the code in this test, it just needs to test lv_bar_set_orientation function, and no need for special style for bar. Except maybe: add gradient color to see that orientation really works as expected. Similar gradient as mentioned here: #6172 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with these too.

orient->orientation
orient -> orientation
Copy link
Member

@kisvegabor kisvegabor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for opening this PR. Please fix the last two things pointed out @PGNetHun and I think it can be merged.

/**
* Set the orientation of bar.
* @param obj pointer to bar object
* @param orient bar orientation from ::lv_bar_orientation_t
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree!

@@ -399,4 +403,92 @@ void test_bar_render_corner(void)
render_test_screen_create(true, LV_GRAD_DIR_VER, "widgets/bar_corner_6.png");
}

void test_bar_orientation(void)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with these too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants