1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 |
--[[
Tab Buttons and Tab Button Groups:
These are a combination of a "check button" and a "radio group". They are typically hung off one of the edges of a window
and used to indicate which sub-panel within the window is currently active. Usual uses include Chat Channel/Filter management
and Character Pane management (displaying separate panes for skills, gear, pets, etc...)
Usage:
Initialize tab buttons with a type, this determines the textures that will be used as the button switches states (mouseover,
pressed, unpressed...) Do not set the textures manually. Valid types are defined in the TAB_DATA table.
Assign a callback function to the tab button so that when pressed or unpressed, it knows what action to take. Typically the
tab button only needs to take some action when it's pressed, not when it becomes unpressed; this is up to the system using
the tab buttons.
After creating and initializing a number of tab buttons, add them to a group which will manage their state and call the
appropriate callbacks as the user interacts with the window.
--]]
-- NOTE: Right and left edge will generally use icons and not labels.
-- When we need to implement them, they probably will need a very custom structure
-- that doesn't need to take advantage of the horizontal resizing of the tab.
local DL_ABOVE = 2
local DL_BELOW = 1
local PRESSED = 1
local UNPRESSED = 2
local DISABLED = 3
local TAB_DATA =
{
TopEdgeImage =
{
UnpressedImage = "EsoUI/Art/Tabs/tab_top_inactive.dds" ,
PressedImage = "EsoUI/Art/Tabs/tab_chat_active.dds" ,
UnpressedMouseOverImage = "EsoUI/Art/Tabs/tab_top_inactive_mouseOver.dds" ,
LeftCoords = { left = 0 , right = 0.25 , top = 0 , bottom = 1 } , -- NOTE: Assumes that the left and right slices match for pressed/unpressed
RightCoords = { left = 0.75 , right = 1 , top = 0 , bottom = 1 } ,
CenterCoords = { left = 0.25 , right = 0.75 , top = 0 , bottom = 1 } ,
SideSize = 12 ,
Height = 24 ,
MinFixedWidth = 80 ,
TooltipPosition = TOP ,
HasTabMouseOver = true ,
} ,
SimpleIcon =
{
SideSize = 0 ,
TooltipPosition = TOP ,
HasTabMouseOver = true ,
} ,
CroppedSimpleIcon =
{
SideSize = - 16 ,
TooltipPosition = TOP ,
HasTabMouseOver = true ,
} ,
SimpleIconHighlight =
{
SideSize = 0 ,
TooltipPosition = TOP ,
HasTabMouseOver = true ,
HasHighlight = true ,
} ,
QuestJournal =
{
UnpressedImage = "EsoUI/Art/Quest/questJournal_tab_inactive.dds" ,
PressedImage = "EsoUI/Art/Quest/questJournal_tab_active.dds" ,
UnpressedMouseOverImage = "EsoUI/Art/Quest/questJournal_tab_inactiveMouseOver.dds" ,
DisabledImage = "EsoUI/Art/Tabs/tab_disabled.dds" ,
LeftCoords = { left = 0 , right = 0.25 , top = 0.0 , bottom = 1 } , -- NOTE: Assumes that the left and right slices match for pressed/unpressed
RightCoords = { left = 0.734375 , right = 1 , top = 0.0 , bottom = 1 } ,
CenterCoords = { left = 0.25 , right = 0.734375 , top = 0.0 , bottom = 1 } ,
Height = 32 ,
SideSize = 16 ,
HasTabMouseOver = true ,
} ,
FancyBottomEdge =
{
UnpressedImage = "EsoUI/Art/Tabs/bottom_tab_inactive.dds" ,
PressedImage = "EsoUI/Art/Tabs/bottom_tab_active.dds" ,
UnpressedMouseOverImage = "EsoUI/Art/Tabs/bottom_tab_inactive_mouseOver.dds" ,
LeftCoords = { left = 0 , right = 0.203 , top = 0 , bottom = 0.58 } , -- NOTE: Assumes that the left and right slices match for pressed/unpressed
RightCoords = { left = 0.75 , right = 1 , top = 0 , bottom = 0.58 } ,
CenterCoords = { left = 0.203 , right = 0.75 , top = 0 , bottom = 0.58 } ,
SideSize = 13 ,
Height = 37 ,
HasTabMouseOver = true ,
TooltipPosition = BOTTOM ,
} ,
FancyBottomEdgeImage =
{
UnpressedImage = "EsoUI/Art/Tabs/bottom_tab_inactive.dds" ,
PressedImage = "EsoUI/Art/Tabs/bottom_tab_active.dds" ,
UnpressedMouseOverImage = "EsoUI/Art/Tabs/bottom_tab_inactive_mouseOver.dds" ,
LeftCoords = { left = 0 , right = 0.203 , top = 0 , bottom = 0.58 } , -- NOTE: Assumes that the left and right slices match for pressed/unpressed
RightCoords = { left = 0.75 , right = 1 , top = 0 , bottom = 0.58 } ,
CenterCoords = { left = 0.203 , right = 0.75 , top = 0 , bottom = 0.58 } ,
SideSize = 13 ,
HasTabMouseOver = true ,
TooltipPosition = BOTTOM ,
} ,
FancyTopEdgeImage =
{
UnpressedImage = "EsoUI/Art/Tabs/tab_top_inactive.dds" ,
PressedImage = "EsoUI/Art/Tabs/tab_top_active.dds" ,
UnpressedMouseOverImage = "EsoUI/Art/Tabs/tab_top_inactive_mouseOver.dds" ,
DisabledImage = "EsoUI/Art/Tabs/tab_top_inactive_disabled.dds" ,
LeftCoords = { left = 0 , right = 0.2344 , top = 0 , bottom = 1 } , -- NOTE: Assumes that the left and right slices match for pressed/unpressed
RightCoords = { left = 0.75 , right = 1 , top = 0 , bottom = 1 } ,
CenterCoords = { left = 0.2344 , right = 0.75 , top = 0 , bottom = 1 } ,
SideSize = 16 ,
HasTabMouseOver = true ,
TooltipPosition = TOP ,
} ,
SimpleText =
{
SideSize = 10 ,
Height = 24 ,
PressedTextColor = ZO_ColorDef : New ( GetInterfaceColor ( INTERFACE_COLOR_TYPE_TEXT_COLORS , INTERFACE_TEXT_COLOR_SELECTED ) ) ,
UnpressedTextColor = ZO_ColorDef : New ( GetInterfaceColor ( INTERFACE_COLOR_TYPE_TEXT_COLORS , INTERFACE_TEXT_COLOR_CONTRAST ) ) ,
UnpressedMouseOverTextColor = ZO_ColorDef : New ( GetInterfaceColor ( INTERFACE_COLOR_TYPE_TEXT_COLORS , INTERFACE_TEXT_COLOR_HIGHLIGHT ) ) ,
DisabledTextColor = ZO_ColorDef : New ( GetInterfaceColor ( INTERFACE_COLOR_TYPE_TEXT_COLORS , INTERFACE_TEXT_COLOR_DISABLED ) ) ,
TooltipPosition = TOP ,
HasTabMouseOver = true ,
Font = "ZoFontHeader2"
} ,
MainMenuSubcategory =
{
SideSize = 5 ,
Height = 32 ,
MinFixedWidth = 0 ,
MaxFixedWidth = 300 ,
PressedTextColor = ZO_ColorDef : New ( GetInterfaceColor ( INTERFACE_COLOR_TYPE_TEXT_COLORS , INTERFACE_TEXT_COLOR_SELECTED ) ) ,
UnpressedTextColor = ZO_ColorDef : New ( GetInterfaceColor ( INTERFACE_COLOR_TYPE_TEXT_COLORS , INTERFACE_TEXT_COLOR_CONTRAST ) ) ,
UnpressedMouseOverTextColor = ZO_ColorDef : New ( GetInterfaceColor ( INTERFACE_COLOR_TYPE_TEXT_COLORS , INTERFACE_TEXT_COLOR_HIGHLIGHT ) ) ,
TooltipPosition = TOP ,
HasTabMouseOver = true ,
Font = "ZoFontHeader3"
} ,
}
-- Early out.
return
end
else
end
end
end
end
else
end
end
end
if tabData . PressedImage and tabData . UnpressedImage then
local leftCoords = tabData . LeftCoords
local rightCoords = tabData . RightCoords
local centerCoords = tabData . CenterCoords
center : SetTextureCoords ( centerCoords . left , centerCoords . right , centerCoords . top , centerCoords . bottom )
end
end
end
-- Early out.
if not tab . tabType or not TAB_DATA [ tab . tabType ] then
return
end
local tabData = TAB_DATA [ tab . tabType ]
local width = textWidth + tabData . SideSize * 2
if tabData . MaxFixedWidth and width > tabData . MaxFixedWidth then
--Text is too long, resize and continue after the label redraws
else
if tabData . HasHighlight then
end
end
end
end
if tabTexture then
if center then
end
if left then
end
if right then
end
end
if iconTexture then
if hasHighlight then
if highlight then
end
else
end
if highlight then
end
end
end
end
if tabButton . state == DISABLED then
return
end
tabButton . state = PRESSED
end
if tabButton . state == DISABLED then
return
end
tabButton . state = UNPRESSED
end
tabButton . tabType = tabType
tabButton . unpressedCallback = unpressedCallback
-- These nil fields are added here for clarity.
tabButton . state = nil
tabButton . tabGroup = nil
-- Start tab buttons in the unpressed state, it's still not a member of a tab group
end
end
function ZO_TabButton_Text_Initialize ( control , tabType , initialText , pressedCallback , unpressedCallback , tabSizeChangedCallback )
if not tabType or not TAB_DATA [ tabType ] then
return
end
local tabData = TAB_DATA [ tabType ]
local sideSize = tabData . SideSize or 8
local height = tabData . Height or 24
if left then
end
if right then
end
if center then
end
if not tabData . PressedImage or not tabData . UnpressedImage then
if left then
end
if right then
end
if center then
end
end
if tabData . MaxFixedWidth then
end
if tabData . Font then
end
initialText = initialText or ""
end
do
local ICON_SIZE = 32
ICON_SIZE = overrideValue
end
ICON_SIZE = 32
end
-- Utility to create uniform tab icons that have normal padding and size.
function ZO_CreateUniformIconTabData ( sharedDataTable , icon , width , height , pressedIcon , unpressedIcon , mouseoverIcon , disabledIcon )
width = width or 32
height = height or 32
local verticalPadding = ( ICON_SIZE - height ) / 2
sharedDataTable . mouseoverIcon = mouseoverIcon
sharedDataTable . disabledIcon = disabledIcon
sharedDataTable . width = width
sharedDataTable . height = height
sharedDataTable . lowerPadding = verticalPadding
sharedDataTable . upperPadding = verticalPadding
return sharedDataTable
end
end
function ZO_TabButton_Icon_Initialize ( tabButton , tabType , visualData , pressedCallback , unpressedCallback )
tabButton . pressedIcon = visualData . pressedIcon
tabButton . unpressedIcon = visualData . unpressedIcon
tabButton . disabledIcon = visualData . disabledIcon
tabButton . mouseoverIcon = visualData . mouseoverIcon
tabButton . allowLabelColorChanges = true
local lowerPadding = visualData . lowerPadding or 0
local upperPadding = visualData . upperPadding or 0
local width = visualData . width or 32
local height = visualData . height or 32
local sideSize = TAB_DATA [ tabType ] . SideSize or 16
local leftCoord = visualData . textureLeft or 0
local rightCoord = visualData . textureRight or 1
local topCoord = visualData . textureTop or 0
local bottomCoord = visualData . textureBottom or 1
--If center is nil, this will just use icon's parent
if highlight then
end
end
local tabHeight = height + lowerPadding + upperPadding
if center then
end
if left then
end
if right then
end
end
tabButton . tooltipPosition = position
end
end
end
if tabButton . state == DISABLED or not tabButton . tabType then
return
end
local tabData = TAB_DATA [ tabButton . tabType ]
if tabData . HasHighlight then
end
local tooltipPos = tabButton . tooltipPosition or tabData . TooltipPosition
if tooltipPos == TOP then
else
end
end
--Only unpressed tabs get mouse over effects
if tabButton . state == UNPRESSED then
if tabData . HasTabMouseOver then
SetTabTextures ( tabButton , tabData . UnpressedMouseOverImage , tabButton . mouseoverIcon , tabData . HasHighlight )
end
if tabButton . allowLabelColorChanges and tabData . UnpressedMouseOverTextColor then
end
end
end
if tabButton . state == DISABLED or not tabButton . tabType then
return
end
local tabData = TAB_DATA [ tabButton . tabType ]
if tabData . HasHighlight then
end
end
--Only unpressed tabs get mouse over effects
if tabButton . state == UNPRESSED then
if tabData . HasTabMouseOver then
end
if tabButton . allowLabelColorChanges and tabData . UnpressedMouseOverTextColor then
end
end
end
return tabButton . state == DISABLED
end
-- Early out.
if not tabButton . tabType then
return
end
return
end
local tabData = TAB_DATA [ tabButton . tabType ]
if disabled then
-- NOTE: For now it is the caller's responsibility to make sure that any unpressedCallback gets called as a result of setting this to the disabled state.
tabButton . state = DISABLED
if tabData . HasHighlight then
end
end
if tabButton . allowLabelColorChanges and tabData . DisabledTextColor then
end
else
--Always revert back to unpressed
tabButton . state = UNPRESSED
end
if tabButton . allowLabelColorChanges and tabData . UnpressedTextColor then
end
else
end
end
end
end
end
end
end
end
else
end
end
--[[
TabButtonGroup implementation. This is modified from the radio button group because the
base tab button definition uses a label and a custom texturing method. It's probably overkill
to abstract the "group management" concept away from radio button group and have both
tab and radio button groups inherit from that base.
This will probably continue to be reworked.
--]]
--m_Buttons will be keyed by a tabButton control, and the stored value is either a handler function, or the same as the key.
end
-- Left mouse press will select a tab (if it's not pressed)
-- Right mouse press will be given the chance to open a context menu (coming soon...)
if buttonId == 1 then
if tabButton . state == PRESSED or tabButton . state == DISABLED then
--Early out, the button was already pressed
return
end
-- Set all buttons in the group to unpressed, and unlocked.
-- Only unpress the button that was pressed, and call its callback.
-- Do not do anything with buttons that were already unpressed.
if currentTabButton . state == PRESSED then
end
end
-- Select the new tab button
end
end
if tabButton then
-- Remember the original handler so that its call can be forced.
-- NOTE: The TabButton template will generally take action on mouse down, not on a full click.
-- This has to do with the fact that it's currently implemented as a label.
-- This throws away return values from the original function, which is most likely ok in the case of a click handler.
end
end
end
end
end
else
-- Need to clear out our handler in this case, otherwise
-- adding this tab to another group will call two tab group handlers
end
end
end
end
end
end
end
if currentTabButton . state == PRESSED then
return currentTabButton
end
end
return nil
end |