void GxDockArea::Draw() { GxDraw* draw = GxDraw::Get(); // Draw the dock bars. for(int i=0; i<binCount; ++i) if(myBins[i]) myBins[i]->Draw(); // Draw the floating docks. for(int i=0; i<myDocks.Size(); ++i) if(myDocks[i]->IsFloating() && !myDocks[i]->IsHidden()) myDocks[i]->Draw(); // Draw docking area highlights. if(myDragHl > 0.01f) { GxVec2i mpos = GxInput::Get()->GetMousePos(); int hl = myGetBinAt(mpos.x, mpos.y); if(myActionType != FA_DRAG) hl = -1; for(int i=0; i<binCount; ++i) if(myBins[i]) { GxRecti r = myBins[i]->myRect; GxColor c(128, 128, (hl == i) ? 160 : 128, 0); draw->Rect(r.x, r.y, r.w, r.h, c.Alpha(myDragHl * 0.5f)); r.Shrink(1); draw->Rect(r.x, r.y, r.w, r.h, c.Alpha(myDragHl * 0.2f)); } } }
void GxDock::Draw() { GxDraw* draw = GxDraw::Get(); GxStyle& style = *GxStyle::Get(); // Get the mouse over item GxVec2i mpos = GxInput::Get()->GetMousePos(); Item mouseItem = myGetItemAt(mpos.x, mpos.y); // Draw dock frame. GxRecti r = myRect; if(IsFloating()) { GxRecti f = r; f.Expand(16); style.d.dockFrame.DrawH(f.x, f.y, f.w, f.h); } else { style.d.dockBar.DrawH(r.x, r.y, r.w); } // Draw dock title GxRecti labelRect(r.x + 4, r.y, r.w - myButtons.Size()*btnW - 4, barH); style.Label(labelRect, GX_TA_LEFT, GX_TA_MIDDLE, myTitle, false); // Draw dock buttons GxColor fade = style.c.textColor.Alpha(64); int bx = r.x + r.w - btnW/2 - 4; int by = r.y + barH/2; for(int i=0; i<myButtons.Size(); ++i) { int type = myButtons[i]; bool hl = (mouseItem == type); GxSprite* sprite = &style.d.close; if(type == I_COLLAPSE) { sprite = &style.d.arrow; if(!myState[DS_COLLAPSED]) sprite->SetMirrorV(true); } GxColor col(255, 255, 255, hl ? 255 : 128); sprite->SetColor(col); sprite->Draw(bx, by); sprite->SetMirrorV(false); sprite->SetColor(255); bx -= 16; } // Draw layout if(!myState[DS_COLLAPSED]) myLayout->Draw(); }
GxRecti GxSelectList::myGetListRect() const { if(myScrollbar->IsHidden()) { GxRecti r = myRect; r.Shrink(2); return r; } const int ofs = 2 - GxInt(myScrollbar->GetValue()); return GxRecti(myRect.x + 2, myRect.y + ofs, myRect.w - 20, myItems.Size() * 16); }
GxVec2i GxDock::myGetResizeDir(int x, int y) const { GxVec2i dir(0, 0); GxRecti r = myRect; r.Shrink(6); if(x < r.x) dir.x = -1; if(x > r.x+r.w) dir.x = +1; if(y < r.y) dir.y = -1; if(y > r.y+r.h) dir.y = +1; return dir; }
void GxColorEdit::Draw() { GxExpandingButton::Draw(); GxDraw* draw = GxDraw::Get(); GxStyle& style = *GxStyle::Get(); GxRecti r = myRect; // Draw the preview color. r.Shrink(3, 3, myButtonW + 3, r.h - myButtonH + 3); draw->Rect(r.x, r.y, r.w, r.h, style.c.frameOutline); r.Shrink(1); GxVec4f colf = GetSliderColor(mySliders); GxColor col(colf.x, colf.y, colf.z, colf.w); draw->Rect(r.x, r.y, r.w, r.h, col); if(col.a < 255) draw->Rect(r.x, r.y, r.w/2, r.h, col.Alpha(255)); }
void GxDockArea::Tick(float dt) { GxVec2i mpos = GxInput::Get()->GetMousePos(); mpos.x = GxClamp(mpos.x, 0, myRect.w); mpos.y = GxClamp(mpos.y, 0, myRect.h); GxVec2i resizeDir = GxVec2i(0, 0); bool draggingAction = false; if(myHoverDock) { GxDock::Item item = myHoverDock->myGetItemAt(mpos.x, mpos.y); if(item == GxDock::I_BAR) draggingAction = true; if(item == GxDock::I_FRAME) resizeDir = myHoverDock->myGetResizeDir(mpos.x, mpos.y); } // Handle floating dock dragging action. if(myActionType == FA_DRAG) { draggingAction = true; GxRecti r = myActionDims; r.x += mpos.x - myActionPos.x; r.y += mpos.y - myActionPos.y; myFocusDock->myFloatRect = r; myFocusDock->myClampFloatSize(GxVec2i()); myFocusDock->myClampFloatPos(GxVec2i(myRect.w, myRect.h)); myDragHl = GxMin(1.f, myDragHl + dt * 2); } else { myDragHl = GxMax(0.f, myDragHl - dt * 4); } // Handle floating dock resize action. if(myActionType == FA_RESIZE) { resizeDir = myResizeDir; GxRecti r = myActionDims; GxVec2i d = mpos - myActionPos; if(myResizeDir.x < 0) r.Expand(-d.x, 0, 0, 0); if(myResizeDir.y < 0) r.Expand(0, -d.y, 0, 0); if(myResizeDir.x > 0) r.Expand(0, 0, +d.x, 0); if(myResizeDir.y > 0) r.Expand(0, 0, 0, +d.y); myFocusDock->myFloatRect = r; myFocusDock->myClampFloatSize(myResizeDir); myFocusDock->myClampFloatPos(GxVec2i(myRect.w, myRect.h)); } // Change the mouse cursor image when resizing. if(resizeDir.x != 0 || resizeDir.y != 0) { GxVec2i d = resizeDir; GxCursorImage c = GX_CI_DRAG; if(d.x != 0 && d.y == 0) c = GX_CI_SIZE_WE; if(d.x == 0 && d.y != 0) c = GX_CI_SIZE_NS; if(d.x < 0 && d.y < 0) c = GX_CI_SIZE_NWSE; if(d.x > 0 && d.y > 0) c = GX_CI_SIZE_NWSE; if(d.x < 0 && d.y > 0) c = GX_CI_SIZE_NESW; if(d.x > 0 && d.y < 0) c = GX_CI_SIZE_NESW; GetContext()->SetCursor(c); } // Change the mouse cursor image when dragging. if(draggingAction) { GetContext()->SetCursor(GX_CI_DRAG); } // Tick the dock bars. for(int i=0; i<binCount; ++i) if(myBins[i]) myBins[i]->Tick(dt); // Tick the floating docks. for(int i=0; i<myDocks.Size(); ++i) if(myDocks[i]->IsFloating() && !myDocks[i]->IsHidden()) myDocks[i]->Tick(dt); }