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

Label styles, LabelBackground #78

Merged
merged 10 commits into from
Nov 6, 2023
Merged

Label styles, LabelBackground #78

merged 10 commits into from
Nov 6, 2023

Conversation

mggower
Copy link
Collaborator

@mggower mggower commented Nov 1, 2023

Label styling

export type LabelPosition = 'bottom' | 'left' | 'top' | 'right'

export type LabelBackgroundStyle = {
  color: string
  opacity?: number
  padding?: number | number[]
}

export type LabelStyle = Partial<{
  fontName: string // important for unique bitmap styles
  fontSize: number
  margin: number // distance from node
  wordWrap: number
  letterSpacing: number
  fontFamily: string
  fontWeight: FontWeight
  stroke: Stroke
  color: string
  position: LabelPosition
  background: LabelBackgroundStyle
}>

Label class

  • a lot of effort into better aligning BitmapFont's with plain Text styles
  • should probably move BitmapFont's into a class and manage with a FontBook class so unused fonts are uninstalled
  • decoupled the methods for updating styles and setting the position
    • updating the label text or styles is interfaced via the update method
    • updating the label's position is interfaced via the moveTo method

Label Background class

  • is owned by the Label class directly
  • also exposes update and moveTo methods
  • follows the lifecycle of its Label parent

TODO: write some documentation for the above changes and styling options

Screenshot 2023-11-01 at 11 54 41 AM _screenshot from examples/native/labels_

@mggower mggower force-pushed the feature/label-styles branch 2 times, most recently from 1b7ec97 to affae79 Compare November 2, 2023 15:45
@mggower mggower changed the base branch from master to techdebt/v7-examples November 2, 2023 15:47
@mggower mggower changed the title Label styles, LabelBackground, and updated examples dir Label styles, LabelBackground Nov 6, 2023
Copy link
Contributor

@jameslaneconkling jameslaneconkling left a comment

Choose a reason for hiding this comment

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

at some point would be good to align the interface for all the objects. i.e. make sure the rules around what setup work is done in the constructor is consistent, and ditto how update/moveTo and what the rules are on when to invoke them.

Base automatically changed from techdebt/v7-examples to master November 6, 2023 20:28
@mggower mggower merged commit e31e727 into master Nov 6, 2023
2 checks passed
@mggower mggower deleted the feature/label-styles branch November 6, 2023 20:56
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.

2 participants