Skip to content

Instantly share code, notes, and snippets.

@knappador
Created June 11, 2014 03:51
Show Gist options
  • Save knappador/fda4ec6d0145322435fa to your computer and use it in GitHub Desktop.
Save knappador/fda4ec6d0145322435fa to your computer and use it in GitHub Desktop.
An Example of More Complicated Dimensions Definition
''' This module contains a list of all "styles" where each more specific
style will override the more general one all the way to the default. Any
attribute type can be used and will be available on the DimensionController
instance, d_ctl inside the kv file. Importing the d_ctl into the kv
namespace allows the entire kv file to recieve any property updates
resulting from UI rotation or resizeing dynamically.'''
''' currently this implementation has no support for nesting
so the namespace could become cluttered on complex UI's. What is the
Solution? '''
# default definition should contain every key
# to avoid properties being missing whenever the kv
# file is being parsed
default = {
# game screen
'a_sh' : (1.0, 0.8),
'a_ph' : {'x' : 0.0, 'y' : 0.1},
'nav_size_hint' : (0.16, 0.45),
'nav_pos_hint' : {'x' : 0.0, 'y' : 0.525},
#'itop_sh' : (0.8, 0.15),
#'itop_ph' : {'x' : 0.1, 'y' : 0.75},
#'p_sh' : (0.9, 0.5),
#'p_ph' : {'x' : 0.05, 'y' : 0.25},
#'ibot_sh' : (0.8, 0.15),
#'ibot_ph' : {'x' : 0.1, 'y' : 0.1},
'b_sh' : (1.0, 0.1),
'b_ph' : {'x' : 0.0, 'y' : 0.0},
# home screen
'title_sh' : (0.9, 0.24),
'title_ph' : {'x' : 0.05, 'y' : 0.76},
'casino_sh' : (0.6, 0.2),
'casino_ph' : {'x' : 0.2, 'y' : 0.6},
'hnav_sh' : (0.9, 0.6),
'hnav_ph' : {'x' : 0.05, 'y' : 0.06},
'hnav_cols' : 1,
'hnav_rows' : 4,
# options screen
'back_sh' : (0.25, 0.06),
'back_ph' : {'x' : 0.05, 'y' : 0.9},
#'otitle_sh' : (0.65, 0.1),
#'otitle_ph' : {'x' : 0.33, 'y' : 0.885},
# color selectors
'cs1_sh' : (0.5, 0.3),
'cs1_ph' : {'x' : 0.05, 'y' : 0.71},
'cs2_sh' : (0.5, 0.3),
'cs2_ph' : {'x' : 0.05, 'y' : 0.45},
'l1_sh' : (0.36, 0.13),
'l1_ph' : {'x' : 0.64, 'y' : 0.79},
'l2_sh' : (0.36, 0.13),
'l2_ph' : {'x' : 0.64, 'y' : 0.52},
'swatch_sh' : (0.8, 0.26),
'swatch_ph' : {'x' : 0.04, 'y' : 0.05},
# volume controls
'st_sh' : (0.4, 0.35),
'st_ph' : {'x' : 0.125, 'y' : 0.57},
'voll_sh' : (0.34, 0.39),
'voll_ph' : {'x' : 0.55, 'y' : 0.56},
'vol_sh' : (0.7, 0.2),
'vol_ph' : {'x' : 0.15, 'y' : 0.16},
}
# defaults for portrait
portrait = {
# color swatches
'cs1_sh' : (0.35, 0.3),
'cs1_ph' : {'x' : 0.1, 'y' : 0.45},
'cs2_sh' : (0.35, 0.3),
'cs2_ph' : {'x' : 0.55, 'y' : 0.45},
'l1_sh' : (0.36, 0.2),
'l1_ph' : {'x' : 0.2, 'y' : 0.79},
'l2_sh' : (0.36, 0.2),
'l2_ph' : {'x' : 0.66, 'y' : 0.79},
'swatch_sh' : (0.8, 0.3),
'swatch_ph' : {'x' : 0.1, 'y' : 0.05},
}
# defaults for portrait on tall devices
portrait_tall = {
}
# specific rules for tall tablets in portriat
portrait_tall_tablet = {
}
# specific rules for tall phones in portriat
portrait_tall_phone = {
}
# specific rules for short devices
portrait_short = {
}
# specific rules for short tablets in portriat
portrait_short_tablet = {
}
# and so on and so on
portrait_short_phone = {
}
landscape = {
# home screen
'title_sh' : (0.8, 0.3),
'title_ph' : {'x' : 0.1, 'y' : 0.66},
'casino_sh' : (0.6, 0.25),
'casino_ph' : {'x' : 0.2, 'y' : 0.45},
'hnav_sh' : (0.7, 0.4),
'hnav_ph' : {'x' : 0.15, 'y' : 0.06},
'hnav_cols' : 2,
'hnav_rows' : 2,
# options screen
'back_sh' : (0.17, 0.08),
'back_ph' : {'x' : 0.02, 'y' : 0.88},
#'otitle_sh' : (0.5, 0.2),
#'otitle_ph' : {'x' : -0.15, 'y' : 0.33},
#'otitle_r' : 90,
#'otitle_scale' : 0.1,
# volume
'st_sh' : (0.9, 0.24),
'st_ph' : {'x' : 0.05, 'y' : 0.66},
'voll_sh' : (0.6, 0.2),
'voll_ph' : {'x' : 0.2, 'y' : 0.4},
'nav_size_hint' : (0.16, 0.45),
'nav_pos_hint' : {'x' : 0.0, 'y' : 0.525},
'a_sh' : (0.84, 1.0),
'a_ph' : {'x' : 0.16, 'y' : 0.0},
'b_sh' : (0.16, 0.45),
'b_ph' : {'x' : 0.0, 'y' : 0.025},
}
landscape_tall = {
# home screen
'title_sh' : (0.8, 0.3),
'title_ph' : {'x' : 0.1, 'y' : 0.7},
'casino_sh' : (0.6, 0.25),
'casino_ph' : {'x' : 0.2, 'y' : 0.5},
'hnav_sh' : (0.7, 0.4),
'hnav_ph' : {'x' : 0.15, 'y' : 0.1},
# play
'nav_size_hint' : (0.16, 0.45),
'nav_pos_hint' : {'x' : 0.0, 'y' : 0.525},
'a_sh' : (0.84, 1.0),
'a_ph' : {'x' : 0.16, 'y' : 0.0},
'b_sh' : (0.16, 0.45),
'b_ph' : {'x' : 0.0, 'y' : 0.025},
}
landscape_tall_tablet = {
}
landscape_tall_phone = {
}
landscape_short = {
}
landscape_short_tablet = {
}
landscape_short_phone = {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment